Class: Rattler::Parsers::Apply
- Inherits:
-
Parser
- Object
- Util::Node
- Parser
- Rattler::Parsers::Apply
- Defined in:
- lib/rattler/parsers/apply.rb
Overview
Apply
parses by applying a referenced parse rule.
Class Method Summary collapse
-
.[](rule_name) ⇒ Apply
Create a new parser that parses by applying the parse rule referenced by
rule_name
. - .parsed(results) ⇒ Object
Instance Method Summary collapse
-
#parse(scanner, rules, scope = {}) ⇒ Object
Apply the parse rule referenced by the #rule_name.
Methods inherited from Parser
#&, #capturing?, #labeled?, #one_or_more, #optional, #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
Class Method Details
.[](rule_name) ⇒ Apply
Create a new parser that parses by applying the parse rule referenced by rule_name
.
25 26 27 |
# File 'lib/rattler/parsers/apply.rb', line 25 def self.[](rule_name) self.new(:rule_name => rule_name.to_sym) end |
.parsed(results) ⇒ Object
30 31 32 |
# File 'lib/rattler/parsers/apply.rb', line 30 def self.parsed(results) #:nodoc: self[results.first] end |
Instance Method Details
#parse(scanner, rules, scope = {}) ⇒ Object
Apply the parse rule referenced by the #rule_name.
39 40 41 |
# File 'lib/rattler/parsers/apply.rb', line 39 def parse(scanner, rules, scope = {}) (rule = rules[rule_name]) && rule.parse(scanner, rules) end |