Module: OOPeg::Parser::ClassMethods
Instance Method Summary collapse
Methods included from Combinators
Instance Method Details
#and(*parsers, name: nil) ⇒ Object
10 11 12 |
# File 'lib/oo_peg/parser/class_methods.rb', line 10 def and(*parsers, name: nil) _sequence(*parsers, name:) end |
#or(*parsers, name: nil) ⇒ Object
14 15 16 |
# File 'lib/oo_peg/parser/class_methods.rb', line 14 def or(*parsers, name: nil) _select(*parsers, name:) end |
#parse(parser, input) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/oo_peg/parser/class_methods.rb', line 19 def parse(parser, input) raise ArgumentError, "parser must be an instance of #{self}" unless self === parser case input when String parser.parse(OOPeg::Input.new(input.grapheme_clusters)) when OOPeg::Input parser.parse(input) else raise ArgumentError, "input must be a string or instance of Input" unless self.class === parser end end |