class Rattler::Parsers::SemanticAction
SemanticAction
is a pseudo-parser that performs a semantic action by evaluating ruby code in the context of a parser scope.
Public Class Methods
[](code)
click to toggle source
@param [String] code ruby code that can be bound to a parser scope to
perform an action
@return [SemanticAction] a pseudo-parser that performs a semantic action
# File lib/rattler/parsers/semantic_action.rb, line 16 def self.[](code) self.new(:code => code.strip) end
Public Instance Methods
parse(scanner, rules, scope = ParserScope.empty)
click to toggle source
Perform the semantic action in the context of scope
@param (see Match#parse
)
@return the result of performing the semantic action in the context of
+scope+
# File lib/rattler/parsers/semantic_action.rb, line 26 def parse(scanner, rules, scope = ParserScope.empty) apply scope end
Protected Instance Methods
create_bindable_code()
click to toggle source
@return [ActionCode] an object that be bound to a parser scope to return
ruby code that performs the action
# File lib/rattler/parsers/semantic_action.rb, line 34 def create_bindable_code ActionCode.new(code) end