Class: Treetop::Compiler::ParsingExpression

### Home Classes Methods

### In Files

- lib/treetop/compiler/node_classes/parsing_expression.rb

### Parent

Runtime::SyntaxNode

### Methods

- #accumulate_subexpression_result
- #accumulator_var
- #assign_failure
- #assign_lazily_instantiated_node
- #assign_result
- #begin_comment
- #compile
- #declared_module_name
- #decorated?
- #end_comment
- #epsilon_node
- #extend_result
- #extend_result_with_declared_module
- #extend_result_with_inline_module
- #init_value
- #inline_module_name
- #node_class_name
- #obtain_new_subexpression_address
- #on_one_line
- #optional_arg
- #reset_index
- #result_var
- #start_index_var
- #subexpression_result_var
- #subexpression_success?
- #use_vars
- #var
- #var_initialization

### Files

- LICENSE

### Class/Module Index

Quicksearch

- Treetop
- Treetop::Compiler
- Treetop::Compiler::AndPredicate
- Treetop::Compiler::AnythingSymbol
- Treetop::Compiler::AtomicExpression
- Treetop::Compiler::CharacterClass
- Treetop::Compiler::Choice
- Treetop::Compiler::DeclarationSequence
- Treetop::Compiler::Grammar
- Treetop::Compiler::GrammarCompiler
- Treetop::Compiler::InlineModule
- Treetop::Compiler::InlineModuleMixin
- Treetop::Compiler::LexicalAddressSpace
- Treetop::Compiler::Metagrammar
- Treetop::Compiler::Metagrammar::BracketExpression0
- Treetop::Compiler::Metagrammar::CharacterClass0
- Treetop::Compiler::Metagrammar::CharacterClass1
- Treetop::Compiler::Metagrammar::CharacterClass2
- Treetop::Compiler::Metagrammar::CharacterClass3
- Treetop::Compiler::Metagrammar::CharacterClass4
- Treetop::Compiler::Metagrammar::Choice0
- Treetop::Compiler::Metagrammar::Choice1
- Treetop::Compiler::Metagrammar::Choice2
- Treetop::Compiler::Metagrammar::CommentToEol0
- Treetop::Compiler::Metagrammar::CommentToEol1
- Treetop::Compiler::Metagrammar::DeclarationSequence0
- Treetop::Compiler::Metagrammar::DeclarationSequence1
- Treetop::Compiler::Metagrammar::DeclarationSequence2
- Treetop::Compiler::Metagrammar::DeclarationSequence3
- Treetop::Compiler::Metagrammar::DoubleQuotedString0
- Treetop::Compiler::Metagrammar::DoubleQuotedString1
- Treetop::Compiler::Metagrammar::Grammar0
- Treetop::Compiler::Metagrammar::Grammar1
- Treetop::Compiler::Metagrammar::GrammarName0
- Treetop::Compiler::Metagrammar::IncludeDeclaration0
- Treetop::Compiler::Metagrammar::IncludeDeclaration1
- Treetop::Compiler::Metagrammar::InlineModule0
- Treetop::Compiler::Metagrammar::InlineModule1
- Treetop::Compiler::Metagrammar::KeywordInsideGrammar0
- Treetop::Compiler::Metagrammar::LabeledExpressionSequenceBody0
- Treetop::Compiler::Metagrammar::LabeledSequencePrimary0
- Treetop::Compiler::Metagrammar::LabeledSequencePrimary1
- Treetop::Compiler::Metagrammar::ModuleDeclaration0
- Treetop::Compiler::Metagrammar::ModuleDeclaration1
- Treetop::Compiler::Metagrammar::ModuleDeclaration2
- Treetop::Compiler::Metagrammar::ModuleDeclaration3
- Treetop::Compiler::Metagrammar::ModuleDeclaration4
- Treetop::Compiler::Metagrammar::ModuleDeclaration5
- Treetop::Compiler::Metagrammar::NamedLabel0
- Treetop::Compiler::Metagrammar::NamedLabel1
- Treetop::Compiler::Metagrammar::NamedLabel2
- Treetop::Compiler::Metagrammar::NodeClassDeclarations0
- Treetop::Compiler::Metagrammar::NodeClassDeclarations1
- Treetop::Compiler::Metagrammar::NodeClassExpression0
- Treetop::Compiler::Metagrammar::NodeClassExpression1
- Treetop::Compiler::Metagrammar::NodeClassExpression2
- Treetop::Compiler::Metagrammar::NodeClassExpression3
- Treetop::Compiler::Metagrammar::NonSpaceChar0
- Treetop::Compiler::Metagrammar::Nonterminal0
- Treetop::Compiler::Metagrammar::Nonterminal1
- Treetop::Compiler::Metagrammar::NullLabel0
- Treetop::Compiler::Metagrammar::OccurrenceRange0
- Treetop::Compiler::Metagrammar::ParenthesizedExpression0
- Treetop::Compiler::Metagrammar::ParenthesizedExpression1
- Treetop::Compiler::Metagrammar::ParsingRule0
- Treetop::Compiler::Metagrammar::ParsingRule1
- Treetop::Compiler::Metagrammar::PredicateBlock0
- Treetop::Compiler::Metagrammar::Primary0
- Treetop::Compiler::Metagrammar::Primary1
- Treetop::Compiler::Metagrammar::Primary2
- Treetop::Compiler::Metagrammar::Primary3
- Treetop::Compiler::Metagrammar::Primary4
- Treetop::Compiler::Metagrammar::Primary5
- Treetop::Compiler::Metagrammar::Primary6
- Treetop::Compiler::Metagrammar::Primary7
- Treetop::Compiler::Metagrammar::QuotedString0
- Treetop::Compiler::Metagrammar::RequireStatement0
- Treetop::Compiler::Metagrammar::Sequence0
- Treetop::Compiler::Metagrammar::Sequence1
- Treetop::Compiler::Metagrammar::SequencePrimary0
- Treetop::Compiler::Metagrammar::SequencePrimary1
- Treetop::Compiler::Metagrammar::SequencePrimary2
- Treetop::Compiler::Metagrammar::SequencePrimary3
- Treetop::Compiler::Metagrammar::SequencePrimary4
- Treetop::Compiler::Metagrammar::SequencePrimary5
- Treetop::Compiler::Metagrammar::SingleQuotedString0
- Treetop::Compiler::Metagrammar::SingleQuotedString1
- Treetop::Compiler::Metagrammar::TrailingInlineModule0
- Treetop::Compiler::Metagrammar::TrailingInlineModule1
- Treetop::Compiler::Metagrammar::TrailingInlineModule2
- Treetop::Compiler::Metagrammar::TreetopFile0
- Treetop::Compiler::Metagrammar::TreetopFile1
- Treetop::Compiler::Metagrammar::TreetopFile2
- Treetop::Compiler::Metagrammar::UnlabeledSequencePrimary0
- Treetop::Compiler::Metagrammar::UnlabeledSequencePrimary1
- Treetop::Compiler::Metagrammar::VariableLengthSequenceBody0
- Treetop::Compiler::Metagrammar::VariableLengthSequenceBody1
- Treetop::Compiler::Metagrammar::VariableLengthSequenceBody2
- Treetop::Compiler::MetagrammarParser
- Treetop::Compiler::Nonterminal
- Treetop::Compiler::NotPredicate
- Treetop::Compiler::OccurrenceRange
- Treetop::Compiler::OneOrMore
- Treetop::Compiler::Optional
- Treetop::Compiler::ParenthesizedExpression
- Treetop::Compiler::ParsingExpression
- Treetop::Compiler::ParsingRule
- Treetop::Compiler::Predicate
- Treetop::Compiler::PredicateBlock
- Treetop::Compiler::Repetition
- Treetop::Compiler::RubyBuilder
- Treetop::Compiler::Sequence
- Treetop::Compiler::SequenceElementAccessorModule
- Treetop::Compiler::Terminal
- Treetop::Compiler::TransientPrefix
- Treetop::Compiler::TreetopFile
- Treetop::Compiler::ZeroOrMore
- Treetop::Polyglot
- Treetop::Runtime
- Treetop::Runtime::CompiledParser
- Treetop::Runtime::SyntaxNode
- Treetop::Runtime::TerminalParseFailure
- Treetop::Runtime::TerminalSyntaxNode
- IntervalSkipList
- IntervalSkipList::HeadNode
- IntervalSkipList::Node
- Object
- String

