Class: Loxxy::Ast::ASTBuilder

Inherits:
Rley::ParseRep::ASTBaseBuilder
  • Object
show all
Defined in:
lib/loxxy/ast/ast_builder.rb

Overview

The purpose of ASTBuilder is to build piece by piece an AST (Abstract Syntax Tree) from a sequence of input tokens and visit events produced by walking over a GFGParsing object.

Constant Summary collapse

Name2special =

Mapping Token name => operator | separator | delimiter characters

Returns:

  • (Hash{String => String})
{
  'AND' => 'and',
  'BANG_EQUAL' => '!=',
  'COMMA' =>  ',',
  'DOT' => '.',
  'EQUAL' => '=',
  'EQUAL_EQUAL' => '==',
  'GREATER' => '>',
  'GREATER_EQUAL' => '>=',
  'LEFT_BRACE' =>  '{',
  'LEFT_PAREN' => '(',
  'LESS' => '<',
  'LESS_EQUAL' => '<=',
  'MINUS' => '-',
  'OR' => 'or',
  'PLUS' => '+',
  'RIGHT_BRACE' => '}',
  'RIGHT_PAREN' => ')',
  'SEMICOLON' => ';',
  'SLASH' =>  '/',
  'STAR' => '*'
}.freeze
Name2unary =
{
  'BANG' => '!',
  'MINUS' => '-@'
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(theTokens) ⇒ ASTBuilder

Create a new AST builder instance.

Parameters:

  • theTokens (Array<Rley::Lexical::Token>)

    The sequence of input tokens.



49
50
51
52
# File 'lib/loxxy/ast/ast_builder.rb', line 49

def initialize(theTokens)
  super(theTokens)
  @strict = false
end

Instance Attribute Details

#strictObject (readonly)

defined



45
46
47
# File 'lib/loxxy/ast/ast_builder.rb', line 45

def strict
  @strict
end