Sha256: a69579e24ca038d4f65a2c6e5c7a4b8ca7b440d15b9a5a4190061cafb950fa25

Contents?: true

Size: 1.31 KB

Versions: 35

Compression:

Stored size: 1.31 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_file(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

      def self.from_files(files)
        schemas = files.map{|file| self.from_file(file).schemas}.flatten

        Model::Repository.new({
          schemas: schemas
        })
      end

      # deprecated
      def self.from_exp(file)
        self.from_file(file)
      end
    end
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
expressir-0.2.13 lib/expressir/express_exp/parser.rb
expressir-0.2.13-x86_64-linux lib/expressir/express_exp/parser.rb
expressir-0.2.13-x86_64-darwin lib/expressir/express_exp/parser.rb
expressir-0.2.13-x86-mingw32 lib/expressir/express_exp/parser.rb
expressir-0.2.13-x86-linux lib/expressir/express_exp/parser.rb
expressir-0.2.13-x64-mingw32 lib/expressir/express_exp/parser.rb
expressir-0.2.13-arm64-darwin lib/expressir/express_exp/parser.rb
expressir-0.2.12 lib/expressir/express_exp/parser.rb
expressir-0.2.12-x86_64-linux lib/expressir/express_exp/parser.rb
expressir-0.2.12-x86_64-darwin lib/expressir/express_exp/parser.rb
expressir-0.2.12-x86-mingw32 lib/expressir/express_exp/parser.rb
expressir-0.2.12-x86-linux lib/expressir/express_exp/parser.rb
expressir-0.2.12-x64-mingw32 lib/expressir/express_exp/parser.rb
expressir-0.2.12-arm64-darwin lib/expressir/express_exp/parser.rb
expressir-0.2.11 lib/expressir/express_exp/parser.rb
expressir-0.2.11-x86_64-linux lib/expressir/express_exp/parser.rb
expressir-0.2.11-x86_64-darwin lib/expressir/express_exp/parser.rb
expressir-0.2.11-x86-mingw32 lib/expressir/express_exp/parser.rb
expressir-0.2.11-x86-linux lib/expressir/express_exp/parser.rb
expressir-0.2.11-x64-mingw32 lib/expressir/express_exp/parser.rb