Class: Rattler::Parsers::ZeroOrMore
- Inherits:
-
Parser
- Object
- Util::Node
- Parser
- Rattler::Parsers::ZeroOrMore
- Includes:
- Combining
- Defined in:
- lib/rattler/parsers/zero_or_more.rb
Overview
ZeroOrMore decorates a parser to match repeatedly and always succeed.
Instance Method Summary collapse
-
#parse(scanner, rules, scope = {}) ⇒ Array, true
Parse using the decorated parser as many times as it succeeds.
- #variable_capture_count? ⇒ Boolean
Methods included from Combining
Methods inherited from Parser
#&, #capturing?, #labeled?, #one_or_more, #optional, parsed, #skip, #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
#parse(scanner, rules, scope = {}) ⇒ Array, true
Parse using the decorated parser as many times as it succeeds. Return the results in an array, or true if the decorated parser is not capturing?.
27 28 29 30 31 32 33 |
# File 'lib/rattler/parsers/zero_or_more.rb', line 27 def parse(scanner, rules, scope = {}) a = [] while result = child.parse(scanner, rules, scope) a << result end capturing? ? a : true end |
#variable_capture_count? ⇒ Boolean
35 36 37 |
# File 'lib/rattler/parsers/zero_or_more.rb', line 35 def variable_capture_count? true end |