No matching classes.

# Treetop::Compiler::ParsingExpression

### Attributes

address[R]
builder[R]
parent_expression[R]
subexpression_address[R]
var_symbols[R]

### Public Instance Methods

accumulate_subexpression_result() click to toggle source

    # File lib/treetop/compiler/node_classes/parsing_expression.rb, line 65
    def accumulate_subexpression_result
      builder.accumulate accumulator_var, subexpression_result_var
    end

accumulator_var() click to toggle source

    # File lib/treetop/compiler/node_classes/parsing_expression.rb, line 45
    def accumulator_var
      var(:accumulator)
    end

assign_failure(start_index_var) click to toggle source

    # File lib/treetop/compiler/node_classes/parsing_expression.rb, line 93
    def assign_failure(start_index_var)
      assign_result("nil")
    end

assign_lazily_instantiated_node() click to toggle source

    # File lib/treetop/compiler/node_classes/parsing_expression.rb, line 97
    def assign_lazily_instantiated_node
      assign_result("true")
    end

assign_result(value_ruby) click to toggle source

    # File lib/treetop/compiler/node_classes/parsing_expression.rb, line 69
    def assign_result(value_ruby)
      builder.assign result_var, value_ruby
    end

begin_comment(expression) click to toggle source

    # File lib/treetop/compiler/node_classes/parsing_expression.rb, line 133
    def begin_comment(expression)
      #builder << "# begin #{on_one_line(expression)}"
    end

