Class: Rattler::Compiler::ParserGenerator::GroupMatch
- Inherits:
-
Parsers::Parser
- Object
- Util::Node
- Parsers::Parser
- Rattler::Compiler::ParserGenerator::GroupMatch
- Defined in:
- lib/rattler/compiler/parser_generator/group_match.rb
Instance Method Summary collapse
- #capture_count ⇒ Object
- #parse(scanner, rules, scope = ParserScope.empty) ⇒ Object
- #re ⇒ Object
- #sequence? ⇒ Boolean
Methods inherited from Parsers::Parser
#&, #>>, #capturing?, #capturing_decidable?, #labeled?, #list, #one_or_more, #optional, parsed, #repeat, #semantic?, #skip, #variable_capture_count?, #with_ws, #zero_or_more, #|
Methods included from Runtime::ParserHelper
Methods inherited from Util::Node
#==, [], #[], #attrs, #can_equal?, #child, #children, #each, #empty?, #eql?, #initialize, #inspect, #method_missing, #name, #pretty_print, #pretty_print_cycle, #respond_to?, #same_contents?, #to_graphviz, #with_attrs, #with_attrs!, #with_children
Constructor Details
This class inherits a constructor from Rattler::Util::Node
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Rattler::Util::Node
Instance Method Details
#capture_count ⇒ Object
13 14 15 |
# File 'lib/rattler/compiler/parser_generator/group_match.rb', line 13 def capture_count num_groups end |
#parse(scanner, rules, scope = ParserScope.empty) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/rattler/compiler/parser_generator/group_match.rb', line 17 def parse(scanner, rules, scope = ParserScope.empty) scanner.scan(re) && if num_groups == 1 yield scope.nest.capture(scanner[1]) if block_given? scanner[1] else rs = (1..num_groups).map {|_| scanner[_] } yield scope.nest.capture(*rs) if block_given? rs end end |
#re ⇒ Object
9 10 11 |
# File 'lib/rattler/compiler/parser_generator/group_match.rb', line 9 def re match.re end |
#sequence? ⇒ Boolean
28 29 30 |
# File 'lib/rattler/compiler/parser_generator/group_match.rb', line 28 def sequence? num_groups > 1 end |