Class: RuleTagToken

Inherits:
Token show all
Defined in:
lib/antlr4/tree/RuleTagToken.rb

Constant Summary

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

Attributes inherited from Token

#channel, #column, #line, #source, #start, #stop, #text, #tokenIndex, #type

Instance Method Summary collapse

Methods inherited from Token

#getInputStream, #getTokenSource

Constructor Details

#initialize(ruleName, bypassTokenType, label = nil) ⇒ RuleTagToken

Returns a new instance of RuleTagToken.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/antlr4/tree/RuleTagToken.rb', line 16

def initialize(ruleName, bypassTokenType, label=nil)
    if ruleName.nil? or ruleName.length ==0 then
        raise Exception.new("ruleName cannot be null or empty.")
    end
    self.source = nil
    self.type = bypassTokenType # token type of the token
    self.channel = Token::DEFAULT_CHANNEL # The parser ignores everything not on DEFAULT_CHANNEL
    self.start = -1 # optional; return -1 if not implemented.
    self.stop = -1  # optional; return -1 if not implemented.
    self.tokenIndex = -1 # from 0..n-1 of the token object in the input stream
    self.line = 0 # line=1..n of the 1st character
    self.column = -1 # beginning of the line at which it occurs, 0..n-1
    self.label = label
    self.ruleName = ruleName
    @text = getText()
end

Instance Attribute Details

#labelObject

Constructs a new instance of RuleTagToken with the specified rule name, bypass token type, and label.

the rule tag is unlabeled.

or empty.

Parameters:

  • ruleName

    The name of the parser rule this rule tag matches.

  • bypassTokenType

    The bypass token type assigned to the parser rule.

  • label

    The label associated with the rule tag, or null if



14
15
16
# File 'lib/antlr4/tree/RuleTagToken.rb', line 14

def label
  @label
end

#ruleNameObject

Constructs a new instance of RuleTagToken with the specified rule name, bypass token type, and label.

the rule tag is unlabeled.

or empty.

Parameters:

  • ruleName

    The name of the parser rule this rule tag matches.

  • bypassTokenType

    The bypass token type assigned to the parser rule.

  • label

    The label associated with the rule tag, or null if



14
15
16
# File 'lib/antlr4/tree/RuleTagToken.rb', line 14

def ruleName
  @ruleName
end

Instance Method Details

#getTextObject



32
33
34
35
36
37
38
# File 'lib/antlr4/tree/RuleTagToken.rb', line 32

def getText()
    if self.label.nil? then
        "<#{@ruleName}>"
    else
        "<#{@label}:#{@ruleName}>"
    end
end