Project

General

Profile

DemoLexer.java

Paula Păstrăguș, 12/18/2025 09:32 AM

Download (6.72 KB)

 
1
// Generated from demo/DemoLexer.g4 by ANTLR 4.13.2
2
package demo;
3
import org.antlr.v4.runtime.Lexer;
4
import org.antlr.v4.runtime.CharStream;
5
import org.antlr.v4.runtime.Token;
6
import org.antlr.v4.runtime.TokenStream;
7
import org.antlr.v4.runtime.*;
8
import org.antlr.v4.runtime.atn.*;
9
import org.antlr.v4.runtime.dfa.DFA;
10
import org.antlr.v4.runtime.misc.*;
11

    
12
@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast", "CheckReturnValue", "this-escape"})
13
public class DemoLexer extends Lexer {
14
        static { RuntimeMetaData.checkVersion("4.13.2", RuntimeMetaData.VERSION); }
15

    
16
        protected static final DFA[] _decisionToDFA;
17
        protected static final PredictionContextCache _sharedContextCache =
18
                new PredictionContextCache();
19
        public static final int
20
                NUM=1, WS=2;
21
        public static String[] channelNames = {
22
                "DEFAULT_TOKEN_CHANNEL", "HIDDEN"
23
        };
24

    
25
        public static String[] modeNames = {
26
                "DEFAULT_MODE"
27
        };
28

    
29
        private static String[] makeRuleNames() {
30
                return new String[] {
31
                        "NUM", "DIGIT", "WS"
32
                };
33
        }
34
        public static final String[] ruleNames = makeRuleNames();
35

    
36
        private static String[] makeLiteralNames() {
37
                return new String[] {
38
                };
39
        }
40
        private static final String[] _LITERAL_NAMES = makeLiteralNames();
41
        private static String[] makeSymbolicNames() {
42
                return new String[] {
43
                        null, "NUM", "WS"
44
                };
45
        }
46
        private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames();
47
        public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES);
48

    
49
        /**
50
         * @deprecated Use {@link #VOCABULARY} instead.
51
         */
52
        @Deprecated
53
        public static final String[] tokenNames;
54
        static {
55
                tokenNames = new String[_SYMBOLIC_NAMES.length];
56
                for (int i = 0; i < tokenNames.length; i++) {
57
                        tokenNames[i] = VOCABULARY.getLiteralName(i);
58
                        if (tokenNames[i] == null) {
59
                                tokenNames[i] = VOCABULARY.getSymbolicName(i);
60
                        }
61

    
62
                        if (tokenNames[i] == null) {
63
                                tokenNames[i] = "<INVALID>";
64
                        }
65
                }
66
        }
67

    
68
        @Override
69
        @Deprecated
70
        public String[] getTokenNames() {
71
                return tokenNames;
72
        }
73

    
74
        @Override
75

    
76
        public Vocabulary getVocabulary() {
77
                return VOCABULARY;
78
        }
79

    
80

    
81
            int count = 0;
82

    
83

    
84
        public DemoLexer(CharStream input) {
85
                super(input);
86
                _interp = new LexerATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache);
87
        }
88

    
89
        @Override
90
        public String getGrammarFileName() { return "DemoLexer.g4"; }
91

    
92
        @Override
93
        public String[] getRuleNames() { return ruleNames; }
94

    
95
        @Override
96
        public String getSerializedATN() { return _serializedATN; }
97

    
98
        @Override
99
        public String[] getChannelNames() { return channelNames; }
100

    
101
        @Override
102
        public String[] getModeNames() { return modeNames; }
103

    
104
        @Override
105
        public ATN getATN() { return _ATN; }
106

    
107
        @Override
108
        public void action(RuleContext _localctx, int ruleIndex, int actionIndex) {
109
                switch (ruleIndex) {
110
                case 0:
111
                        NUM_action((RuleContext)_localctx, actionIndex);
112
                        break;
113
                }
114
        }
115
        private void NUM_action(RuleContext _localctx, int actionIndex) {
116
                switch (actionIndex) {
117
                case 0:
118
                         count++; System.out.println("inc count (int) = " + count); 
119
                        break;
120
                case 1:
121
                         count++; System.out.println("inc count (frac) = " + count); 
122
                        break;
123
                case 2:
124

    
125
                                    System.out.println("ALT1 chosen, final count = " + count);
126
                                
127
                        break;
128
                case 3:
129
                         count++; System.out.println("inc count (frac) = " + count); 
130
                        break;
131
                case 4:
132

    
133
                                    System.out.println("ALT2 chosen, final count = " + count);
134
                                
135
                        break;
136
                case 5:
137

    
138
                                System.out.println("END NUM, count = " + count);
139
                                count = 0;
140
                            
141
                        break;
142
                }
143
        }
144
        @Override
145
        public boolean sempred(RuleContext _localctx, int ruleIndex, int predIndex) {
146
                switch (ruleIndex) {
147
                case 0:
148
                        return NUM_sempred((RuleContext)_localctx, predIndex);
149
                }
150
                return true;
151
        }
152
        private boolean NUM_sempred(RuleContext _localctx, int predIndex) {
153
                switch (predIndex) {
154
                case 0:
155
                        return count < 2;
156
                }
157
                return true;
158
        }
