Sha256: 7c06738ed30fb0eb53539c095ddc9ad996cbe6d7223c4a7ffd13d57c707be7e1

Contents?: true

Size: 890 Bytes

Versions: 1

Compression:

Stored size: 890 Bytes

Contents

# finished
# 已完成

module Antlr4ruby
  class CommonTokenFactory

    DEFAULT = CommonTokenFactory.new

    def initialize(copy_text = false)
      @copy_text = copy_text
    end

    protected

    attr_reader :copy_text

    public

    def create(type:, text:, source: nil,
               channel: nil, start: nil, stop: nil, line: nil, position: nil)
      if channel and source and start and stop and line and position
        t = CommonToken.new(type: type, source: source, channel: channel, start: start, stop: stop)
        t.set_line(line)
        t.set_char_position_in_line(position)
        if text
          t.set_text(text)
        elsif copy_text && source.second
          t.set_text(source.second.get_text(start..stop))
        end
        t
      else
        CommonToken.new(type: type, text: text)
      end
    end



  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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