Class: Sapluuna::Parser
- Inherits:
-
Object
- Object
- Sapluuna::Parser
- Defined in:
- lib/sapluuna/parser.rb
Defined Under Namespace
Classes: ParserError, UnterminatedBlock
Constant Summary collapse
- CODE_OPEN =
'<%\s*'
- CODE_CLOSE =
'\s*%>'
- TEMPLATE_OPEN =
'[\t ]*{{{[\t ]*'
- TEMPLATE_CLOSE =
'[\t ]*}}}[\t ]*\n?'
- NEW_LINE =
"\n"
Instance Method Summary collapse
-
#initialize ⇒ Parser
constructor
A new instance of Parser.
- #parse(input) ⇒ Object
Constructor Details
#initialize ⇒ Parser
Returns a new instance of Parser.
13 14 15 |
# File 'lib/sapluuna/parser.rb', line 13 def initialize @sc = StringScanner.new '' end |
Instance Method Details
#parse(input) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/sapluuna/parser.rb', line 17 def parse input level = 0 cfg = [] @sc.string = input loop do if @sc.scan_until Regexp.new(TEMPLATE_OPEN) cfg << [:template, get_labels, get_template(level)] else break end end @sc.string = '' # no need to keep it in memory cfg end |