001/*
002 * Copyright 2006 - 2013
003 *     Stefan Balev     <stefan.balev@graphstream-project.org>
004 *     Julien Baudry    <julien.baudry@graphstream-project.org>
005 *     Antoine Dutot    <antoine.dutot@graphstream-project.org>
006 *     Yoann Pigné      <yoann.pigne@graphstream-project.org>
007 *     Guilhelm Savin   <guilhelm.savin@graphstream-project.org>
008 * 
009 * This file is part of GraphStream <http://graphstream-project.org>.
010 * 
011 * GraphStream is a library whose purpose is to handle static or dynamic
012 * graph, create them from scratch, file or any source and display them.
013 * 
014 * This program is free software distributed under the terms of two licenses, the
015 * CeCILL-C license that fits European law, and the GNU Lesser General Public
016 * License. You can  use, modify and/ or redistribute the software under the terms
017 * of the CeCILL-C license as circulated by CEA, CNRS and INRIA at the following
018 * URL <http://www.cecill.info> or under the terms of the GNU LGPL as published by
019 * the Free Software Foundation, either version 3 of the License, or (at your
020 * option) any later version.
021 * 
022 * This program is distributed in the hope that it will be useful, but WITHOUT ANY
023 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
024 * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
025 * 
026 * You should have received a copy of the GNU Lesser General Public License
027 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
028 * 
029 * The fact that you are presently reading this means that you have had
030 * knowledge of the CeCILL-C and LGPL licenses and that you accept their terms.
031 */
032package org.graphstream.stream.file.tlp;
033
034import org.graphstream.util.parser.SimpleCharStream;
035import org.graphstream.util.parser.Token;
036import org.graphstream.util.parser.TokenMgrError;
037
038/** Token Manager. */
039public class TLPParserTokenManager implements TLPParserConstants {
040
041        /** Debug output. */
042        public java.io.PrintStream debugStream = System.out;
043
044        /** Set debug output. */
045        public void setDebugStream(java.io.PrintStream ds) {
046                debugStream = ds;
047        }
048
049        private final int jjStopStringLiteralDfa_0(int pos, long active0) {
050                switch (pos) {
051                case 0:
052                        if ((active0 & 0x900000L) != 0L)
053                                return 35;
054                        if ((active0 & 0x240000L) != 0L)
055                                return 29;
056                        return -1;
057                case 1:
058                        if ((active0 & 0x200000L) != 0L)
059                                return 28;
060                        return -1;
061                default:
062                        return -1;
063                }
064        }
065
066        private final int jjStartNfa_0(int pos, long active0) {
067                return jjMoveNfa_0(jjStopStringLiteralDfa_0(pos, active0), pos + 1);
068        }
069
070        private int jjStopAtPos(int pos, int kind) {
071                jjmatchedKind = kind;
072                jjmatchedPos = pos;
073                return pos + 1;
074        }
075
076        private int jjMoveStringLiteralDfa0_0() {
077                switch (curChar) {
078                case 40:
079                        return jjStopAtPos(0, 10);
080                case 41:
081                        return jjStopAtPos(0, 11);
082                case 65:
083                case 97:
084                        return jjMoveStringLiteralDfa1_0(0x80000L);
085                case 67:
086                case 99:
087                        return jjMoveStringLiteralDfa1_0(0x240000L);
088                case 68:
089                case 100:
090                        return jjMoveStringLiteralDfa1_0(0x900000L);
091                case 69:
092                case 101:
093                        return jjMoveStringLiteralDfa1_0(0x30000L);
094                case 71:
095                case 103:
096                        return jjMoveStringLiteralDfa1_0(0x2000L);
097                case 78:
098                case 110:
099                        return jjMoveStringLiteralDfa1_0(0xc000L);
100                case 80:
101                case 112:
102                        return jjMoveStringLiteralDfa1_0(0x400000L);
103                case 84:
104                case 116:
105                        return jjMoveStringLiteralDfa1_0(0x1000L);
106                default:
107                        return jjMoveNfa_0(6, 0);
108                }
109        }
110
111        private int jjMoveStringLiteralDfa1_0(long active0) {
112                try {
113                        curChar = input_stream.readChar();
114                } catch (java.io.IOException e) {
115                        jjStopStringLiteralDfa_0(0, active0);
116                        return 1;
117                }
118                switch (curChar) {
119                case 65:
120                case 97:
121                        return jjMoveStringLiteralDfa2_0(active0, 0x100000L);
122                case 68:
123                case 100:
124                        return jjMoveStringLiteralDfa2_0(active0, 0x30000L);
125                case 69:
126                case 101:
127                        return jjMoveStringLiteralDfa2_0(active0, 0x800000L);
128                case 76:
129                case 108:
130                        return jjMoveStringLiteralDfa2_0(active0, 0x41000L);
131                case 79:
132                case 111:
133                        return jjMoveStringLiteralDfa2_0(active0, 0x20c000L);
134                case 82:
135                case 114:
136                        return jjMoveStringLiteralDfa2_0(active0, 0x402000L);
137                case 85:
138                case 117:
139                        return jjMoveStringLiteralDfa2_0(active0, 0x80000L);
140                default:
141                        break;
142                }
143                return jjStartNfa_0(0, active0);
144        }
145
146        private int jjMoveStringLiteralDfa2_0(long old0, long active0) {
147                if (((active0 &= old0)) == 0L)
148                        return jjStartNfa_0(0, old0);
149                try {
150                        curChar = input_stream.readChar();
151                } catch (java.io.IOException e) {
152                        jjStopStringLiteralDfa_0(1, active0);
153                        return 2;
154                }
155                switch (curChar) {
156                case 65:
157                case 97:
158                        return jjMoveStringLiteralDfa3_0(active0, 0x2000L);
159                case 68:
160                case 100:
161                        return jjMoveStringLiteralDfa3_0(active0, 0xc000L);
162                case 70:
163                case 102:
164                        return jjMoveStringLiteralDfa3_0(active0, 0x800000L);
165                case 71:
166                case 103:
167                        return jjMoveStringLiteralDfa3_0(active0, 0x30000L);
168                case 77:
169                case 109:
170                        return jjMoveStringLiteralDfa3_0(active0, 0x200000L);
171                case 79:
172                case 111:
173                        return jjMoveStringLiteralDfa3_0(active0, 0x400000L);
174                case 80:
175                case 112:
176                        if ((active0 & 0x1000L) != 0L)
177                                return jjStopAtPos(2, 12);
178                        break;
179                case 84:
180                case 116:
181                        return jjMoveStringLiteralDfa3_0(active0, 0x180000L);
182                case 85:
183                case 117:
184                        return jjMoveStringLiteralDfa3_0(active0, 0x40000L);
185                default:
186                        break;
187                }
188                return jjStartNfa_0(1, active0);
189        }
190
191        private int jjMoveStringLiteralDfa3_0(long old0, long active0) {
192                if (((active0 &= old0)) == 0L)
193                        return jjStartNfa_0(1, old0);
194                try {
195                        curChar = input_stream.readChar();
196                } catch (java.io.IOException e) {
197                        jjStopStringLiteralDfa_0(2, active0);
198                        return 3;
199                }
200                switch (curChar) {
201                case 65:
202                case 97:
203                        return jjMoveStringLiteralDfa4_0(active0, 0x800000L);
204                case 69:
205                case 101:
206                        if ((active0 & 0x4000L) != 0L) {
207                                jjmatchedKind = 14;
208                                jjmatchedPos = 3;
209                        } else if ((active0 & 0x10000L) != 0L) {
210                                jjmatchedKind = 16;
211                                jjmatchedPos = 3;
212                        } else if ((active0 & 0x100000L) != 0L)
213                                return jjStopAtPos(3, 20);
214                        return jjMoveStringLiteralDfa4_0(active0, 0x28000L);
215                case 72:
216                case 104:
217                        return jjMoveStringLiteralDfa4_0(active0, 0x80000L);
218                case 77:
219                case 109:
220                        return jjMoveStringLiteralDfa4_0(active0, 0x200000L);
221                case 80:
222                case 112:
223                        return jjMoveStringLiteralDfa4_0(active0, 0x402000L);
224                case 83:
225                case 115:
226                        return jjMoveStringLiteralDfa4_0(active0, 0x40000L);
227                default:
228                        break;
229                }
230                return jjStartNfa_0(2, active0);
231        }
232
233        private int jjMoveStringLiteralDfa4_0(long old0, long active0) {
234                if (((active0 &= old0)) == 0L)
235                        return jjStartNfa_0(2, old0);
236                try {
237                        curChar = input_stream.readChar();
238                } catch (java.io.IOException e) {
239                        jjStopStringLiteralDfa_0(3, active0);
240                        return 4;
241                }
242                switch (curChar) {
243                case 69:
244                case 101:
245                        return jjMoveStringLiteralDfa5_0(active0, 0x600000L);
246                case 72:
247                case 104:
248                        if ((active0 & 0x2000L) != 0L)
249                                return jjStopAtPos(4, 13);
250                        break;
251                case 79:
252                case 111:
253                        return jjMoveStringLiteralDfa5_0(active0, 0x80000L);
254                case 83:
255                case 115:
256                        if ((active0 & 0x8000L) != 0L)
257                                return jjStopAtPos(4, 15);
258                        else if ((active0 & 0x20000L) != 0L)
259                                return jjStopAtPos(4, 17);
260                        break;
261                case 84:
262                case 116:
263                        return jjMoveStringLiteralDfa5_0(active0, 0x40000L);
264                case 85:
265                case 117:
266                        return jjMoveStringLiteralDfa5_0(active0, 0x800000L);
267                default:
268                        break;
269                }
270                return jjStartNfa_0(3, active0);
271        }
272
273        private int jjMoveStringLiteralDfa5_0(long old0, long active0) {
274                if (((active0 &= old0)) == 0L)
275                        return jjStartNfa_0(3, old0);
276                try {
277                        curChar = input_stream.readChar();
278                } catch (java.io.IOException e) {
279                        jjStopStringLiteralDfa_0(4, active0);
280                        return 5;
281                }
282                switch (curChar) {
283                case 69:
284                case 101:
285                        return jjMoveStringLiteralDfa6_0(active0, 0x40000L);
286                case 76:
287                case 108:
288                        return jjMoveStringLiteralDfa6_0(active0, 0x800000L);
289                case 78:
290                case 110:
291                        return jjMoveStringLiteralDfa6_0(active0, 0x200000L);
292                case 82:
293                case 114:
294                        if ((active0 & 0x80000L) != 0L)
295                                return jjStopAtPos(5, 19);
296                        return jjMoveStringLiteralDfa6_0(active0, 0x400000L);
297                default:
298                        break;
299                }
300                return jjStartNfa_0(4, active0);
301        }
302
303        private int jjMoveStringLiteralDfa6_0(long old0, long active0) {
304                if (((active0 &= old0)) == 0L)
305                        return jjStartNfa_0(4, old0);
306                try {
307                        curChar = input_stream.readChar();
308                } catch (java.io.IOException e) {
309                        jjStopStringLiteralDfa_0(5, active0);
310                        return 6;
311                }
312                switch (curChar) {
313                case 82:
314                case 114:
315                        if ((active0 & 0x40000L) != 0L)
316                                return jjStopAtPos(6, 18);
317                        break;
318                case 84:
319                case 116:
320                        if ((active0 & 0x800000L) != 0L)
321                                return jjStopAtPos(6, 23);
322                        return jjMoveStringLiteralDfa7_0(active0, 0x600000L);
323                default:
324                        break;
325                }
326                return jjStartNfa_0(5, active0);
327        }
328
329        private int jjMoveStringLiteralDfa7_0(long old0, long active0) {
330                if (((active0 &= old0)) == 0L)
331                        return jjStartNfa_0(5, old0);
332                try {
333                        curChar = input_stream.readChar();
334                } catch (java.io.IOException e) {
335                        jjStopStringLiteralDfa_0(6, active0);
336                        return 7;
337                }
338                switch (curChar) {
339                case 83:
340                case 115:
341                        if ((active0 & 0x200000L) != 0L)
342                                return jjStopAtPos(7, 21);
343                        break;
344                case 89:
345                case 121:
346                        if ((active0 & 0x400000L) != 0L)
347                                return jjStopAtPos(7, 22);
348                        break;
349                default:
350                        break;
351                }
352                return jjStartNfa_0(6, active0);
353        }
354
355        static final long[] jjbitVec0 = { 0x0L, 0x0L, 0xffffffffffffffffL,
356                        0xffffffffffffffffL };
357
358        private int jjMoveNfa_0(int startState, int curPos) {
359                int startsAt = 0;
360                jjnewStateCnt = 55;
361                int i = 1;
362                jjstateSet[0] = startState;
363                int kind = 0x7fffffff;
364                for (;;) {
365                        if (++jjround == 0x7fffffff)
366                                ReInitRounds();
367                        if (curChar < 64) {
368                                long l = 1L << curChar;
369                                do {
370                                        switch (jjstateSet[--i]) {
371                                        case 6:
372                                                if ((0x3ff000000000000L & l) != 0L) {
373                                                        if (kind > 24)
374                                                                kind = 24;
375                                                        jjCheckNAddStates(0, 2);
376                                                } else if ((0x280000000000L & l) != 0L)
377                                                        jjCheckNAdd(11);
378                                                else if (curChar == 39)
379                                                        jjCheckNAddTwoStates(20, 21);
380                                                else if (curChar == 34)
381                                                        jjCheckNAddStates(3, 5);
382                                                else if (curChar == 59)
383                                                        jjCheckNAddTwoStates(8, 9);
384                                                else if (curChar == 47)
385                                                        jjstateSet[jjnewStateCnt++] = 0;
386                                                break;
387                                        case 0:
388                                                if (curChar == 42)
389                                                        jjCheckNAddStates(6, 8);
390                                                break;
391                                        case 1:
392                                                if ((0xfffffbffffffffffL & l) != 0L)
393                                                        jjCheckNAddStates(6, 8);
394                                                break;
395                                        case 2:
396                                                if (curChar == 42)
397                                                        jjstateSet[jjnewStateCnt++] = 3;
398                                                break;
399                                        case 3:
400                                                if ((0xffff7fffffffffffL & l) != 0L)
401                                                        jjCheckNAddStates(6, 8);
402                                                break;
403                                        case 4:
404                                                if (curChar == 47 && kind > 5)
405                                                        kind = 5;
406                                                break;
407                                        case 5:
408                                                if (curChar == 42)
409                                                        jjstateSet[jjnewStateCnt++] = 4;
410                                                break;
411                                        case 7:
412                                                if (curChar == 59)
413                                                        jjCheckNAddTwoStates(8, 9);
414                                                break;
415                                        case 8:
416                                                if ((0xffffffffffffdbffL & l) != 0L)
417                                                        jjCheckNAddTwoStates(8, 9);
418                                                break;
419                                        case 9:
420                                                if ((0x2400L & l) != 0L && kind > 6)
421                                                        kind = 6;
422                                                break;
423                                        case 10:
424                                                if ((0x280000000000L & l) != 0L)
425                                                        jjCheckNAdd(11);
426                                                break;
427                                        case 11:
428                                                if ((0x3ff000000000000L & l) == 0L)
429                                                        break;
430                                                if (kind > 25)
431                                                        kind = 25;
432                                                jjCheckNAddTwoStates(11, 12);
433                                                break;
434                                        case 12:
435                                                if (curChar == 46)
436                                                        jjCheckNAdd(13);
437                                                break;
438                                        case 13:
439                                                if ((0x3ff000000000000L & l) == 0L)
440                                                        break;
441                                                if (kind > 25)
442                                                        kind = 25;
443                                                jjCheckNAdd(13);
444                                                break;
445                                        case 14:
446                                        case 16:
447                                                if (curChar == 34)
448                                                        jjCheckNAddStates(3, 5);
449                                                break;
450                                        case 15:
451                                                if ((0xfffffffbffffffffL & l) != 0L)
452                                                        jjCheckNAddStates(3, 5);
453                                                break;
454                                        case 18:
455                                                if (curChar == 34 && kind > 26)
456                                                        kind = 26;
457                                                break;
458                                        case 19:
459                                                if (curChar == 39)
460                                                        jjCheckNAddTwoStates(20, 21);
461                                                break;
462                                        case 20:
463                                                if ((0xffffff7fffffffffL & l) != 0L)
464                                                        jjCheckNAddTwoStates(20, 21);
465                                                break;
466                                        case 21:
467                                                if (curChar == 39 && kind > 26)
468                                                        kind = 26;
469                                                break;
470                                        case 53:
471                                                if ((0x3ff000000000000L & l) == 0L)
472                                                        break;
473                                                if (kind > 24)
474                                                        kind = 24;
475                                                jjCheckNAddStates(0, 2);
476                                                break;
477                                        case 54:
478                                                if ((0x3ff000000000000L & l) == 0L)
479                                                        break;
480                                                if (kind > 24)
481                                                        kind = 24;
482                                                jjCheckNAdd(54);
483                                                break;
484                                        default:
485                                                break;
486                                        }
487                                } while (i != startsAt);
488                        } else if (curChar < 128) {
489                                long l = 1L << (curChar & 077);
490                                do {
491                                        switch (jjstateSet[--i]) {
492                                        case 6:
493                                                if ((0x8000000080000L & l) != 0L)
494                                                        jjAddStates(9, 10);
495                                                else if ((0x20000000200L & l) != 0L)
496                                                        jjstateSet[jjnewStateCnt++] = 43;
497                                                else if ((0x100000001000L & l) != 0L)
498                                                        jjstateSet[jjnewStateCnt++] = 41;
499                                                else if ((0x1000000010L & l) != 0L)
500                                                        jjstateSet[jjnewStateCnt++] = 35;
501                                                else if ((0x800000008L & l) != 0L)
502                                                        jjstateSet[jjnewStateCnt++] = 29;
503                                                else if ((0x400000004L & l) != 0L)
504                                                        jjstateSet[jjnewStateCnt++] = 24;
505                                                break;
506                                        case 1:
507                                        case 3:
508                                                jjCheckNAddStates(6, 8);
509                                                break;
510                                        case 8:
511                                                jjAddStates(11, 12);
512                                                break;
513                                        case 15:
514                                                jjAddStates(3, 5);
515                                                break;
516                                        case 17:
517                                                if (curChar == 92)
518                                                        jjstateSet[jjnewStateCnt++] = 16;
519                                                break;
520                                        case 20:
521                                                jjAddStates(13, 14);
522                                                break;
523                                        case 22:
524                                                if ((0x100000001000L & l) != 0L && kind > 27)
525                                                        kind = 27;
526                                                break;
527                                        case 23:
528                                                if ((0x800000008000L & l) != 0L)
529                                                        jjstateSet[jjnewStateCnt++] = 22;
530                                                break;
531                                        case 24:
532                                                if ((0x800000008000L & l) != 0L)
533                                                        jjstateSet[jjnewStateCnt++] = 23;
534                                                break;
535                                        case 25:
536                                                if ((0x400000004L & l) != 0L)
537                                                        jjstateSet[jjnewStateCnt++] = 24;
538                                                break;
539                                        case 26:
540                                                if ((0x4000000040000L & l) != 0L && kind > 27)
541                                                        kind = 27;
542                                                break;
543                                        case 27:
544                                                if ((0x800000008000L & l) != 0L)
545                                                        jjstateSet[jjnewStateCnt++] = 26;
546                                                break;
547                                        case 28:
548                                                if ((0x100000001000L & l) != 0L)
549                                                        jjstateSet[jjnewStateCnt++] = 27;
550                                                break;
551                                        case 29:
552                                                if ((0x800000008000L & l) != 0L)
553                                                        jjstateSet[jjnewStateCnt++] = 28;
554                                                break;
555                                        case 30:
556                                                if ((0x800000008L & l) != 0L)
557                                                        jjstateSet[jjnewStateCnt++] = 29;
558                                                break;
559                                        case 31:
560                                                if ((0x2000000020L & l) != 0L && kind > 27)
561                                                        kind = 27;
562                                                break;
563                                        case 32:
564                                                if ((0x100000001000L & l) != 0L)
565                                                        jjCheckNAdd(31);
566                                                break;
567                                        case 33:
568                                                if ((0x400000004L & l) != 0L)
569                                                        jjstateSet[jjnewStateCnt++] = 32;
570                                                break;
571                                        case 34:
572                                                if ((0x20000000200000L & l) != 0L)
573                                                        jjstateSet[jjnewStateCnt++] = 33;
574                                                break;
575                                        case 35:
576                                                if ((0x800000008000L & l) != 0L)
577                                                        jjstateSet[jjnewStateCnt++] = 34;
578                                                break;
579                                        case 36:
580                                                if ((0x1000000010L & l) != 0L)
581                                                        jjstateSet[jjnewStateCnt++] = 35;
582                                                break;
583                                        case 37:
584                                                if ((0x10000000100000L & l) != 0L && kind > 27)
585                                                        kind = 27;
586                                                break;
587                                        case 38:
588                                                if ((0x20000000200000L & l) != 0L)
589                                                        jjCheckNAdd(37);
590                                                break;
591                                        case 39:
592                                                if ((0x800000008000L & l) != 0L)
593                                                        jjstateSet[jjnewStateCnt++] = 38;
594                                                break;
595                                        case 40:
596                                                if ((0x200000002000000L & l) != 0L)
597                                                        jjstateSet[jjnewStateCnt++] = 39;
598                                                break;
599                                        case 41:
600                                                if ((0x200000002L & l) != 0L)
601                                                        jjstateSet[jjnewStateCnt++] = 40;
602                                                break;
603                                        case 42:
604                                                if ((0x100000001000L & l) != 0L)
605                                                        jjstateSet[jjnewStateCnt++] = 41;
606                                                break;
607                                        case 43:
608                                                if ((0x400000004000L & l) != 0L)
609                                                        jjCheckNAdd(37);
610                                                break;
611                                        case 44:
612                                                if ((0x20000000200L & l) != 0L)
613                                                        jjstateSet[jjnewStateCnt++] = 43;
614                                                break;
615                                        case 45:
616                                                if ((0x8000000080000L & l) != 0L)
617                                                        jjAddStates(9, 10);
618                                                break;
619                                        case 46:
620                                                if ((0x400000004000000L & l) != 0L)
621                                                        jjCheckNAdd(31);
622                                                break;
623                                        case 47:
624                                                if ((0x20000000200L & l) != 0L)
625                                                        jjstateSet[jjnewStateCnt++] = 46;
626                                                break;
627                                        case 48:
628                                                if ((0x8000000080L & l) != 0L && kind > 27)
629                                                        kind = 27;
630                                                break;
631                                        case 49:
632                                                if ((0x400000004000L & l) != 0L)
633                                                        jjstateSet[jjnewStateCnt++] = 48;
634                                                break;
635                                        case 50:
636                                                if ((0x20000000200L & l) != 0L)
637                                                        jjstateSet[jjnewStateCnt++] = 49;
638                                                break;
639                                        case 51:
640                                                if ((0x4000000040000L & l) != 0L)
641                                                        jjstateSet[jjnewStateCnt++] = 50;
642                                                break;
643                                        case 52:
644                                                if ((0x10000000100000L & l) != 0L)
645                                                        jjstateSet[jjnewStateCnt++] = 51;
646                                                break;
647                                        default:
648                                                break;
649                                        }
650                                } while (i != startsAt);
651                        } else {
652                                int i2 = (curChar & 0xff) >> 6;
653                                long l2 = 1L << (curChar & 077);
654                                do {
655                                        switch (jjstateSet[--i]) {
656                                        case 1:
657                                        case 3:
658                                                if ((jjbitVec0[i2] & l2) != 0L)
659                                                        jjCheckNAddStates(6, 8);
660                                                break;
661                                        case 8:
662                                                if ((jjbitVec0[i2] & l2) != 0L)
663                                                        jjAddStates(11, 12);
664                                                break;
665                                        case 15:
666                                                if ((jjbitVec0[i2] & l2) != 0L)
667                                                        jjAddStates(3, 5);
668                                                break;
669                                        case 20:
670                                                if ((jjbitVec0[i2] & l2) != 0L)
671                                                        jjAddStates(13, 14);
672                                                break;
673                                        default:
674                                                break;
675                                        }
676                                } while (i != startsAt);
677                        }
678                        if (kind != 0x7fffffff) {
679                                jjmatchedKind = kind;
680                                jjmatchedPos = curPos;
681                                kind = 0x7fffffff;
682                        }
683                        ++curPos;
684                        if ((i = jjnewStateCnt) == (startsAt = 55 - (jjnewStateCnt = startsAt)))
685                                return curPos;
686                        try {
687                                curChar = input_stream.readChar();
688                        } catch (java.io.IOException e) {
689                                return curPos;
690                        }
691                }
692        }
693
694        static final int[] jjnextStates = { 54, 11, 12, 15, 17, 18, 1, 2, 5, 47,
695                        52, 8, 9, 20, 21, };
696
697        /** Token literal values. */
698        public static final String[] jjstrLiteralImages = { "", null, null, null,
699                        null, null, null, null, null, null, "\50", "\51", null, null, null,
700                        null, null, null, null, null, null, null, null, null, null, null,
701                        null, null, };
702
703        /** Lexer state names. */
704        public static final String[] lexStateNames = { "DEFAULT", };
705        static final long[] jjtoToken = { 0xffffc01L, };
706        static final long[] jjtoSkip = { 0x7eL, };
707        protected SimpleCharStream input_stream;
708        private final int[] jjrounds = new int[55];
709        private final int[] jjstateSet = new int[110];
710        protected char curChar;
711
712        /** Constructor. */
713        public TLPParserTokenManager(SimpleCharStream stream) {
714                if (SimpleCharStream.staticFlag)
715                        throw new Error(
716                                        "ERROR: Cannot use a static CharStream class with a non-static lexical analyzer.");
717                input_stream = stream;
718        }
719
720        /** Constructor. */
721        public TLPParserTokenManager(SimpleCharStream stream, int lexState) {
722                this(stream);
723                SwitchTo(lexState);
724        }
725
726        /** Reinitialise parser. */
727        public void ReInit(SimpleCharStream stream) {
728                jjmatchedPos = jjnewStateCnt = 0;
729                curLexState = defaultLexState;
730                input_stream = stream;
731                ReInitRounds();
732        }
733
734        private void ReInitRounds() {
735                int i;
736                jjround = 0x80000001;
737                for (i = 55; i-- > 0;)
738                        jjrounds[i] = 0x80000000;
739        }
740
741        /** Reinitialise parser. */
742        public void ReInit(SimpleCharStream stream, int lexState) {
743                ReInit(stream);
744                SwitchTo(lexState);
745        }
746
747        /** Switch to specified lex state. */
748        public void SwitchTo(int lexState) {
749                if (lexState >= 1 || lexState < 0)
750                        throw new TokenMgrError("Error: Ignoring invalid lexical state : "
751                                        + lexState + ". State unchanged.",
752                                        TokenMgrError.INVALID_LEXICAL_STATE);
753                else
754                        curLexState = lexState;
755        }
756
757        protected Token jjFillToken() {
758                final Token t;
759                final String curTokenImage;
760                final int beginLine;
761                final int endLine;
762                final int beginColumn;
763                final int endColumn;
764                String im = jjstrLiteralImages[jjmatchedKind];
765                curTokenImage = (im == null) ? input_stream.GetImage() : im;
766                beginLine = input_stream.getBeginLine();
767                beginColumn = input_stream.getBeginColumn();
768                endLine = input_stream.getEndLine();
769                endColumn = input_stream.getEndColumn();
770                t = Token.newToken(jjmatchedKind, curTokenImage);
771
772                t.beginLine = beginLine;
773                t.endLine = endLine;
774                t.beginColumn = beginColumn;
775                t.endColumn = endColumn;
776
777                return t;
778        }
779
780        int curLexState = 0;
781        int defaultLexState = 0;
782        int jjnewStateCnt;
783        int jjround;
784        int jjmatchedPos;
785        int jjmatchedKind;
786
787        /** Get the next Token. */
788        public Token getNextToken() {
789                Token matchedToken;
790                int curPos = 0;
791
792                EOFLoop: for (;;) {
793                        try {
794                                curChar = input_stream.BeginToken();
795                        } catch (java.io.IOException e) {
796                                jjmatchedKind = 0;
797                                matchedToken = jjFillToken();
798                                return matchedToken;
799                        }
800
801                        try {
802                                input_stream.backup(0);
803                                while (curChar <= 32 && (0x100002600L & (1L << curChar)) != 0L)
804                                        curChar = input_stream.BeginToken();
805                        } catch (java.io.IOException e1) {
806                                continue EOFLoop;
807                        }
808                        jjmatchedKind = 0x7fffffff;
809                        jjmatchedPos = 0;
810                        curPos = jjMoveStringLiteralDfa0_0();
811                        if (jjmatchedKind != 0x7fffffff) {
812                                if (jjmatchedPos + 1 < curPos)
813                                        input_stream.backup(curPos - jjmatchedPos - 1);
814                                if ((jjtoToken[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L) {
815                                        matchedToken = jjFillToken();
816                                        return matchedToken;
817                                } else {
818                                        continue EOFLoop;
819                                }
820                        }
821                        int error_line = input_stream.getEndLine();
822                        int error_column = input_stream.getEndColumn();
823                        String error_after = null;
824                        boolean EOFSeen = false;
825                        try {
826                                input_stream.readChar();
827                                input_stream.backup(1);
828                        } catch (java.io.IOException e1) {
829                                EOFSeen = true;
830                                error_after = curPos <= 1 ? "" : input_stream.GetImage();
831                                if (curChar == '\n' || curChar == '\r') {
832                                        error_line++;
833                                        error_column = 0;
834                                } else
835                                        error_column++;
836                        }
837                        if (!EOFSeen) {
838                                input_stream.backup(1);
839                                error_after = curPos <= 1 ? "" : input_stream.GetImage();
840                        }
841                        throw new TokenMgrError(EOFSeen, curLexState, error_line,
842                                        error_column, error_after, curChar,
843                                        TokenMgrError.LEXICAL_ERROR);
844                }
845        }
846
847        private void jjCheckNAdd(int state) {
848                if (jjrounds[state] != jjround) {
849                        jjstateSet[jjnewStateCnt++] = state;
850                        jjrounds[state] = jjround;
851                }
852        }
853
854        private void jjAddStates(int start, int end) {
855                do {
856                        jjstateSet[jjnewStateCnt++] = jjnextStates[start];
857                } while (start++ != end);
858        }
859
860        private void jjCheckNAddTwoStates(int state1, int state2) {
861                jjCheckNAdd(state1);
862                jjCheckNAdd(state2);
863        }
864
865        private void jjCheckNAddStates(int start, int end) {
866                do {
867                        jjCheckNAdd(jjnextStates[start]);
868                } while (start++ != end);
869        }
870
871}