Sha256: 9c04ab0b6a839626661d5d6e6ba6db52d883186a3e661613c5a801daa866068c

Contents?: true

Size: 548 Bytes

Versions: 8

Compression:

Stored size: 548 Bytes

Contents

# Purpose: to demonstrate how to build and render a parse tree for JSON
# language
require_relative 'calc_lexer'
require_relative 'calc_grammar'

# A parser for arithmetic expressions
class CalcParser < Rley::Parser::GFGEarleyParser
  attr_reader(:source_file)

  # Constructor
  def initialize()
    # Builder the Earley parser with the calculator grammar
    super(CalcGrammar)
  end

  def parse_expression(aText)
    lexer = CalcLexer.new(aText, self.grammar)
    result = parse(lexer.tokens)

    return result
  end
end # class

# End of file

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
rley-0.4.06 examples/general/calc/calc_parser.rb
rley-0.4.05 examples/general/calc/calc_parser.rb
rley-0.4.04 examples/general/calc/calc_parser.rb
rley-0.4.03 examples/general/calc/calc_parser.rb
rley-0.4.02 examples/general/calc/calc_parser.rb
rley-0.4.01 examples/general/calc/calc_parser.rb
rley-0.4.00 examples/general/calc/calc_parser.rb
rley-0.3.12 examples/general/calc/calc_parser.rb