xref: /aosp_15_r20/external/antlr/runtime/Ruby/lib/antlr3/constants.rb (revision 16467b971bd3e2009fad32dd79016f2c7e421deb)
1*16467b97STreehugger Robot#!/usr/bin/ruby
2*16467b97STreehugger Robot# encoding: utf-8
3*16467b97STreehugger Robot
4*16467b97STreehugger Robot=begin LICENSE
5*16467b97STreehugger Robot
6*16467b97STreehugger Robot[The "BSD licence"]
7*16467b97STreehugger RobotCopyright (c) 2009-2010 Kyle Yetter
8*16467b97STreehugger RobotAll rights reserved.
9*16467b97STreehugger Robot
10*16467b97STreehugger RobotRedistribution and use in source and binary forms, with or without
11*16467b97STreehugger Robotmodification, are permitted provided that the following conditions
12*16467b97STreehugger Robotare met:
13*16467b97STreehugger Robot
14*16467b97STreehugger Robot 1. Redistributions of source code must retain the above copyright
15*16467b97STreehugger Robot    notice, this list of conditions and the following disclaimer.
16*16467b97STreehugger Robot 2. Redistributions in binary form must reproduce the above copyright
17*16467b97STreehugger Robot    notice, this list of conditions and the following disclaimer in the
18*16467b97STreehugger Robot    documentation and/or other materials provided with the distribution.
19*16467b97STreehugger Robot 3. The name of the author may not be used to endorse or promote products
20*16467b97STreehugger Robot    derived from this software without specific prior written permission.
21*16467b97STreehugger Robot
22*16467b97STreehugger RobotTHIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23*16467b97STreehugger RobotIMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24*16467b97STreehugger RobotOF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25*16467b97STreehugger RobotIN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26*16467b97STreehugger RobotINCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27*16467b97STreehugger RobotNOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28*16467b97STreehugger RobotDATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29*16467b97STreehugger RobotTHEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30*16467b97STreehugger Robot(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31*16467b97STreehugger RobotTHIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32*16467b97STreehugger Robot
33*16467b97STreehugger Robot=end
34*16467b97STreehugger Robot
35*16467b97STreehugger Robotmodule ANTLR3
36*16467b97STreehugger Robot
37*16467b97STreehugger Robot
38*16467b97STreehugger Robot=begin rdoc ANTLR3::Constants
39*16467b97STreehugger Robot
40*16467b97STreehugger RobotA simple module to keep track of the various built-in token types, channels, and
41*16467b97STreehugger Robottoken names used by ANTLR throughout the runtime library.
42*16467b97STreehugger Robot
43*16467b97STreehugger Robot=end
44*16467b97STreehugger Robotmodule Constants
45*16467b97STreehugger Robot  # built-in token channel IDs
46*16467b97STreehugger Robot
47*16467b97STreehugger Robot  # the channel to which most tokens will be assigned
48*16467b97STreehugger Robot  DEFAULT = DEFAULT_CHANNEL = DEFAULT_TOKEN_CHANNEL = :default
49*16467b97STreehugger Robot
50*16467b97STreehugger Robot  # the channel for tokens which should not be passed to a parser by a token stream
51*16467b97STreehugger Robot  HIDDEN  = HIDDEN_CHANNEL  = :hidden
52*16467b97STreehugger Robot
53*16467b97STreehugger Robot  # flag used by recognizers during memoization to
54*16467b97STreehugger Robot  # represent a previous prediction failure
55*16467b97STreehugger Robot  MEMO_RULE_FAILED = -2
56*16467b97STreehugger Robot
57*16467b97STreehugger Robot  # flag used by recognizers during memoization to indicate
58*16467b97STreehugger Robot  # that the rule has not been memoized yet
59*16467b97STreehugger Robot  MEMO_RULE_UNKNOWN = -1
60*16467b97STreehugger Robot
61*16467b97STreehugger Robot  # built-in token types used internally by ANTLR3
62*16467b97STreehugger Robot
63*16467b97STreehugger Robot  INVALID_TOKEN_TYPE = 0
64*16467b97STreehugger Robot
65*16467b97STreehugger Robot  EOF = -1
66*16467b97STreehugger Robot
67*16467b97STreehugger Robot
68*16467b97STreehugger Robot  # Imaginary tree-navigation token type indicating the ascent after moving through the
69*16467b97STreehugger Robot  # children of a node
70*16467b97STreehugger Robot  UP = 3
71*16467b97STreehugger Robot
72*16467b97STreehugger Robot  # Imaginary tree-navigation token type indicating a descent into the children of a node
73*16467b97STreehugger Robot  DOWN = 2
74*16467b97STreehugger Robot
75*16467b97STreehugger Robot  # End of Rule (used internally by DFAs)
76*16467b97STreehugger Robot  EOR_TOKEN_TYPE = 1
77*16467b97STreehugger Robot
78*16467b97STreehugger Robot  # The smallest possible value of non-builtin ANTLR-generated token types
79*16467b97STreehugger Robot  MIN_TOKEN_TYPE = 4
80*16467b97STreehugger Robot
81*16467b97STreehugger Robot  # A hash mapping built in token types to their respective names
82*16467b97STreehugger Robot  # returning a string "<UNKNOWN: #{type}>" for non-builtin token
83*16467b97STreehugger Robot  # types
84*16467b97STreehugger Robot  BUILT_IN_TOKEN_NAMES = Hash.new do |h, k|
85*16467b97STreehugger Robot    "<UNKNOWN: #{ k }>"
86*16467b97STreehugger Robot  end
87*16467b97STreehugger Robot
88*16467b97STreehugger Robot  BUILT_IN_TOKEN_NAMES.update(
89*16467b97STreehugger Robot    0 => "<invalid>".freeze, 1 => "<EOR>".freeze,
90*16467b97STreehugger Robot    2 => "<DOWN>".freeze, 3 => "<UP>".freeze,
91*16467b97STreehugger Robot    -1 => "<EOF>".freeze
92*16467b97STreehugger Robot  )
93*16467b97STreehugger Robot
94*16467b97STreehugger Robot
95*16467b97STreehugger Robotend
96*16467b97STreehugger Robot
97*16467b97STreehugger Robotinclude Constants
98*16467b97STreehugger Robotend
99