module ANTLR3::TokenFactory
There are a variety of different entities throughout the ANTLR runtime library that need to create token objects This module serves as a mixin that provides methods for constructing tokens.
Including this module provides a token_class
attribute. Instance of the including class can create tokens using the token class (which defaults to ANTLR3::CommonToken
). Token
classes are presumed to have an initialize method that can be called without any parameters and the token objects are expected to have the standard token attributes (see ANTLR3::Token
).
Attributes
token_class[W]
Public Instance Methods
create_token( *args ) { |*targs| ... }
click to toggle source
# File lib/antlr3/token.rb, line 361 def create_token( *args ) if block_given? token_class.new( *args ) do |*targs| yield( *targs ) end else token_class.new( *args ) end end
token_class()
click to toggle source
# File lib/antlr3/token.rb, line 353 def token_class @token_class ||= begin self.class.token_class rescue self::Token rescue ANTLR3::CommonToken end end