Class: TokenTagToken
- Inherits:
-
CommonToken
- Object
- Token
- CommonToken
- TokenTagToken
- Defined in:
- lib/antlr4/tree/TokenTagToken.rb
Overview
A Token object representing a token of a particular type; e.g., <ID>. These tokens are created for TagChunk chunks where the tag corresponds to a lexer rule or token type.
Constant Summary
Constants inherited from CommonToken
Constants inherited from Token
Token::DEFAULT_CHANNEL, Token::EOF, Token::EPSILON, Token::HIDDEN_CHANNEL, Token::INVALID_TYPE, Token::MIN_USER_TOKEN_TYPE
Instance Attribute Summary collapse
-
#label ⇒ Object
Constructs a new instance of TokenTagToken with the specified token name, type, and label.
-
#tokenName ⇒ Object
Constructs a new instance of TokenTagToken with the specified token name, type, and label.
Attributes inherited from Token
#channel, #column, #line, #source, #start, #stop, #text, #tokenIndex, #type
Instance Method Summary collapse
-
#getText ⇒ Object
<p>The implementation for TokenTagToken returns the token tag formatted with < and > delimiters.</p>.
-
#initialize(tokenName, type, label = nil) ⇒ TokenTagToken
constructor
A new instance of TokenTagToken.
-
#to_s ⇒ Object
<p>The implementation for TokenTagToken returns a string of the form tokenName:type.</p>.
Methods inherited from CommonToken
Methods inherited from Token
#getInputStream, #getTokenSource
Constructor Details
#initialize(tokenName, type, label = nil) ⇒ TokenTagToken
Returns a new instance of TokenTagToken.
17 18 19 20 21 22 |
# File 'lib/antlr4/tree/TokenTagToken.rb', line 17 def initialize(tokenName, type, label=nil) super(type) self.tokenName = tokenName self.label = label @text = getText() end |
Instance Attribute Details
#label ⇒ Object
Constructs a new instance of TokenTagToken with the specified token name, type, and label.
the token tag is unlabeled.
16 17 18 |
# File 'lib/antlr4/tree/TokenTagToken.rb', line 16 def label @label end |
#tokenName ⇒ Object
Constructs a new instance of TokenTagToken with the specified token name, type, and label.
the token tag is unlabeled.
16 17 18 |
# File 'lib/antlr4/tree/TokenTagToken.rb', line 16 def tokenName @tokenName end |
Instance Method Details
#getText ⇒ Object
<p>The implementation for TokenTagToken returns the token tag formatted with < and > delimiters.</p>
25 26 27 28 29 30 31 |
# File 'lib/antlr4/tree/TokenTagToken.rb', line 25 def getText() if self.label.nil? return "<" + self.tokenName + ">" else return "<" + self.label + ":" + self.tokenName + ">" end end |
#to_s ⇒ Object
<p>The implementation for TokenTagToken returns a string of the form tokenName:type.</p>
35 36 37 |
# File 'lib/antlr4/tree/TokenTagToken.rb', line 35 def to_s "#{self.tokenName}:#{self.class}" end |