szabivan

JFlex generated Java

Apr 21st, 2015
297
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 26.49 KB | None | 0 0
  1. /* The following code was generated by JFlex 1.6.0 */
  2.  
  3. package szabivan.cup;
  4. import java_cup.runtime.*;
  5.  
  6.  
  7. /**
  8.  * This class is a scanner generated by
  9.  * <a href="http://www.jflex.de/">JFlex</a> 1.6.0
  10.  * from the specification file <tt>FormulaLexer.jflex</tt>
  11.  */
  12. class FormulaLexer implements java_cup.runtime.Scanner {
  13.  
  14.   /** This character denotes the end of file */
  15.   public static final int YYEOF = -1;
  16.  
  17.   /** initial size of the lookahead buffer */
  18.   private static final int ZZ_BUFFERSIZE = 16384;
  19.  
  20.   /** lexical states */
  21.   public static final int YYINITIAL = 0;
  22.  
  23.   /**
  24.    * ZZ_LEXSTATE[l] is the state in the DFA for the lexical state l
  25.    * ZZ_LEXSTATE[l+1] is the state in the DFA for the lexical state l
  26.    *                  at the beginning of a line
  27.    * l is of the form l = 2*k, k a non negative integer
  28.    */
  29.   private static final int ZZ_LEXSTATE[] = {
  30.      0, 0
  31.   };
  32.  
  33.   /**
  34.    * Translates characters to character classes
  35.    */
  36.   private static final String ZZ_CMAP_PACKED =
  37.     "\11\12\1\13\4\0\16\12\4\0\1\13\3\0\1\11\1\0\1\2"+
  38.     "\1\0\1\7\1\10\3\0\1\4\2\0\12\12\2\0\1\6\1\0"+
  39.     "\1\5\2\0\25\11\1\1\4\11\4\0\1\11\1\0\32\11\3\0"+
  40.     "\1\3\41\12\2\0\4\11\4\0\1\11\2\0\1\12\7\0\1\11"+
  41.     "\4\0\1\11\5\0\27\11\1\0\37\11\1\0\u01ca\11\4\0\14\11"+
  42.     "\16\0\5\11\7\0\1\11\1\0\1\11\21\0\160\12\5\11\1\0"+
  43.     "\2\11\2\0\4\11\10\0\1\11\1\0\3\11\1\0\1\11\1\0"+
  44.     "\24\11\1\0\123\11\1\0\213\11\1\0\5\12\2\0\236\11\11\0"+
  45.     "\46\11\2\0\1\11\7\0\47\11\7\0\1\11\1\0\55\12\1\0"+
  46.     "\1\12\1\0\2\12\1\0\2\12\1\0\1\12\10\0\33\11\5\0"+
  47.     "\3\11\15\0\5\12\6\0\1\11\4\0\13\12\5\0\53\11\37\12"+
  48.     "\4\0\2\11\1\12\143\11\1\0\1\11\10\12\1\0\6\12\2\11"+
  49.     "\2\12\1\0\4\12\2\11\12\12\3\11\2\0\1\11\17\0\1\12"+
  50.     "\1\11\1\12\36\11\33\12\2\0\131\11\13\12\1\11\16\0\12\12"+
  51.     "\41\11\11\12\2\11\4\0\1\11\5\0\26\11\4\12\1\11\11\12"+
  52.     "\1\11\3\12\1\11\5\12\22\0\31\11\3\12\104\0\1\11\1\0"+
  53.     "\13\11\67\0\33\12\1\0\4\12\66\11\3\12\1\11\22\12\1\11"+
  54.     "\7\12\12\11\2\12\2\0\12\12\1\0\7\11\1\0\7\11\1\0"+
  55.     "\3\12\1\0\10\11\2\0\2\11\2\0\26\11\1\0\7\11\1\0"+
  56.     "\1\11\3\0\4\11\2\0\1\12\1\11\7\12\2\0\2\12\2\0"+
  57.     "\3\12\1\11\10\0\1\12\4\0\2\11\1\0\3\11\2\12\2\0"+
  58.     "\12\12\4\11\7\0\1\11\5\0\3\12\1\0\6\11\4\0\2\11"+
  59.     "\2\0\26\11\1\0\7\11\1\0\2\11\1\0\2\11\1\0\2\11"+
  60.     "\2\0\1\12\1\0\5\12\4\0\2\12\2\0\3\12\3\0\1\12"+
  61.     "\7\0\4\11\1\0\1\11\7\0\14\12\3\11\1\12\13\0\3\12"+
  62.     "\1\0\11\11\1\0\3\11\1\0\26\11\1\0\7\11\1\0\2\11"+
  63.     "\1\0\5\11\2\0\1\12\1\11\10\12\1\0\3\12\1\0\3\12"+
  64.     "\2\0\1\11\17\0\2\11\2\12\2\0\12\12\1\0\1\11\17\0"+
  65.     "\3\12\1\0\10\11\2\0\2\11\2\0\26\11\1\0\7\11\1\0"+
  66.     "\2\11\1\0\5\11\2\0\1\12\1\11\7\12\2\0\2\12\2\0"+
  67.     "\3\12\10\0\2\12\4\0\2\11\1\0\3\11\2\12\2\0\12\12"+
  68.     "\1\0\1\11\20\0\1\12\1\11\1\0\6\11\3\0\3\11\1\0"+
  69.     "\4\11\3\0\2\11\1\0\1\11\1\0\2\11\3\0\2\11\3\0"+
  70.     "\3\11\3\0\14\11\4\0\5\12\3\0\3\12\1\0\4\12\2\0"+
  71.     "\1\11\6\0\1\12\16\0\12\12\11\0\1\11\7\0\3\12\1\0"+
  72.     "\10\11\1\0\3\11\1\0\27\11\1\0\12\11\1\0\5\11\3\0"+
  73.     "\1\11\7\12\1\0\3\12\1\0\4\12\7\0\2\12\1\0\2\11"+
  74.     "\6\0\2\11\2\12\2\0\12\12\22\0\2\12\1\0\10\11\1\0"+
  75.     "\3\11\1\0\27\11\1\0\12\11\1\0\5\11\2\0\1\12\1\11"+
  76.     "\7\12\1\0\3\12\1\0\4\12\7\0\2\12\7\0\1\11\1\0"+
  77.     "\2\11\2\12\2\0\12\12\1\0\2\11\17\0\2\12\1\0\10\11"+
  78.     "\1\0\3\11\1\0\51\11\2\0\1\11\7\12\1\0\3\12\1\0"+
  79.     "\4\12\1\11\10\0\1\12\10\0\2\11\2\12\2\0\12\12\12\0"+
  80.     "\6\11\2\0\2\12\1\0\22\11\3\0\30\11\1\0\11\11\1\0"+
  81.     "\1\11\2\0\7\11\3\0\1\12\4\0\6\12\1\0\1\12\1\0"+
  82.     "\10\12\22\0\2\12\15\0\60\11\1\12\2\11\7\12\4\0\10\11"+
  83.     "\10\12\1\0\12\12\47\0\2\11\1\0\1\11\2\0\2\11\1\0"+
  84.     "\1\11\2\0\1\11\6\0\4\11\1\0\7\11\1\0\3\11\1\0"+
  85.     "\1\11\1\0\1\11\2\0\2\11\1\0\4\11\1\12\2\11\6\12"+
  86.     "\1\0\2\12\1\11\2\0\5\11\1\0\1\11\1\0\6\12\2\0"+
  87.     "\12\12\2\0\4\11\40\0\1\11\27\0\2\12\6\0\12\12\13\0"+
  88.     "\1\12\1\0\1\12\1\0\1\12\4\0\2\12\10\11\1\0\44\11"+
  89.     "\4\0\24\12\1\0\2\12\5\11\13\12\1\0\44\12\11\0\1\12"+
  90.     "\71\0\53\11\24\12\1\11\12\12\6\0\6\11\4\12\4\11\3\12"+
  91.     "\1\11\3\12\2\11\7\12\3\11\4\12\15\11\14\12\1\11\17\12"+
  92.     "\2\0\46\11\1\0\1\11\5\0\1\11\2\0\53\11\1\0\u014d\11"+
  93.     "\1\0\4\11\2\0\7\11\1\0\1\11\1\0\4\11\2\0\51\11"+
  94.     "\1\0\4\11\2\0\41\11\1\0\4\11\2\0\7\11\1\0\1\11"+
  95.     "\1\0\4\11\2\0\17\11\1\0\71\11\1\0\4\11\2\0\103\11"+
  96.     "\2\0\3\12\40\0\20\11\20\0\125\11\14\0\u026c\11\2\0\21\11"+
  97.     "\1\0\32\11\5\0\113\11\3\0\3\11\17\0\15\11\1\0\4\11"+
  98.     "\3\12\13\0\22\11\3\12\13\0\22\11\2\12\14\0\15\11\1\0"+
  99.     "\3\11\1\0\2\12\14\0\64\11\40\12\3\0\1\11\3\0\2\11"+
  100.     "\1\12\2\0\12\12\41\0\3\12\2\0\12\12\6\0\130\11\10\0"+
  101.     "\51\11\1\12\1\11\5\0\106\11\12\0\35\11\3\0\14\12\4\0"+
  102.     "\14\12\12\0\12\12\36\11\2\0\5\11\13\0\54\11\4\0\21\12"+
  103.     "\7\11\2\12\6\0\12\12\46\0\27\11\5\12\4\0\65\11\12\12"+
  104.     "\1\0\35\12\2\0\13\12\6\0\12\12\15\0\1\11\130\0\5\12"+
  105.     "\57\11\21\12\7\11\4\0\12\12\21\0\11\12\14\0\3\12\36\11"+
  106.     "\15\12\2\11\12\12\54\11\16\12\14\0\44\11\24\12\10\0\12\12"+
  107.     "\3\0\3\11\12\12\44\11\122\0\3\12\1\0\25\12\4\11\1\12"+
  108.     "\4\11\3\12\2\11\11\0\300\11\47\12\25\0\4\12\u0116\11\2\0"+
  109.     "\6\11\2\0\46\11\2\0\6\11\2\0\10\11\1\0\1\11\1\0"+
  110.     "\1\11\1\0\1\11\1\0\37\11\2\0\65\11\1\0\7\11\1\0"+
  111.     "\1\11\3\0\3\11\1\0\7\11\3\0\4\11\2\0\6\11\4\0"+
  112.     "\15\11\5\0\3\11\1\0\7\11\16\0\5\12\32\0\5\12\20\0"+
  113.     "\2\11\23\0\1\11\13\0\5\12\5\0\6\12\1\0\1\11\15\0"+
  114.     "\1\11\20\0\15\11\3\0\33\11\25\0\15\12\4\0\1\12\3\0"+
  115.     "\14\12\21\0\1\11\4\0\1\11\2\0\12\11\1\0\1\11\3\0"+
  116.     "\5\11\6\0\1\11\1\0\1\11\1\0\1\11\1\0\4\11\1\0"+
  117.     "\13\11\2\0\4\11\5\0\5\11\4\0\1\11\21\0\51\11\u0a77\0"+
  118.     "\57\11\1\0\57\11\1\0\205\11\6\0\4\11\3\12\2\11\14\0"+
  119.     "\46\11\1\0\1\11\5\0\1\11\2\0\70\11\7\0\1\11\17\0"+
  120.     "\1\12\27\11\11\0\7\11\1\0\7\11\1\0\7\11\1\0\7\11"+
  121.     "\1\0\7\11\1\0\7\11\1\0\7\11\1\0\7\11\1\0\40\12"+
  122.     "\57\0\1\11\u01d5\0\3\11\31\0\11\11\6\12\1\0\5\11\2\0"+
  123.     "\5\11\4\0\126\11\2\0\2\12\2\0\3\11\1\0\132\11\1\0"+
  124.     "\4\11\5\0\51\11\3\0\136\11\21\0\33\11\65\0\20\11\u0200\0"+
  125.     "\u19b6\11\112\0\u51cd\11\63\0\u048d\11\103\0\56\11\2\0\u010d\11\3\0"+
  126.     "\20\11\12\12\2\11\24\0\57\11\1\12\4\0\12\12\1\0\31\11"+
  127.     "\7\0\1\12\120\11\2\12\45\0\11\11\2\0\147\11\2\0\4\11"+
  128.     "\1\0\4\11\14\0\13\11\115\0\12\11\1\12\3\11\1\12\4\11"+
  129.     "\1\12\27\11\5\12\20\0\1\11\7\0\64\11\14\0\2\12\62\11"+
  130.     "\21\12\13\0\12\12\6\0\22\12\6\11\3\0\1\11\4\0\12\12"+
  131.     "\34\11\10\12\2\0\27\11\15\12\14\0\35\11\3\0\4\12\57\11"+
  132.     "\16\12\16\0\1\11\12\12\46\0\51\11\16\12\11\0\3\11\1\12"+
  133.     "\10\11\2\12\2\0\12\12\6\0\27\11\3\0\1\11\1\12\4\0"+
  134.     "\60\11\1\12\1\11\3\12\2\11\2\12\5\11\2\12\1\11\1\12"+
  135.     "\1\11\30\0\3\11\2\0\13\11\5\12\2\0\3\11\2\12\12\0"+
  136.     "\6\11\2\0\6\11\2\0\6\11\11\0\7\11\1\0\7\11\221\0"+
  137.     "\43\11\10\12\1\0\2\12\2\0\12\12\6\0\u2ba4\11\14\0\27\11"+
  138.     "\4\0\61\11\u2104\0\u016e\11\2\0\152\11\46\0\7\11\14\0\5\11"+
  139.     "\5\0\1\11\1\12\12\11\1\0\15\11\1\0\5\11\1\0\1\11"+
  140.     "\1\0\2\11\1\0\2\11\1\0\154\11\41\0\u016b\11\22\0\100\11"+
  141.     "\2\0\66\11\50\0\15\11\3\0\20\12\20\0\7\12\14\0\2\11"+
  142.     "\30\0\3\11\31\0\1\11\6\0\5\11\1\0\207\11\2\0\1\12"+
  143.     "\4\0\1\11\13\0\12\12\7\0\32\11\4\0\1\11\1\0\32\11"+
  144.     "\13\0\131\11\3\0\6\11\2\0\6\11\2\0\6\11\2\0\3\11"+
  145.     "\3\0\2\11\3\0\2\11\22\0\3\12\4\0\14\11\1\0\32\11"+
  146.     "\1\0\23\11\1\0\2\11\1\0\17\11\2\0\16\11\42\0\173\11"+
  147.     "\105\0\65\11\210\0\1\12\202\0\35\11\3\0\61\11\57\0\37\11"+
  148.     "\21\0\33\11\65\0\36\11\2\0\44\11\4\0\10\11\1\0\5\11"+
  149.     "\52\0\236\11\2\0\12\12\u0356\0\6\11\2\0\1\11\1\0\54\11"+
  150.     "\1\0\2\11\3\0\1\11\2\0\27\11\252\0\26\11\12\0\32\11"+
  151.     "\106\0\70\11\6\0\2\11\100\0\1\11\3\12\1\0\2\12\5\0"+
  152.     "\4\12\4\11\1\0\3\11\1\0\33\11\4\0\3\12\4\0\1\12"+
  153.     "\40\0\35\11\203\0\66\11\12\0\26\11\12\0\23\11\215\0\111\11"+
  154.     "\u03b7\0\3\12\65\11\17\12\37\0\12\12\20\0\3\12\55\11\13\12"+
  155.     "\2\0\1\12\22\0\31\11\7\0\12\12\6\0\3\12\44\11\16\12"+
  156.     "\1\0\12\12\100\0\3\12\60\11\16\12\4\11\13\0\12\12\u04a6\0"+
  157.     "\53\11\15\12\10\0\12\12\u0936\0\u036f\11\221\0\143\11\u0b9d\0\u042f\11"+
  158.     "\u33d1\0\u0239\11\u04c7\0\105\11\13\0\1\11\56\12\20\0\4\12\15\11"+
  159.     "\u4060\0\2\11\u2163\0\5\12\3\0\26\12\2\0\7\12\36\0\4\12"+
  160.     "\224\0\3\12\u01bb\0\125\11\1\0\107\11\1\0\2\11\2\0\1\11"+
  161.     "\2\0\2\11\2\0\4\11\1\0\14\11\1\0\1\11\1\0\7\11"+
  162.     "\1\0\101\11\1\0\4\11\2\0\10\11\1\0\7\11\1\0\34\11"+
  163.     "\1\0\4\11\1\0\5\11\1\0\1\11\3\0\7\11\1\0\u0154\11"+
  164.     "\2\0\31\11\1\0\31\11\1\0\37\11\1\0\31\11\1\0\37\11"+
  165.     "\1\0\31\11\1\0\37\11\1\0\31\11\1\0\37\11\1\0\31\11"+
  166.     "\1\0\10\11\2\0\62\12\u1600\0\4\11\1\0\33\11\1\0\2\11"+
  167.     "\1\0\1\11\2\0\1\11\1\0\12\11\1\0\4\11\1\0\1\11"+
  168.     "\1\0\1\11\6\0\1\11\4\0\1\11\1\0\1\11\1\0\1\11"+
  169.     "\1\0\3\11\1\0\2\11\1\0\1\11\2\0\1\11\1\0\1\11"+
  170.     "\1\0\1\11\1\0\1\11\1\0\1\11\1\0\2\11\1\0\1\11"+
  171.     "\2\0\4\11\1\0\7\11\1\0\4\11\1\0\4\11\1\0\1\11"+
  172.     "\1\0\12\11\1\0\21\11\5\0\3\11\1\0\5\11\1\0\21\11"+
  173.     "\u1144\0\ua6d7\11\51\0\u1035\11\13\0\336\11\u3fe2\0\u021e\11\uffff\0\uffff\0\uffff\0\uffff\0\uffff\0\uffff\0\uffff\0\uffff\0\uffff\0\uffff\0\uffff\0\u05ee\0"+
  174.     "\1\12\36\0\140\12\200\0\360\12\uffff\0\uffff\0\ufe12\0";
  175.  
  176.   /**
  177.    * Translates characters to character classes
  178.    */
  179.   private static final char [] ZZ_CMAP = zzUnpackCMap(ZZ_CMAP_PACKED);
  180.  
  181.   /**
  182.    * Translates DFA states to action switch labels.
  183.    */
  184.   private static final int [] ZZ_ACTION = zzUnpackAction();
  185.  
  186.   private static final String ZZ_ACTION_PACKED_0 =
  187.     "\1\0\1\1\1\2\1\3\1\4\2\1\1\5\1\6"+
  188.     "\1\7\1\10\1\11\1\0\1\12";
  189.  
  190.   private static int [] zzUnpackAction() {
  191.     int [] result = new int[14];
  192.     int offset = 0;
  193.     offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result);
  194.     return result;
  195.   }
  196.  
  197.   private static int zzUnpackAction(String packed, int offset, int [] result) {
  198.     int i = 0;       /* index in packed string  */
  199.     int j = offset;  /* index in unpacked array */
  200.     int l = packed.length();
  201.     while (i < l) {
  202.       int count = packed.charAt(i++);
  203.       int value = packed.charAt(i++);
  204.       do result[j++] = value; while (--count > 0);
  205.     }
  206.     return j;
  207.   }
  208.  
  209.  
  210.   /**
  211.    * Translates a state to a row index in the transition table
  212.    */
  213.   private static final int [] ZZ_ROWMAP = zzUnpackRowMap();
  214.  
  215.   private static final String ZZ_ROWMAP_PACKED_0 =
  216.     "\0\0\0\14\0\30\0\14\0\14\0\44\0\60\0\14"+
  217.     "\0\14\0\30\0\74\0\14\0\110\0\14";
  218.  
  219.   private static int [] zzUnpackRowMap() {
  220.     int [] result = new int[14];
  221.     int offset = 0;
  222.     offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result);
  223.     return result;
  224.   }
  225.  
  226.   private static int zzUnpackRowMap(String packed, int offset, int [] result) {
  227.     int i = 0;  /* index in packed string  */
  228.     int j = offset;  /* index in unpacked array */
  229.     int l = packed.length();
  230.     while (i < l) {
  231.       int high = packed.charAt(i++) << 16;
  232.       result[j++] = high | packed.charAt(i++);
  233.     }
  234.     return j;
  235.   }
  236.  
  237.   /**
  238.    * The transition table of the DFA
  239.    */
  240.   private static final int [] ZZ_TRANS = zzUnpackTrans();
  241.  
  242.   private static final String ZZ_TRANS_PACKED_0 =
  243.     "\1\2\1\3\1\4\1\5\1\6\1\2\1\7\1\10"+
  244.     "\1\11\1\12\1\2\1\13\15\0\1\12\7\0\2\12"+
  245.     "\6\0\1\14\12\0\1\15\22\0\1\13\5\0\1\16"+
  246.     "\6\0";
  247.  
  248.   private static int [] zzUnpackTrans() {
  249.     int [] result = new int[84];
  250.     int offset = 0;
  251.     offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result);
  252.     return result;
  253.   }
  254.  
  255.   private static int zzUnpackTrans(String packed, int offset, int [] result) {
  256.     int i = 0;       /* index in packed string  */
  257.     int j = offset;  /* index in unpacked array */
  258.     int l = packed.length();
  259.     while (i < l) {
  260.       int count = packed.charAt(i++);
  261.       int value = packed.charAt(i++);
  262.       value--;
  263.       do result[j++] = value; while (--count > 0);
  264.     }
  265.     return j;
  266.   }
  267.  
  268.  
  269.   /* error codes */
  270.   private static final int ZZ_UNKNOWN_ERROR = 0;
  271.   private static final int ZZ_NO_MATCH = 1;
  272.   private static final int ZZ_PUSHBACK_2BIG = 2;
  273.  
  274.   /* error messages for the codes above */
  275.   private static final String ZZ_ERROR_MSG[] = {
  276.     "Unkown internal scanner error",
  277.     "Error: could not match input",
  278.     "Error: pushback value was too large"
  279.   };
  280.  
  281.   /**
  282.    * ZZ_ATTRIBUTE[aState] contains the attributes of state <code>aState</code>
  283.    */
  284.   private static final int [] ZZ_ATTRIBUTE = zzUnpackAttribute();
  285.  
  286.   private static final String ZZ_ATTRIBUTE_PACKED_0 =
  287.     "\1\0\1\11\1\1\2\11\2\1\2\11\2\1\1\11"+
  288.     "\1\0\1\11";
  289.  
  290.   private static int [] zzUnpackAttribute() {
  291.     int [] result = new int[14];
  292.     int offset = 0;
  293.     offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result);
  294.     return result;
  295.   }
  296.  
  297.   private static int zzUnpackAttribute(String packed, int offset, int [] result) {
  298.     int i = 0;       /* index in packed string  */
  299.     int j = offset;  /* index in unpacked array */
  300.     int l = packed.length();
  301.     while (i < l) {
  302.       int count = packed.charAt(i++);
  303.       int value = packed.charAt(i++);
  304.       do result[j++] = value; while (--count > 0);
  305.     }
  306.     return j;
  307.   }
  308.  
  309.   /** the input device */
  310.   private java.io.Reader zzReader;
  311.  
  312.   /** the current state of the DFA */
  313.   private int zzState;
  314.  
  315.   /** the current lexical state */
  316.   private int zzLexicalState = YYINITIAL;
  317.  
  318.   /** this buffer contains the current text to be matched and is
  319.       the source of the yytext() string */
  320.   private char zzBuffer[] = new char[ZZ_BUFFERSIZE];
  321.  
  322.   /** the textposition at the last accepting state */
  323.   private int zzMarkedPos;
  324.  
  325.   /** the current text position in the buffer */
  326.   private int zzCurrentPos;
  327.  
  328.   /** startRead marks the beginning of the yytext() string in the buffer */
  329.   private int zzStartRead;
  330.  
  331.   /** endRead marks the last character in the buffer, that has been read
  332.       from input */
  333.   private int zzEndRead;
  334.  
  335.   /** number of newlines encountered up to the start of the matched text */
  336.   private int yyline;
  337.  
  338.   /** the number of characters up to the start of the matched text */
  339.   private int yychar;
  340.  
  341.   /**
  342.    * the number of characters from the last newline up to the start of the
  343.    * matched text
  344.    */
  345.   private int yycolumn;
  346.  
  347.   /**
  348.    * zzAtBOL == true <=> the scanner is currently at the beginning of a line
  349.    */
  350.   private boolean zzAtBOL = true;
  351.  
  352.   /** zzAtEOF == true <=> the scanner is at the EOF */
  353.   private boolean zzAtEOF;
  354.  
  355.   /** denotes if the user-EOF-code has already been executed */
  356.   private boolean zzEOFDone;
  357.  
  358.   /**
  359.    * The number of occupied positions in zzBuffer beyond zzEndRead.
  360.    * When a lead/high surrogate has been read from the input stream
  361.    * into the final zzBuffer position, this will have a value of 1;
  362.    * otherwise, it will have a value of 0.
  363.    */
  364.   private int zzFinalHighSurrogate = 0;
  365.  
  366.   /* user code: */
  367.   private Symbol symbol( int type ){ return new Symbol(type, yyline, yycolumn); }
  368.   private Symbol symbol( int type, Object value ){ return new Symbol(type, yyline, yycolumn, value); }
  369.  
  370.  
  371.   /**
  372.    * Creates a new scanner
  373.    *
  374.    * @param   in  the java.io.Reader to read input from.
  375.    */
  376.   FormulaLexer(java.io.Reader in) {
  377.     this.zzReader = in;
  378.   }
  379.  
  380.  
  381.   /**
  382.    * Unpacks the compressed character translation table.
  383.    *
  384.    * @param packed   the packed character translation table
  385.    * @return         the unpacked character translation table
  386.    */
  387.   private static char [] zzUnpackCMap(String packed) {
  388.     char [] map = new char[0x110000];
  389.     int i = 0;  /* index in packed string  */
  390.     int j = 0;  /* index in unpacked array */
  391.     while (i < 2776) {
  392.       int  count = packed.charAt(i++);
  393.       char value = packed.charAt(i++);
  394.       do map[j++] = value; while (--count > 0);
  395.     }
  396.     return map;
  397.   }
  398.  
  399.  
  400.   /**
  401.    * Refills the input buffer.
  402.    *
  403.    * @return      <code>false</code>, iff there was new input.
  404.    *
  405.    * @exception   java.io.IOException  if any I/O-Error occurs
  406.    */
  407.   private boolean zzRefill() throws java.io.IOException {
  408.  
  409.     /* first: make room (if you can) */
  410.     if (zzStartRead > 0) {
  411.       zzEndRead += zzFinalHighSurrogate;
  412.       zzFinalHighSurrogate = 0;
  413.       System.arraycopy(zzBuffer, zzStartRead,
  414.                        zzBuffer, 0,
  415.                        zzEndRead-zzStartRead);
  416.  
  417.       /* translate stored positions */
  418.       zzEndRead-= zzStartRead;
  419.       zzCurrentPos-= zzStartRead;
  420.       zzMarkedPos-= zzStartRead;
  421.       zzStartRead = 0;
  422.     }
  423.  
  424.     /* is the buffer big enough? */
  425.     if (zzCurrentPos >= zzBuffer.length - zzFinalHighSurrogate) {
  426.       /* if not: blow it up */
  427.       char newBuffer[] = new char[zzBuffer.length*2];
  428.       System.arraycopy(zzBuffer, 0, newBuffer, 0, zzBuffer.length);
  429.       zzBuffer = newBuffer;
  430.       zzEndRead += zzFinalHighSurrogate;
  431.       zzFinalHighSurrogate = 0;
  432.     }
  433.  
  434.     /* fill the buffer with new input */
  435.     int requested = zzBuffer.length - zzEndRead;          
  436.     int totalRead = 0;
  437.     while (totalRead < requested) {
  438.       int numRead = zzReader.read(zzBuffer, zzEndRead + totalRead, requested - totalRead);
  439.       if (numRead == -1) {
  440.         break;
  441.       }
  442.       totalRead += numRead;
  443.     }
  444.  
  445.     if (totalRead > 0) {
  446.       zzEndRead += totalRead;
  447.       if (totalRead == requested) { /* possibly more input available */
  448.         if (Character.isHighSurrogate(zzBuffer[zzEndRead - 1])) {
  449.           --zzEndRead;
  450.           zzFinalHighSurrogate = 1;
  451.         }
  452.       }
  453.       return false;
  454.     }
  455.  
  456.     // totalRead = 0: End of stream
  457.     return true;
  458.   }
  459.  
  460.    
  461.   /**
  462.    * Closes the input stream.
  463.    */
  464.   public final void yyclose() throws java.io.IOException {
  465.     zzAtEOF = true;            /* indicate end of file */
  466.     zzEndRead = zzStartRead;  /* invalidate buffer    */
  467.  
  468.     if (zzReader != null)
  469.       zzReader.close();
  470.   }
  471.  
  472.  
  473.   /**
  474.    * Resets the scanner to read from a new input stream.
  475.    * Does not close the old reader.
  476.    *
  477.    * All internal variables are reset, the old input stream
  478.    * <b>cannot</b> be reused (internal buffer is discarded and lost).
  479.    * Lexical state is set to <tt>ZZ_INITIAL</tt>.
  480.    *
  481.    * Internal scan buffer is resized down to its initial length, if it has grown.
  482.    *
  483.    * @param reader   the new input stream
  484.    */
  485.   public final void yyreset(java.io.Reader reader) {
  486.     zzReader = reader;
  487.     zzAtBOL  = true;
  488.     zzAtEOF  = false;
  489.     zzEOFDone = false;
  490.     zzEndRead = zzStartRead = 0;
  491.     zzCurrentPos = zzMarkedPos = 0;
  492.     zzFinalHighSurrogate = 0;
  493.     yyline = yychar = yycolumn = 0;
  494.     zzLexicalState = YYINITIAL;
  495.     if (zzBuffer.length > ZZ_BUFFERSIZE)
  496.       zzBuffer = new char[ZZ_BUFFERSIZE];
  497.   }
  498.  
  499.  
  500.   /**
  501.    * Returns the current lexical state.
  502.    */
  503.   public final int yystate() {
  504.     return zzLexicalState;
  505.   }
  506.  
  507.  
  508.   /**
  509.    * Enters a new lexical state
  510.    *
  511.    * @param newState the new lexical state
  512.    */
  513.   public final void yybegin(int newState) {
  514.     zzLexicalState = newState;
  515.   }
  516.  
  517.  
  518.   /**
  519.    * Returns the text matched by the current regular expression.
  520.    */
  521.   public final String yytext() {
  522.     return new String( zzBuffer, zzStartRead, zzMarkedPos-zzStartRead );
  523.   }
  524.  
  525.  
  526.   /**
  527.    * Returns the character at position <tt>pos</tt> from the
  528.    * matched text.
  529.    *
  530.    * It is equivalent to yytext().charAt(pos), but faster
  531.    *
  532.    * @param pos the position of the character to fetch.
  533.    *            A value from 0 to yylength()-1.
  534.    *
  535.    * @return the character at position pos
  536.    */
  537.   public final char yycharat(int pos) {
  538.     return zzBuffer[zzStartRead+pos];
  539.   }
  540.  
  541.  
  542.   /**
  543.    * Returns the length of the matched text region.
  544.    */
  545.   public final int yylength() {
  546.     return zzMarkedPos-zzStartRead;
  547.   }
  548.  
  549.  
  550.   /**
  551.    * Reports an error that occured while scanning.
  552.    *
  553.    * In a wellformed scanner (no or only correct usage of
  554.    * yypushback(int) and a match-all fallback rule) this method
  555.    * will only be called with things that "Can't Possibly Happen".
  556.    * If this method is called, something is seriously wrong
  557.    * (e.g. a JFlex bug producing a faulty scanner etc.).
  558.    *
  559.    * Usual syntax/scanner level error handling should be done
  560.    * in error fallback rules.
  561.    *
  562.    * @param   errorCode  the code of the errormessage to display
  563.    */
  564.   private void zzScanError(int errorCode) {
  565.     String message;
  566.     try {
  567.       message = ZZ_ERROR_MSG[errorCode];
  568.     }
  569.     catch (ArrayIndexOutOfBoundsException e) {
  570.       message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR];
  571.     }
  572.  
  573.     throw new Error(message);
  574.   }
  575.  
  576.  
  577.   /**
  578.    * Pushes the specified amount of characters back into the input stream.
  579.    *
  580.    * They will be read again by then next call of the scanning method
  581.    *
  582.    * @param number  the number of characters to be read again.
  583.    *                This number must not be greater than yylength()!
  584.    */
  585.   public void yypushback(int number)  {
  586.     if ( number > yylength() )
  587.       zzScanError(ZZ_PUSHBACK_2BIG);
  588.  
  589.     zzMarkedPos -= number;
  590.   }
  591.  
  592.  
  593.   /**
  594.    * Contains user EOF-code, which will be executed exactly once,
  595.    * when the end of file is reached
  596.    */
  597.   private void zzDoEOF() throws java.io.IOException {
  598.     if (!zzEOFDone) {
  599.       zzEOFDone = true;
  600.       yyclose();
  601.     }
  602.   }
  603.  
  604.  
  605.   /**
  606.    * Resumes scanning until the next regular expression is matched,
  607.    * the end of input is encountered or an I/O-Error occurs.
  608.    *
  609.    * @return      the next token
  610.    * @exception   java.io.IOException  if any I/O-Error occurs
  611.    */
  612.   public java_cup.runtime.Symbol next_token() throws java.io.IOException {
  613.     int zzInput;
  614.     int zzAction;
  615.  
  616.     // cached fields:
  617.     int zzCurrentPosL;
  618.     int zzMarkedPosL;
  619.     int zzEndReadL = zzEndRead;
  620.     char [] zzBufferL = zzBuffer;
  621.     char [] zzCMapL = ZZ_CMAP;
  622.  
  623.     int [] zzTransL = ZZ_TRANS;
  624.     int [] zzRowMapL = ZZ_ROWMAP;
  625.     int [] zzAttrL = ZZ_ATTRIBUTE;
  626.  
  627.     while (true) {
  628.       zzMarkedPosL = zzMarkedPos;
  629.  
  630.       boolean zzR = false;
  631.       int zzCh;
  632.       int zzCharCount;
  633.       for (zzCurrentPosL = zzStartRead  ;
  634.            zzCurrentPosL < zzMarkedPosL ;
  635.            zzCurrentPosL += zzCharCount ) {
  636.         zzCh = Character.codePointAt(zzBufferL, zzCurrentPosL, zzMarkedPosL);
  637.         zzCharCount = Character.charCount(zzCh);
  638.         switch (zzCh) {
  639.         case '\u000B':
  640.         case '\u000C':
  641.         case '\u0085':
  642.         case '\u2028':
  643.         case '\u2029':
  644.           yyline++;
  645.           yycolumn = 0;
  646.           zzR = false;
  647.           break;
  648.         case '\r':
  649.           yyline++;
  650.           yycolumn = 0;
  651.           zzR = true;
  652.           break;
  653.         case '\n':
  654.           if (zzR)
  655.             zzR = false;
  656.           else {
  657.             yyline++;
  658.             yycolumn = 0;
  659.           }
  660.           break;
  661.         default:
  662.           zzR = false;
  663.           yycolumn += zzCharCount;
  664.         }
  665.       }
  666.  
  667.       if (zzR) {
  668.         // peek one character ahead if it is \n (if we have counted one line too much)
  669.         boolean zzPeek;
  670.         if (zzMarkedPosL < zzEndReadL)
  671.           zzPeek = zzBufferL[zzMarkedPosL] == '\n';
  672.         else if (zzAtEOF)
  673.           zzPeek = false;
  674.         else {
  675.           boolean eof = zzRefill();
  676.           zzEndReadL = zzEndRead;
  677.           zzMarkedPosL = zzMarkedPos;
  678.           zzBufferL = zzBuffer;
  679.           if (eof)
  680.             zzPeek = false;
  681.           else
  682.             zzPeek = zzBufferL[zzMarkedPosL] == '\n';
  683.         }
  684.         if (zzPeek) yyline--;
  685.       }
  686.       zzAction = -1;
  687.  
  688.       zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL;
  689.  
  690.       zzState = ZZ_LEXSTATE[zzLexicalState];
  691.  
  692.       // set up zzAction for empty match case:
  693.       int zzAttributes = zzAttrL[zzState];
  694.       if ( (zzAttributes & 1) == 1 ) {
  695.         zzAction = zzState;
  696.       }
  697.  
  698.  
  699.       zzForAction: {
  700.         while (true) {
  701.    
  702.           if (zzCurrentPosL < zzEndReadL) {
  703.             zzInput = Character.codePointAt(zzBufferL, zzCurrentPosL, zzEndReadL);
  704.             zzCurrentPosL += Character.charCount(zzInput);
  705.           }
  706.           else if (zzAtEOF) {
  707.             zzInput = YYEOF;
  708.             break zzForAction;
  709.           }
  710.           else {
  711.             // store back cached positions
  712.             zzCurrentPos  = zzCurrentPosL;
  713.             zzMarkedPos   = zzMarkedPosL;
  714.             boolean eof = zzRefill();
  715.             // get translated positions and possibly new buffer
  716.             zzCurrentPosL  = zzCurrentPos;
  717.             zzMarkedPosL   = zzMarkedPos;
  718.             zzBufferL      = zzBuffer;
  719.             zzEndReadL     = zzEndRead;
  720.             if (eof) {
  721.               zzInput = YYEOF;
  722.               break zzForAction;
  723.             }
  724.             else {
  725.               zzInput = Character.codePointAt(zzBufferL, zzCurrentPosL, zzEndReadL);
  726.               zzCurrentPosL += Character.charCount(zzInput);
  727.             }
  728.           }
  729.           int zzNext = zzTransL[ zzRowMapL[zzState] + zzCMapL[zzInput] ];
  730.           if (zzNext == -1) break zzForAction;
  731.           zzState = zzNext;
  732.  
  733.           zzAttributes = zzAttrL[zzState];
  734.           if ( (zzAttributes & 1) == 1 ) {
  735.             zzAction = zzState;
  736.             zzMarkedPosL = zzCurrentPosL;
  737.             if ( (zzAttributes & 8) == 8 ) break zzForAction;
  738.           }
  739.  
  740.         }
  741.       }
  742.  
  743.       // store back cached position
  744.       zzMarkedPos = zzMarkedPosL;
  745.  
  746.       switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) {
  747.         case 1:
  748.           { throw new Error("Illegal character <"+yytext()+">");
  749.           }
  750.         case 11: break;
  751.         case 2:
  752.           { return symbol( FormulaParserSym.VEE );
  753.           }
  754.         case 12: break;
  755.         case 3:
  756.           { return symbol( FormulaParserSym.WEDGE );
  757.           }
  758.         case 13: break;
  759.         case 4:
  760.           { return symbol( FormulaParserSym.NEGATION );
  761.           }
  762.         case 14: break;
  763.         case 5:
  764.           { return symbol( FormulaParserSym.LPAREN );
  765.           }
  766.         case 15: break;
  767.         case 6:
  768.           { return symbol( FormulaParserSym.RPAREN );
  769.           }
  770.         case 16: break;
  771.         case 7:
  772.           { return symbol( FormulaParserSym.VARIABLE, yytext() );
  773.           }
  774.         case 17: break;
  775.         case 8:
  776.           {
  777.           }
  778.         case 18: break;
  779.         case 9:
  780.           { return symbol( FormulaParserSym.IMPLIES );
  781.           }
  782.         case 19: break;
  783.         case 10:
  784.           { return symbol( FormulaParserSym.IFF );
  785.           }
  786.         case 20: break;
  787.         default:
  788.           if (zzInput == YYEOF && zzStartRead == zzCurrentPos) {
  789.             zzAtEOF = true;
  790.             zzDoEOF();
  791.               { return new java_cup.runtime.Symbol(FormulaParserSym.EOF); }
  792.           }
  793.           else {
  794.             zzScanError(ZZ_NO_MATCH);
  795.           }
  796.       }
  797.     }
  798.   }
  799.  
  800.  
  801. }
Advertisement
Add Comment
Please, Sign In to add comment