Class: Template::Parser::Template

Inherits:
Language
  • Object
show all
Defined in:
lib/template/parser/template.rb

Instance Method Summary collapse

Methods inherited from Language

<<, >>, absent, aka, #any, ignore, #inspect, maybe, parse, #parse, repeat, #str, then, #to_s, |

Instance Method Details

#backslashObject



16
17
18
# File 'lib/template/parser/template.rb', line 16

def backslash
  str("\\")
end

#closing_curly_bracketObject



12
13
14
# File 'lib/template/parser/template.rb', line 12

def closing_curly_bracket
  str("}")
end

#codeObject



4
5
6
# File 'lib/template/parser/template.rb', line 4

def code
  ::Code::Parser::Code
end

#code_partObject



20
21
22
# File 'lib/template/parser/template.rb', line 20

def code_part
  opening_curly_bracket << code << (closing_curly_bracket | any.absent)
end

#opening_curly_bracketObject



8
9
10
# File 'lib/template/parser/template.rb', line 8

def opening_curly_bracket
  str("{")
end

#rootObject



33
34
35
36
# File 'lib/template/parser/template.rb', line 33

def root
  (code_part.aka(:code) | text_part.aka(:text)).repeat |
    str("").aka(:text).repeat(1, 1)
end

#text_characterObject



24
25
26
27
# File 'lib/template/parser/template.rb', line 24

def text_character
  (backslash.ignore << opening_curly_bracket) |
    (opening_curly_bracket.absent << any)
end

#text_partObject



29
30
31
# File 'lib/template/parser/template.rb', line 29

def text_part
  text_character.repeat(1)
end