KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > javacc > parser > RStringLiteral


1 /*
2  * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
3  * California 95054, U.S.A. All rights reserved. Sun Microsystems, Inc. has
4  * intellectual property rights relating to technology embodied in the product
5  * that is described in this document. In particular, and without limitation,
6  * these intellectual property rights may include one or more of the U.S.
7  * patents listed at http://www.sun.com/patents and one or more additional
8  * patents or pending patent applications in the U.S. and in other countries.
9  * U.S. Government Rights - Commercial software. Government users are subject
10  * to the Sun Microsystems, Inc. standard license agreement and applicable
11  * provisions of the FAR and its supplements. Use is subject to license terms.
12  * Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered
13  * trademarks of Sun Microsystems, Inc. in the U.S. and other countries. This
14  * product is covered and controlled by U.S. Export Control laws and may be
15  * subject to the export or import laws in other countries. Nuclear, missile,
16  * chemical biological weapons or nuclear maritime end uses or end users,
17  * whether direct or indirect, are strictly prohibited. Export or reexport
18  * to countries subject to U.S. embargo or to entities identified on U.S.
19  * export exclusion lists, including, but not limited to, the denied persons
20  * and specially designated nationals lists is strictly prohibited.
21  */

22
23 package org.javacc.parser;
24
25 import java.util.*;
26
27 final class KindInfo
28 {
29    long[] validKinds;
30    long[] finalKinds;
31    int validKindCnt = 0;
32    int finalKindCnt = 0;
33
34    KindInfo(int maxKind)
35    {
36       validKinds = new long[maxKind / 64 + 1];
37       finalKinds = new long[maxKind / 64 + 1];
38    }
39
40    public void InsertValidKind(int kind)
41    {
42       validKinds[kind / 64] |= (1L << (kind % 64));
43       validKindCnt++;
44    }
45
46    public void InsertFinalKind(int kind)
47    {
48       finalKinds[kind / 64] |= (1L << (kind % 64));
49       finalKindCnt++;
50    }
51 };
52
53 /**
54  * Describes string literals.
55  */

