Class: Junoser::Parser
- Inherits:
-
Parslet::Parser
- Object
- Parslet::Parser
- Junoser::Parser
- Defined in:
- lib/junoser/parser.rb
Instance Method Summary collapse
-
#a(object, arg, *children) ⇒ Object
with an argument, and children maybe.
-
#b(object, *children) ⇒ Object
block with children maybe.
-
#c(*objects) ⇒ Object
choice.
-
#s(*objects) ⇒ Object
sequence.
-
#sc(*objects) ⇒ Object
sequential choice.
Instance Method Details
#a(object, arg, *children) ⇒ Object
with an argument, and children maybe
11 12 13 |
# File 'lib/junoser/parser.rb', line 11 def a(object, arg, *children) b(object.as(:statement) >> space >> arg.as(:argument), *children) end |
#b(object, *children) ⇒ Object
block with children maybe
6 7 8 |
# File 'lib/junoser/parser.rb', line 6 def b(object, *children) children.inject(object) {|rule, child| rule.as(:label) >> (space >> child.as(:child) | eos) } end |
#c(*objects) ⇒ Object
choice
16 17 18 |
# File 'lib/junoser/parser.rb', line 16 def c(*objects) objects.inject {|rule, object| rule | object } end |
#s(*objects) ⇒ Object
sequence
21 22 23 24 |
# File 'lib/junoser/parser.rb', line 21 def s(*objects) # TODO: eval "minOccurs" attribute of choice element objects.inject {|rule, object| rule >> (space >> object).maybe } end |
#sc(*objects) ⇒ Object
sequential choice
27 28 29 |
# File 'lib/junoser/parser.rb', line 27 def sc(*objects) (c(*objects) >> space.maybe).repeat(0) end |