compile(address, builder, parent_expression) click to toggle source

    # File lib/treetop/compiler/node_classes/parsing_expression.rb, line 6
    def compile(address, builder, parent_expression)
      @address = address
      @builder = builder
      @parent_expression = parent_expression
    end

declared_module_name() click to toggle source

    # File lib/treetop/compiler/node_classes/parsing_expression.rb, line 16
    def declared_module_name
      parent_expression && parent_expression.node_class_name
    end

decorated?() click to toggle source

    # File lib/treetop/compiler/node_classes/parsing_expression.rb, line 24
    def decorated?
      parent_expression && (parent_expression.node_class_name || parent_expression.node_class_name || parent_expression.inline_module_name)
    end

end_comment(expression) click to toggle source

    # File lib/treetop/compiler/node_classes/parsing_expression.rb, line 137
    def end_comment(expression)
      #builder << "# end #{on_one_line(expression)}"
    end

epsilon_node() click to toggle source

    # File lib/treetop/compiler/node_classes/parsing_expression.rb, line 89
    def epsilon_node
      "instantiate_node(SyntaxNode,input, index...index)"
    end

extend_result(module_name) click to toggle source

    # File lib/treetop/compiler/node_classes/parsing_expression.rb, line 73
    def extend_result(module_name)
      builder.extend result_var, module_name
    end

extend_result_with_declared_module() click to toggle source

    # File lib/treetop/compiler/node_classes/parsing_expression.rb, line 77
    def extend_result_with_declared_module
      extend_result declared_module_name if declared_module_name
    end

extend_result_with_inline_module() click to toggle source

    # File lib/treetop/compiler/node_classes/parsing_expression.rb, line 81
    def extend_result_with_inline_module
      extend_result inline_module_name if inline_module_name
    end

init_value(var_symbol) click to toggle source

    # File lib/treetop/compiler/node_classes/parsing_expression.rb, line 125
    def init_value(var_symbol)
      case var_symbol
      when :accumulator then '[]'
      when :start_index then 'index'
      else nil
      end
    end

inline_module_name() click to toggle source

    # File lib/treetop/compiler/node_classes/parsing_expression.rb, line 20
    def inline_module_name
      parent_expression && parent_expression.inline_module_name
    end

node_class_name() click to toggle source

    # File lib/treetop/compiler/node_classes/parsing_expression.rb, line 12
    def node_class_name
      parent_expression && parent_expression.node_class_name || 'SyntaxNode'
    end

obtain_new_subexpression_address() click to toggle source

    # File lib/treetop/compiler/node_classes/parsing_expression.rb, line 61
    def obtain_new_subexpression_address
      @subexpression_address = builder.next_address
    end

on_one_line(expression) click to toggle source

    # File lib/treetop/compiler/node_classes/parsing_expression.rb, line 141
    def on_one_line(expression)
      expression.text_value.tr("\n", ' ')
    end

optional_arg(arg) click to toggle source

    # File lib/treetop/compiler/node_classes/parsing_expression.rb, line 28
    def optional_arg(arg)
      if arg
        ", #{arg}"
      else
        ''
      end
    end

reset_index() click to toggle source

    # File lib/treetop/compiler/node_classes/parsing_expression.rb, line 85
    def reset_index
      builder.assign '@index', start_index_var
    end

result_var() click to toggle source

    # File lib/treetop/compiler/node_classes/parsing_expression.rb, line 41
    def result_var
      var(:result)
    end

start_index_var() click to toggle source

    # File lib/treetop/compiler/node_classes/parsing_expression.rb, line 49
    def start_index_var
      var(:start_index)
    end

subexpression_result_var() click to toggle source

    # File lib/treetop/compiler/node_classes/parsing_expression.rb, line 53
    def subexpression_result_var
      "r#{subexpression_address}"
    end

subexpression_success?() click to toggle source

    # File lib/treetop/compiler/node_classes/parsing_expression.rb, line 57
    def subexpression_success?
      subexpression_result_var
    end

use_vars(*var_symbols) click to toggle source

    # File lib/treetop/compiler/node_classes/parsing_expression.rb, line 36
    def use_vars(*var_symbols)
      @var_symbols = var_symbols
      builder << var_initialization
    end

var(var_symbol) click to toggle source

    # File lib/treetop/compiler/node_classes/parsing_expression.rb, line 116
    def var(var_symbol)
      case var_symbol
      when :result then "r#{address}"
      when :accumulator then "s#{address}"
      when :start_index then "i#{address}"
      else raise "Unknown var symbol #{var_symbol}."
      end
    end

var_initialization() click to toggle source

    # File lib/treetop/compiler/node_classes/parsing_expression.rb, line 101
    def var_initialization
      left, right = [], []
      var_symbols.each do |symbol|
        if init_value(symbol)
          left << var(symbol)
          right << init_value(symbol)
        end
      end
      if left.empty?
        ""
      else
        left.join(', ') + ' = ' + right.join(', ')
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.