Sha256: 6e9e284ea5addfb36765d892198c8bdb5e239c7af26c0df8582425a9cf06bd82
Contents?: true
Size: 934 Bytes
Versions: 3
Compression:
Stored size: 934 Bytes
Contents
require 'antlr4/runtime' require 'expressir/express_exp/generated/ExpressVisitor' require 'expressir/express_exp/generated/ExpressLexer' require 'expressir/express_exp/generated/ExpressParser' require 'expressir/express_exp/visitor' module Expressir module ExpressExp class Parser def self.from_exp(file) input = File.read(file) char_stream = Antlr4::Runtime::CharStreams.from_string(input, 'String') lexer = Generated::ExpressLexer.new(char_stream) token_stream = Antlr4::Runtime::CommonTokenStream.new(lexer) parser = Generated::ExpressParser.new(token_stream) # don't attempt to recover from any parsing error parser.instance_variable_set(:@_err_handler, Antlr4::Runtime::BailErrorStrategy.new) parse_tree = parser.syntax() visitor = Visitor.new(token_stream) repo = visitor.visit(parse_tree) repo end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
expressir-0.2.3 | lib/expressir/express_exp/parser.rb |
expressir-0.2.2 | lib/expressir/express_exp/parser.rb |
expressir-0.2.1 | lib/expressir/express_exp/parser.rb |