159

    
160
        public static final String _serializedATN =
161
                "\u0004\u0000\u00020\u0006\uffff\uffff\u0002\u0000\u0007\u0000\u0002\u0001"+
162
                "\u0007\u0001\u0002\u0002\u0007\u0002\u0001\u0000\u0001\u0000\u0001\u0000"+
163
                "\u0004\u0000\u000b\b\u0000\u000b\u0000\f\u0000\f\u0001\u0000\u0001\u0000"+
164
                "\u0001\u0000\u0001\u0000\u0001\u0000\u0004\u0000\u0014\b\u0000\u000b\u0000"+
165
                "\f\u0000\u0015\u0001\u0000\u0001\u0000\u0001\u0000\u0001\u0000\u0001\u0000"+
166
                "\u0001\u0000\u0004\u0000\u001e\b\u0000\u000b\u0000\f\u0000\u001f\u0001"+
167
                "\u0000\u0001\u0000\u0003\u0000$\b\u0000\u0001\u0000\u0001\u0000\u0001"+
168
                "\u0001\u0001\u0001\u0001\u0002\u0004\u0002+\b\u0002\u000b\u0002\f\u0002"+
169
                ",\u0001\u0002\u0001\u0002\u0000\u0000\u0003\u0001\u0001\u0003\u0000\u0005"+
170
                "\u0002\u0001\u0000\u0002\u0001\u000009\u0003\u0000\t\n\r\r  3\u0000\u0001"+
171
                "\u0001\u0000\u0000\u0000\u0000\u0005\u0001\u0000\u0000\u0000\u0001\n\u0001"+
172
                "\u0000\u0000\u0000\u0003\'\u0001\u0000\u0000\u0000\u0005*\u0001\u0000"+
173
                "\u0000\u0000\u0007\b\u0003\u0003\u0001\u0000\b\t\u0006\u0000\u0000\u0000"+
174
                "\t\u000b\u0001\u0000\u0000\u0000\n\u0007\u0001\u0000\u0000\u0000\u000b"+
175
                "\f\u0001\u0000\u0000\u0000\f\n\u0001\u0000\u0000\u0000\f\r\u0001\u0000"+
176
                "\u0000\u0000\r#\u0001\u0000\u0000\u0000\u000e\u000f\u0004\u0000\u0000"+
177
                "\u0000\u000f\u0013\u0005.\u0000\u0000\u0010\u0011\u0003\u0003\u0001\u0000"+
178
                "\u0011\u0012\u0006\u0000\u0001\u0000\u0012\u0014\u0001\u0000\u0000\u0000"+
179
                "\u0013\u0010\u0001\u0000\u0000\u0000\u0014\u0015\u0001\u0000\u0000\u0000"+
180
                "\u0015\u0013\u0001\u0000\u0000\u0000\u0015\u0016\u0001\u0000\u0000\u0000"+
181
                "\u0016\u0017\u0001\u0000\u0000\u0000\u0017\u0018\u0006\u0000\u0002\u0000"+
182
                "\u0018$\u0001\u0000\u0000\u0000\u0019\u001d\u0005.\u0000\u0000\u001a\u001b"+
183
                "\u0003\u0003\u0001\u0000\u001b\u001c\u0006\u0000\u0003\u0000\u001c\u001e"+
184
                "\u0001\u0000\u0000\u0000\u001d\u001a\u0001\u0000\u0000\u0000\u001e\u001f"+
185
                "\u0001\u0000\u0000\u0000\u001f\u001d\u0001\u0000\u0000\u0000\u001f \u0001"+
186
                "\u0000\u0000\u0000 !\u0001\u0000\u0000\u0000!\"\u0006\u0000\u0004\u0000"+
187
                "\"$\u0001\u0000\u0000\u0000#\u000e\u0001\u0000\u0000\u0000#\u0019\u0001"+
188
                "\u0000\u0000\u0000$%\u0001\u0000\u0000\u0000%&\u0006\u0000\u0005\u0000"+
189
                "&\u0002\u0001\u0000\u0000\u0000\'(\u0007\u0000\u0000\u0000(\u0004\u0001"+
190
                "\u0000\u0000\u0000)+\u0007\u0001\u0000\u0000*)\u0001\u0000\u0000\u0000"+
191
                "+,\u0001\u0000\u0000\u0000,*\u0001\u0000\u0000\u0000,-\u0001\u0000\u0000"+
192
                "\u0000-.\u0001\u0000\u0000\u0000./\u0006\u0002\u0006\u0000/\u0006\u0001"+
193
                "\u0000\u0000\u0000\u0006\u0000\f\u0015\u001f#,\u0007\u0001\u0000\u0000"+
194
                "\u0001\u0000\u0001\u0001\u0000\u0002\u0001\u0000\u0003\u0001\u0000\u0004"+
195
                "\u0001\u0000\u0005\u0006\u0000\u0000";
196
        public static final ATN _ATN =
197
                new ATNDeserializer().deserialize(_serializedATN.toCharArray());
198
        static {
199
                _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()];
200
                for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) {
201
                        _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i);
202
                }
203
        }
204
}