Class: Rattler::Parsers::SemanticAction
- Inherits:
-
Parser
- Object
- Util::Node
- Parser
- Rattler::Parsers::SemanticAction
- Includes:
- Semantic
- Defined in:
- lib/rattler/parsers/semantic_action.rb
Overview
SemanticAction
is a pseudo-parser that performs a semantic action by evaluating ruby code in the context of a parser scope.
Class Method Summary collapse
-
.[](code) ⇒ SemanticAction
A pseudo-parser that performs a semantic action.
- .parsed(results, *_) ⇒ Object
Instance Method Summary collapse
-
#parse(scanner, rules, scope = ParserScope.empty) ⇒ Object
Perform the semantic action in the context of
scope
.
Methods included from Semantic
#bind, #bindable_code, #semantic?
Methods inherited from Parser
#&, #>>, #capturing?, #capturing_decidable?, #labeled?, #list, #one_or_more, #optional, #repeat, #semantic?, #sequence?, #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
Class Method Details
.[](code) ⇒ SemanticAction
Returns a pseudo-parser that performs a semantic action.
16 17 18 |
# File 'lib/rattler/parsers/semantic_action.rb', line 16 def self.[](code) self.new(:code => code.strip) end |
.parsed(results, *_) ⇒ Object
9 10 11 |
# File 'lib/rattler/parsers/semantic_action.rb', line 9 def self.parsed(results, *_) #:nodoc: self[results.first] end |
Instance Method Details
#parse(scanner, rules, scope = ParserScope.empty) ⇒ Object
Perform the semantic action in the context of scope
26 27 28 |
# File 'lib/rattler/parsers/semantic_action.rb', line 26 def parse(scanner, rules, scope = ParserScope.empty) apply scope end |