Sha256: 0e77c2da9b48d9363cc697ed1e067c048f321702c06fa97cd419518d21830185

Contents?: true

Size: 781 Bytes

Versions: 1

Compression:

Stored size: 781 Bytes

Contents

require_relative 'code_point_char_stream'
module Antlr4ruby
  class CharStreams
    class << self
      def from_path(path, charset)
        # from_file(path, charset)
      end

      def from_file_name(filename, charset)
        mode = charset ? "rb:#{charset}" : 'r'
        File.open(filename, mode) do |file|
          from_file(file)
        end
      end

      def from_file(file)
        input = file.read
        if input
          from_string(input)
        else
          raise "文件读取异常"
        end
      end

      def from_string(input, source_name = IntStream.UNKNOWN_SOURCE_NAME)
        # 首先将字符串转换为整数数组
        CodePointCharStream.from_string(input, source_name)
      end



    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
antlr4ruby-0.1.0 lib/antlr4ruby/char_streams.rb