Class: Rattler::BackEnd::ParserGenerator::GroupMatch

Inherits:
Parsers::Parser show all
Defined in:
lib/rattler/back_end/parser_generator/group_match.rb

Instance Method Summary collapse

Methods inherited from Parsers::Parser

#&, #capturing?, #labeled?, #one_or_more, #optional, parsed, #skip, #variable_capture_count?, #with_ws, #zero_or_more, #|

Methods inherited from Util::Node

#==, [], #[], #attrs, #can_equal?, #child, #children, #each, #empty?, #eql?, #initialize, #inspect, #method_missing, #name, #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_countObject



13
14
15
# File 'lib/rattler/back_end/parser_generator/group_match.rb', line 13

def capture_count
  num_groups
end

#parse(scanner, rules, scope = {}) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/rattler/back_end/parser_generator/group_match.rb', line 17

def parse(scanner, rules, scope={})
  scanner.scan(re) && if num_groups == 1
    scanner[1]
  else
    (1..num_groups).map {|_| scanner[_] }
  end
end

#reObject



9
10
11
# File 'lib/rattler/back_end/parser_generator/group_match.rb', line 9

def re
  match.re
end