Class: Rattler::Parsers::Super

Inherits:
Parser show all
Defined in:
lib/rattler/parsers/super.rb

Overview

Super parses by applying the rule of the same name inherited from a super-grammar.

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Parser

#&, #>>, #capturing?, #labeled?, #list, #one_or_more, #optional, parsed, #repeat, #semantic?, #sequence?, #skip, #variable_capture_count?, #with_ws, #zero_or_more, #|

Methods included from Runtime::ParserHelper

#select_captures

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

.[](rule_name) ⇒ Apply

Returns a new parser that parses by applying the rule referenced by rule_name in a super-grammar.

Parameters:

  • rule_name (Symbol)

    the name of the referenced rule

Returns:

  • (Apply)

    a new parser that parses by applying the rule referenced by rule_name in a super-grammar



13
14
15
# File 'lib/rattler/parsers/super.rb', line 13

def self.[](rule_name)
  self.new(:rule_name => rule_name.to_sym)
end

Instance Method Details

#capturing_decidable?Object

true if it can be determined statically whether the parser returns parse results on success

Returns:

  • true if it can be determined statically whether the parser returns parse results on success



28
29
30
# File 'lib/rattler/parsers/super.rb', line 28

def capturing_decidable?
  false
end

#parse(scanner, rules, scope = ParserScope.empty) ⇒ Object

Apply the parse rule of the same name inherited from a super-grammar.

Parameters:

  • scanner (StringScanner)

    the scanner for the current parse

  • rules (RuleSet)

    the grammar rules being used for the current parse

  • scope (ParserScope) (defaults to: ParserScope.empty)

    the scope of captured results

Returns:

  • the result of applying parse rule of the same name inherited from a super-grammar



23
24
25
# File 'lib/rattler/parsers/super.rb', line 23

def parse(scanner, rules, scope = ParserScope.empty)
  rules.inherited_rule(rule_name).parse(scanner, rules, scope)
end