56
57 public class RStringLiteral extends RegularExpression {
58
59   /**
60    * The string image of the literal.
61    */

62   public String JavaDoc image;
63
64   static int maxStrKind = 0;
65   static int maxLen = 0;
66   static int charCnt = 0;
67   static Vector charPosKind = new Vector(); // Elements are hashtables
68
// with single char keys;
69
static int[] maxLenForActive = new int[100]; // 6400 tokens
70
public static String JavaDoc[] allImages;
71   static int[][] intermediateKinds;
72   static int[][] intermediateMatchedPos;
73
74   static int startStateCnt = 0;
75   static boolean subString[];
76   static boolean subStringAtPos[];
77   static Hashtable[] statesForPos;
78
79   // Need to call this method after gnerating code for each lexical state. It
80
// initializes all the static variables, so that there is no interference
81
// between the various states of the lexer.
82
public static void ReInit()
83   {
84      maxStrKind = 0;
85      maxLen = 0;
86      charPosKind = new Vector();
87      maxLenForActive = new int[100]; // 6400 tokens
88
intermediateKinds = null;
89      intermediateMatchedPos = null;
90      startStateCnt = 0;
91      subString = null;
92      subStringAtPos = null;
93      statesForPos = null;
94   }
95
96   public static void DumpStrLiteralImages(java.io.PrintWriter JavaDoc ostr)
97   {
98      String JavaDoc image;
99      int charCnt = 0, i;
100
101      ostr.println("public static final String[] jjstrLiteralImages = {");
102
103      if (allImages == null || allImages.length == 0)
104      {
105         ostr.println("};");
106         return;
107      }
108
109      allImages[0] = "";
110      for (i = 0; i < allImages.length; i++)
111      {
112         if ((image = allImages[i]) == null ||
113             ((LexGen.toSkip[i / 64] & (1L << (i % 64))) == 0L &&
114              (LexGen.toMore[i / 64] & (1L << (i % 64))) == 0L &&
115              (LexGen.toToken[i / 64] & (1L << (i % 64))) == 0L) ||
116             (LexGen.toSkip[i / 64] & (1L << (i % 64))) != 0L ||
117             (LexGen.toMore[i / 64] & (1L << (i % 64))) != 0L ||
118             LexGen.canReachOnMore[LexGen.lexStates[i]] ||
119             ((Options.getIgnoreCase() || LexGen.ignoreCase[i]) &&
120              (!image.equals(image.toLowerCase()) ||
121               !image.equals(image.toUpperCase()))))
122         {
123            allImages[i] = null;
124            if ((charCnt += 6) > 80)
125            {
126               ostr.println("");
127               charCnt = 0;
128            }
129
130            ostr.print("null, ");
131            continue;
132         }
133
134         String JavaDoc toPrint = "\"";
135
136         for (int j = 0; j < image.length(); j++)
137         {
138            if (image.charAt(j) <= 0xff)
139               toPrint += ("\\" + Integer.toOctalString((int)image.charAt(j)));
140            else
141            {
142               String JavaDoc hexVal = Integer.toHexString((int)image.charAt(j));
143
144               if (hexVal.length() == 3)
145                  hexVal = "0" + hexVal;
146               toPrint += ("\\u" + hexVal);
147            }
148         }
149
150         toPrint += ( "\", ");
151
152         if ((charCnt += toPrint.length()) >= 80)
153         {
154            ostr.println("");
155            charCnt = 0;
156         }
157
158         ostr.print(toPrint);
159      }
160
161      while (++i < LexGen.maxOrdinal)
162      {
163         if ((charCnt += 6) > 80)
164         {
165            ostr.println("");
166            charCnt = 0;
167         }
168
169         ostr.print("null, ");
170         continue;
171      }
172
173      ostr.println("};");
174   }
175
176   // Used for top level string literals
177
public void GenerateDfa(java.io.PrintWriter JavaDoc ostr, int kind)
178   {
179      String JavaDoc s;
180      Hashtable temp;
181      KindInfo info;
182      int len;
183
184      if (maxStrKind <= ordinal)
185         maxStrKind = ordinal + 1;
186
187      if ((len = image.length()) > maxLen)
188         maxLen = len;
189
190      char c;
191      for (int i = 0; i < len; i++)
192      {
193         if (Options.getIgnoreCase())
194            s = ("" + (c = image.charAt(i))).toLowerCase();
195         else
196            s = "" + (c = image.charAt(i));
197
198         if (!NfaState.unicodeWarningGiven && c > 0xff &&
199             !Options.getJavaUnicodeEscape() &&
200             !Options.getUserCharStream())
201         {
202            NfaState.unicodeWarningGiven = true;
203            JavaCCErrors.warning(LexGen.curRE, "Non-ASCII characters used in regular expression." +
204               "Please make sure you use the correct Reader when you create the parser that can handle your character set.");
205         }
206
207         if (i >= charPosKind.size()) // Kludge, but OK
208
charPosKind.addElement(temp = new Hashtable());
209         else
210            temp = (Hashtable)charPosKind.elementAt(i);
211
212         if ((info = (KindInfo)temp.get(s)) == null)
213            temp.put(s, info = new KindInfo(LexGen.maxOrdinal));
214
215         if (i + 1 == len)
216            info.InsertFinalKind(ordinal);
217         else
218            info.InsertValidKind(ordinal);
219
220         if (!Options.getIgnoreCase() && LexGen.ignoreCase[ordinal] &&
221             c != Character.toLowerCase(c))
222         {
223            s = ("" + image.charAt(i)).toLowerCase();
224
225            if (i >= charPosKind.size()) // Kludge, but OK
226
charPosKind.addElement(temp = new Hashtable());
227            else
228               temp = (Hashtable)charPosKind.elementAt(i);
229
230            if ((info = (KindInfo)temp.get(s)) == null)
231               temp.put(s, info = new KindInfo(LexGen.maxOrdinal));
232
233            if (i + 1 == len)
234               info.InsertFinalKind(ordinal);
235            else
236               info.InsertValidKind(ordinal);
237         }
238
239         if (!Options.getIgnoreCase() && LexGen.ignoreCase[ordinal] &&
240             c != Character.toUpperCase(c))
241         {
242            s = ("" + image.charAt(i)).toUpperCase();
243
244            if (i >= charPosKind.size()) // Kludge, but OK
245
charPosKind.addElement(temp = new Hashtable());
246            else
247               temp = (Hashtable)charPosKind.elementAt(i);
248
249            if ((info = (KindInfo)temp.get(s)) == null)
250               temp.put(s, info = new KindInfo(LexGen.maxOrdinal));
251
252            if (i + 1 == len)
253               info.InsertFinalKind(ordinal);
254            else
255               info.InsertValidKind(ordinal);
256         }
257      }
258
259      maxLenForActive[ordinal / 64] = Math.max(maxLenForActive[ordinal / 64],
260                                                                         len -1);
261      allImages[ordinal] = image;
262   }
263
264   public Nfa GenerateNfa(boolean ignoreCase)
265   {
266      if (image.length() == 1)
267      {
268         RCharacterList temp = new RCharacterList(image.charAt(0));
269         return temp.GenerateNfa(ignoreCase);
270      }
271
272      NfaState startState = new NfaState();
273      NfaState theStartState = startState;
274      NfaState finalState = null;
275
276      if (image.length() == 0)
277         return new Nfa(theStartState, theStartState);
278
279      int i;
280
281      for (i = 0; i < image.length(); i++)
282      {
283         finalState = new NfaState();
284         startState.charMoves = new char[1];
285         startState.AddChar(image.charAt(i));
286
287         if (Options.getIgnoreCase() || ignoreCase)
288         {
289            startState.AddChar(Character.toLowerCase(image.charAt(i)));
290            startState.AddChar(Character.toUpperCase(image.charAt(i)));
291         }
292
293         startState.next = finalState;
294         startState = finalState;
295      }
296
297      return new Nfa(theStartState, finalState);
298   }
299
300   static void DumpNullStrLiterals(java.io.PrintWriter JavaDoc ostr)
301   {
302      ostr.println("{");
303
304      if (NfaState.generatedStates != 0)
305         ostr.println(" return jjMoveNfa" + LexGen.lexStateSuffix + "(" + NfaState.InitStateName() + ", 0);");
306      else
307         ostr.println(" return 1;");
308
309      ostr.println("}");
310   }
311
312   private static int GetStateSetForKind(int pos, int kind)
313   {
314      if (LexGen.mixed[LexGen.lexStateIndex] || NfaState.generatedStates == 0)
315         return -1;
316
317      Hashtable allStateSets = statesForPos[pos];
318
319      if (allStateSets == null)
320         return -1;
321
322      Enumeration e = allStateSets.keys();
323
324      while (e.hasMoreElements())
325      {
326         String JavaDoc s = (String JavaDoc)e.nextElement();
327         long[] actives = (long[])allStateSets.get(s);
328
329         s = s.substring(s.indexOf(", ") + 2);
330         s = s.substring(s.indexOf(", ") + 2);
331
332         if (s.equals("null;"))
333            continue;
334
335         if (actives != null &&
336             (actives[kind / 64] & (1L << (kind % 64))) != 0L)
337         {
338            return NfaState.AddStartStateSet(s);
339         }
340      }
341
342      return -1;
343   }
344
345   static String JavaDoc GetLabel(int kind)
346   {
347      RegularExpression re = LexGen.rexprs[kind];
348
349      if (re instanceof RStringLiteral)
350        return " \"" + JavaCCGlobals.add_escapes(((RStringLiteral)re).image) + "\"";
351      else if (!re.label.equals(""))
352        return " <" + re.label + ">";
353      else
354        return " <token of kind " + kind + ">";
355   }
356
357   static int GetLine(int kind)
358   {
359      return LexGen.rexprs[kind].line;
360   }
361
362   static int GetColumn(int kind)
363   {
364      return LexGen.rexprs[kind].column;
365   }
366
367   /**
368    * Returns true if s1 starts with s2 (ignoring case for each character).
369    */

370   static private boolean StartsWithIgnoreCase(String JavaDoc s1, String JavaDoc s2)
371   {
372      if (s1.length() < s2.length())
373         return false;
374
375      for (int i = 0; i < s2.length(); i++)
376      {
377         char c1 = s1.charAt(i), c2 = s2.charAt(i);
378
379         if (c1 != c2 && Character.toLowerCase(c2) != c1 &&
380             Character.toUpperCase(c2) != c1)
381            return false;
382      }
383
384      return true;
385   }
386
387   static void FillSubString()
388   {
389      String JavaDoc image;
390      subString = new boolean[maxStrKind + 1];
391      subStringAtPos = new boolean[maxLen];
392
393      for (int i = 0; i < maxStrKind; i++)
394      {
395         subString[i] = false;
396
397         if ((image = allImages[i]) == null ||
398             LexGen.lexStates[i] != LexGen.lexStateIndex)
399            continue;
400
401         if (LexGen.mixed[LexGen.lexStateIndex])
402         {
403            // We will not optimize for mixed case
404
subString[i] = true;
405            subStringAtPos[image.length() - 1] = true;
406            continue;
407         }
408
409         for (int j = 0; j < maxStrKind; j++)
410         {
411            if (j != i && LexGen.lexStates[j] == LexGen.lexStateIndex &&
412                ((String JavaDoc)allImages[j]) != null)
413            {
414               if (((String JavaDoc)allImages[j]).indexOf(image) == 0)
415               {
416                  subString[i] = true;
417                  subStringAtPos[image.length() - 1] = true;
418                  break;
419               }
420               else if (Options.getIgnoreCase() &&
421                        StartsWithIgnoreCase((String JavaDoc)allImages[j], image))
422               {
423                  subString[i] = true;
424                  subStringAtPos[image.length() - 1] = true;
425                  break;
426               }
427            }
428         }
429      }
430   }
431
432   static void DumpStartWithStates(java.io.PrintWriter JavaDoc ostr)
433   {
434      ostr.println((Options.getStatic() ? "static " : "") + "private final int " +
435                   "jjStartNfaWithStates" + LexGen.lexStateSuffix + "(int pos, int kind, int state)");
436      ostr.println("{");
437      ostr.println(" jjmatchedKind = kind;");
438      ostr.println(" jjmatchedPos = pos;");
439
440      if (Options.getDebugTokenManager())
441      {
442         ostr.println(" debugStream.println(\" No more string literal token matches are possible.\");");
443         ostr.println(" debugStream.println(\" Currently matched the first \" + (jjmatchedPos + 1) + \" characters as a \" + tokenImage[jjmatchedKind] + \" token.\");");
444      }
445
446      ostr.println(" try { curChar = input_stream.readChar(); }");
447      ostr.println(" catch(java.io.IOException e) { return pos + 1; }");
448
449      if (Options.getDebugTokenManager())
450         ostr.println(" debugStream.println(" + (LexGen.maxLexStates > 1 ? "\"<\" + lexStateNames[curLexState] + \">\" + " : "") + "\"Current character : \" + " +
451                  "TokenMgrError.addEscapes(String.valueOf(curChar)) + \" (\" + (int)curChar + \") at line \" + input_stream.getLine() + \" column \" + input_stream.getColumn());");
452
453      ostr.println(" return jjMoveNfa" + LexGen.lexStateSuffix + "(state, pos + 1);");
454      ostr.println("}");
455   }
456
457   private static boolean boilerPlateDumped = false;
458   static void DumpBoilerPlate(java.io.PrintWriter JavaDoc ostr)
459   {
460      ostr.println((Options.getStatic() ? "static " : "") + "private final int " +
461                   "jjStopAtPos(int pos, int kind)");
462      ostr.println("{");
463      ostr.println(" jjmatchedKind = kind;");
464      ostr.println(" jjmatchedPos = pos;");
465
466      if (Options.getDebugTokenManager())
467      {
468         ostr.println(" debugStream.println(\" No more string literal token matches are possible.\");");
469         ostr.println(" debugStream.println(\" Currently matched the first \" + (jjmatchedPos + 1) + \" characters as a \" + tokenImage[jjmatchedKind] + \" token.\");");
470      }
471
472      ostr.println(" return pos + 1;");
473      ostr.println("}");
474   }
475
476   static String JavaDoc[] ReArrange(Hashtable tab)
477   {
478      String JavaDoc[] ret = new String JavaDoc[tab.size()];
479      Enumeration e = tab.keys();
480      int cnt = 0;
481
482      while (e.hasMoreElements())
483      {
484         int i = 0, j;
485         String JavaDoc s;
486         char c = (s = (String JavaDoc)e.nextElement()).charAt(0);
487
488         while (i < cnt && ret[i].charAt(0) < c) i++;
489
490         if (i < cnt)
491            for (j = cnt - 1; j >= i; j--)
492              ret[j + 1] = ret[j];
493
494         ret[i] = s;
495         cnt++;
496      }
497
498      return ret;
499   }
500
501   static void DumpDfaCode(java.io.PrintWriter JavaDoc ostr)
502   {
503      Hashtable tab;
504      String JavaDoc key;
505      KindInfo info;
506      int maxLongsReqd = maxStrKind / 64 + 1;
507      int i, j, k;
508      boolean ifGenerated;
509      LexGen.maxLongsReqd[LexGen.lexStateIndex] = maxLongsReqd;
510
511      if (maxLen == 0)
512      {
513         ostr.println((Options.getStatic() ? "static " : "") + "private final int " +
514                        "jjMoveStringLiteralDfa0" + LexGen.lexStateSuffix + "()");
515
516         DumpNullStrLiterals(ostr);
517         return;
518      }
519
520      if (!boilerPlateDumped)
521      {
522         DumpBoilerPlate(ostr);
523         boilerPlateDumped = true;
524      }
525
526      if (!LexGen.mixed[LexGen.lexStateIndex] && NfaState.generatedStates != 0)
527         DumpStartWithStates(ostr);
528
529      boolean startNfaNeeded;
530      for (i = 0; i < maxLen; i++)
531      {
532         boolean atLeastOne = false;
533         startNfaNeeded = false;
534         tab = (Hashtable)charPosKind.elementAt(i);
535         String JavaDoc[] keys = ReArrange(tab);
536
537         ostr.print((Options.getStatic() ? "static " : "") + "private final int " +
538                        "jjMoveStringLiteralDfa" + i + LexGen.lexStateSuffix + "(");
539
540         if (i != 0)
541         {
542            if (i == 1)
543            {
544               for (j = 0; j < maxLongsReqd - 1; j++)
545                  if (i <= maxLenForActive[j])
546                  {
547                     if (atLeastOne)
548                        ostr.print(", ");
549                     else
550                        atLeastOne = true;
551                     ostr.print("long active" + j);
552                  }
553
554               if (i <= maxLenForActive[j])
555               {
556                  if (atLeastOne)
557                     ostr.print(", ");
558                  ostr.print("long active" + j);
559               }
560            }
561            else
562            {
563               for (j = 0; j < maxLongsReqd - 1; j++)
564                  if (i <= maxLenForActive[j] + 1)
565                  {
566                     if (atLeastOne)
567                        ostr.print(", ");
568                     else
569                        atLeastOne = true;
570                     ostr.print("long old" + j + ", long active" + j);
571                  }
572
573               if (i <= maxLenForActive[j] + 1)
574               {
575                  if (atLeastOne)
576                     ostr.print(", ");
577                  ostr.print("long old" + j + ", long active" + j);
578               }
579            }
580         }
581         ostr.println(")");
582         ostr.println("{");
583
584         if (i != 0)
585         {
586            if (i > 1)
587            {
588               atLeastOne = false;
589               ostr.print(" if ((");
590
591               for (j = 0; j < maxLongsReqd - 1; j++)
592                  if (i <= maxLenForActive[j] + 1)
593                  {
594                     if (atLeastOne)
595                        ostr.print(" | ");
596                     else
597                        atLeastOne = true;
598                     ostr.print("(active" + j + " &= old" + j + ")");
599                  }
600
601               if (i <= maxLenForActive[j] + 1)
602               {
603                  if (atLeastOne)
604                     ostr.print(" | ");
605                  ostr.print("(active" + j + " &= old" + j + ")");
606               }
607
608               ostr.println(") == 0L)");
609               if (!LexGen.mixed[LexGen.lexStateIndex] && NfaState.generatedStates != 0)
610               {
611                  ostr.print(" return jjStartNfa" + LexGen.lexStateSuffix +
612                                  "(" + (i - 2) + ", ");
613                  for (j = 0; j < maxLongsReqd - 1; j++)
614                     if (i <= maxLenForActive[j] + 1)
615                        ostr.print("old" + j + ", ");
616                     else
617                        ostr.print("0L, ");
618                  if (i <= maxLenForActive[j] + 1)
619                     ostr.println("old" + j + "); ");
620                  else
621                     ostr.println("0L);");
622               }
623               else if (NfaState.generatedStates != 0)
624                  ostr.println(" return jjMoveNfa" + LexGen.lexStateSuffix + "(" + NfaState.InitStateName() + ", " + (i - 1) + ");");
625               else
626                  ostr.println(" return " + i + ";");
627            }
628
629            if (i != 0 && Options.getDebugTokenManager())
630            {
631               ostr.println(" if (jjmatchedKind != 0 && jjmatchedKind != 0x" + Integer.toHexString(Integer.MAX_VALUE) + ")");
632               ostr.println(" debugStream.println(\" Currently matched the first \" + (jjmatchedPos + 1) + \" characters as a \" + tokenImage[jjmatchedKind] + \" token.\");");
633
634               ostr.println(" debugStream.println(\" Possible string literal matches : { \"");
635
636               for (int vecs = 0; vecs < maxStrKind / 64 + 1; vecs++)
637               {
638                  if (i <= maxLenForActive[vecs])
639                  {
640                     ostr.println(" + ");
641                     ostr.print(" jjKindsForBitVector(" + vecs + ", ");
642                     ostr.print("active" + vecs + ") ");
643                  }
644               }
645
646               ostr.println(" + \" } \");");
647            }
648
649            ostr.println(" try { curChar = input_stream.readChar(); }");
650            ostr.println(" catch(java.io.IOException e) {");
651
652            if (!LexGen.mixed[LexGen.lexStateIndex] && NfaState.generatedStates != 0)
653            {
654               ostr.print(" jjStopStringLiteralDfa" + LexGen.lexStateSuffix + "(" + (i - 1) + ", ");
655               for (k = 0; k < maxLongsReqd - 1; k++)
656                  if (i <= maxLenForActive[k])
657                     ostr.print("active" + k + ", ");
658                  else
659                     ostr.print("0L, ");
660
661               if (i <= maxLenForActive[k])
662                  ostr.println("active" + k + ");");
663               else
664                  ostr.println("0L);");
665
666
667               if (i != 0 && Options.getDebugTokenManager())
668               {
669                  ostr.println(" if (jjmatchedKind != 0 && jjmatchedKind != 0x" + Integer.toHexString(Integer.MAX_VALUE) + ")");
670                  ostr.println(" debugStream.println(\" Currently matched the first \" + (jjmatchedPos + 1) + \" characters as a \" + tokenImage[jjmatchedKind] + \" token.\");");
671               }
672               ostr.println(" return " + i + ";");
673            }
674            else if (NfaState.generatedStates != 0)
675               ostr.println(" return jjMoveNfa" + LexGen.lexStateSuffix + "(" + NfaState.InitStateName() + ", " + (i - 1) + ");");
676            else
677               ostr.println(" return " + i + ";");
678
679            ostr.println(" }");
680         }
681
682         if (i != 0 && Options.getDebugTokenManager())
683            ostr.println(" debugStream.println(" + (LexGen.maxLexStates > 1 ? "\"<\" + lexStateNames[curLexState] + \">\" + " : "") + "\"Current character : \" + " +
684                  "TokenMgrError.addEscapes(String.valueOf(curChar)) + \" (\" + (int)curChar + \") at line \" + input_stream.getLine() + \" column \" + input_stream.getColumn());");
685
686         ostr.println(" switch(curChar)");
687         ostr.println(" {");
688
689         CaseLoop:
690         for (int q = 0; q < keys.length; q++)
691         {
692            key = keys[q];
693            info = (KindInfo)tab.get(key);
694            ifGenerated = false;
695            char c = key.charAt(0);
696
697            if (i == 0 && c < 128 && info.finalKindCnt != 0 &&
698                (NfaState.generatedStates == 0 || !NfaState.CanStartNfaUsingAscii(c)))
699            {
700               int kind;
701               Outer:
702               for (j = 0; j < maxLongsReqd; j++)
703                  if (info.finalKinds[j] != 0L)
704                     break;
705
706               for (k = 0; k < 64; k++)
707                  if ((info.finalKinds[j] & (1L << k)) != 0L &&
708                      !subString[kind = (j * 64 + k)])
709                  {
710                    if ((intermediateKinds != null &&
711                         intermediateKinds[(j * 64 + k)] != null &&
712                         intermediateKinds[(j * 64 + k)][i] < (j * 64 + k) &&
713                         intermediateMatchedPos != null &&
714                         intermediateMatchedPos[(j * 64 + k)][i] == i) ||
715                        (LexGen.canMatchAnyChar[LexGen.lexStateIndex] >= 0 &&
716                         LexGen.canMatchAnyChar[LexGen.lexStateIndex] < (j * 64 + k)))
717                       break;
718                     else if ((LexGen.toSkip[kind / 64] & (1L << (kind % 64))) != 0L &&
719                              (LexGen.toSpecial[kind / 64] & (1L << (kind % 64))) == 0L &&
720                              LexGen.actions[kind] == null &&
721                              LexGen.newLexState[kind] == null)
722                     {
723                        LexGen.AddCharToSkip(c, kind);
724
725                        if (Options.getIgnoreCase())
726                        {
727                           if (c != Character.toUpperCase(c))
728                              LexGen.AddCharToSkip(Character.toUpperCase(c), kind);
729
730                           if (c != Character.toLowerCase(c))
731                              LexGen.AddCharToSkip(Character.toLowerCase(c), kind);
732                        }
733                        continue CaseLoop;
734                     }
735                  }
736            }
737
738            // Since we know key is a single character ...
739
if (Options.getIgnoreCase())
740            {
741               if (c != Character.toUpperCase(c))
742                  ostr.println(" case " + (int)Character.toUpperCase(c) + ":");
743
744               if (c != Character.toLowerCase(c))
745                  ostr.println(" case " + (int)Character.toLowerCase(c) + ":");
746            }
747
748            ostr.println(" case " + (int)c + ":");
749
750            long matchedKind;
751            String JavaDoc prefix = (i == 0) ? " " : " ";
752
753            if (info.finalKindCnt != 0)
754            {
755               for (j = 0; j < maxLongsReqd; j++)
756               {
757                  if ((matchedKind = info.finalKinds[j]) == 0L)
758                     continue;
759
760                  for (k = 0; k < 64; k++)
761                  {
762                     if ((matchedKind & (1L << k)) == 0L)
763                        continue;
764
765                     if (ifGenerated)
766                     {
767                        ostr.print(" else if ");
768                     }
769                     else if (i != 0)
770                        ostr.print(" if ");
771
772                     ifGenerated = true;
773
774                     int kindToPrint;
775                     if (i != 0)
776                     {
777                        ostr.println("((active" + j +
778                           " & 0x" + Long.toHexString(1L << k) + "L) != 0L)");
779                     }
780
781                     if (intermediateKinds != null &&
782                         intermediateKinds[(j * 64 + k)] != null &&
783                         intermediateKinds[(j * 64 + k)][i] < (j * 64 + k) &&
784                         intermediateMatchedPos != null &&
785                         intermediateMatchedPos[(j * 64 + k)][i] == i)
786                     {
787                        JavaCCErrors.warning(" \"" +
788                            JavaCCGlobals.add_escapes(allImages[j * 64 + k]) +
789                            "\" cannot be matched as a string literal token " +
790                            "at line " + GetLine(j * 64 + k) + ", column " + GetColumn(j * 64 + k) +
791                            ". It will be matched as " +
792                            GetLabel(intermediateKinds[(j * 64 + k)][i]) + ".");
793                        kindToPrint = intermediateKinds[(j * 64 + k)][i];
794                     }
795                     else if (i == 0 &&
796                          LexGen.canMatchAnyChar[LexGen.lexStateIndex] >= 0 &&
797                          LexGen.canMatchAnyChar[LexGen.lexStateIndex] < (j * 64 + k))
798                     {
799                        JavaCCErrors.warning(" \"" +
800                            JavaCCGlobals.add_escapes(allImages[j * 64 + k]) +
801                            "\" cannot be matched as a string literal token " +
802                            "at line " + GetLine(j * 64 + k) + ", column " + GetColumn(j * 64 + k) +
803                            ". It will be matched as " +
804                            GetLabel(LexGen.canMatchAnyChar[LexGen.lexStateIndex]) + ".");
805                        kindToPrint = LexGen.canMatchAnyChar[LexGen.lexStateIndex];
806                     }
807                     else
808                        kindToPrint = j * 64 + k;
809
810                     if (!subString[(j * 64 + k)])
811          &n