Class: EJX::Template::BalanceScanner
- Inherits:
-
Object
- Object
- EJX::Template::BalanceScanner
- Includes:
- StreamParser
- Defined in:
- lib/ejx/template/balance_scanner.rb
Constant Summary collapse
- BALANCE =
{ "}" => "{", ")" => "(", "{" => "}", "(" => ")", }
Instance Method Summary collapse
Instance Method Details
#parse(stack = []) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/ejx/template/balance_scanner.rb', line 11 def parse(stack = []) while !eos? if match = scan_until(/[\(\)\{\}\"\'\`]/) case match[0] when "}", ")" if stack.last == BALANCE[match[0]] stack.pop else stack << match[0] end when "\"", "'", "`" quoted_value(match[0]) else stack << match[0] end end end stack end |