Sha256: c5f9341e9d353c1779446aed46576a8892576ae3e0354117c9f30acaa14d6074

Contents?: true

Size: 956 Bytes

Versions: 4

Compression:

Stored size: 956 Bytes

Contents

require 'express_parser'
require 'expressir/express_exp/visitor'

module Expressir
  module ExpressExp
    class Parser
      def self.from_exp(file)
        input = File.read(file)

=begin
        char_stream = Antlr4::Runtime::CharStreams.from_string(input, 'String')
        lexer = ::ExpressParser::Lexer.new(char_stream)
        token_stream = Antlr4::Runtime::CommonTokenStream.new(lexer)
        parser = ::ExpressParser::Parser.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)
=end

        parser = ::ExpressParser::Parser.parse(input)

        parse_tree = parser.syntax()

        visitor = Visitor.new(parser.tokens)
        repo = visitor.visit(parse_tree)

        repo
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
expressir-0.2.5-x86_64-linux lib/expressir/express_exp/parser.rb
expressir-0.2.5-x86_64-darwin-19 lib/expressir/express_exp/parser.rb
expressir-0.2.5 lib/expressir/express_exp/parser.rb
expressir-0.2.4 lib/expressir/express_exp/parser.rb