Sha256: 3e9f510dbd50073713a323047a146cb82b2b54c56057e8f51499d0df8fbee2f1

Contents?: true

Size: 1.04 KB

Versions: 14

Compression:

Stored size: 1.04 KB

Contents

begin
  RUBY_VERSION =~ /(\d+\.\d+)/
  require_relative "#{$1}/express_parser"
rescue LoadError
  require_relative "express_parser"
end
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

14 entries across 14 versions & 1 rubygems

Version Path
expressir-0.2.8 lib/expressir/express_exp/parser.rb
expressir-0.2.8-x86_64-linux lib/expressir/express_exp/parser.rb
expressir-0.2.8-x86_64-darwin lib/expressir/express_exp/parser.rb
expressir-0.2.8-x86-mingw32 lib/expressir/express_exp/parser.rb
expressir-0.2.8-x86-linux lib/expressir/express_exp/parser.rb
expressir-0.2.8-x64-mingw32 lib/expressir/express_exp/parser.rb
expressir-0.2.8-arm64-darwin lib/expressir/express_exp/parser.rb
expressir-0.2.7 lib/expressir/express_exp/parser.rb
expressir-0.2.7-x86-mingw32 lib/expressir/express_exp/parser.rb
expressir-0.2.7-x64-mingw32 lib/expressir/express_exp/parser.rb
expressir-0.2.7-x86_64-linux lib/expressir/express_exp/parser.rb
expressir-0.2.7-x86-linux lib/expressir/express_exp/parser.rb
expressir-0.2.7-x86_64-darwin lib/expressir/express_exp/parser.rb
expressir-0.2.7-arm64-darwin lib/expressir/express_exp/parser.rb