Yylex.java

  1. package org.drip.json.parser;

  2. /*
  3.  * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  4.  */

  5. /*!
  6.  * Copyright (C) 2020 Lakshmi Krishnamurthy
  7.  * Copyright (C) 2019 Lakshmi Krishnamurthy
  8.  * Copyright (C) 2018 Lakshmi Krishnamurthy
  9.  * Copyright (C) 2017 Lakshmi Krishnamurthy
  10.  * Copyright (C) 2016 Lakshmi Krishnamurthy
  11.  *
  12.  *  This file is part of DROP, an open-source library targeting analytics/risk, transaction cost analytics,
  13.  *      asset liability management analytics, capital, exposure, and margin analytics, valuation adjustment
  14.  *      analytics, and portfolio construction analytics within and across fixed income, credit, commodity,
  15.  *      equity, FX, and structured products. It also includes auxiliary libraries for algorithm support,
  16.  *      numerical analysis, numerical optimization, spline builder, model validation, statistical learning,
  17.  *      and computational support.
  18.  *  
  19.  *      https://lakshmidrip.github.io/DROP/
  20.  *  
  21.  *  DROP is composed of three modules:
  22.  *  
  23.  *  - DROP Product Core - https://lakshmidrip.github.io/DROP-Product-Core/
  24.  *  - DROP Portfolio Core - https://lakshmidrip.github.io/DROP-Portfolio-Core/
  25.  *  - DROP Computational Core - https://lakshmidrip.github.io/DROP-Computational-Core/
  26.  *
  27.  *  DROP Product Core implements libraries for the following:
  28.  *  - Fixed Income Analytics
  29.  *  - Loan Analytics
  30.  *  - Transaction Cost Analytics
  31.  *
  32.  *  DROP Portfolio Core implements libraries for the following:
  33.  *  - Asset Allocation Analytics
  34.  *  - Asset Liability Management Analytics
  35.  *  - Capital Estimation Analytics
  36.  *  - Exposure Analytics
  37.  *  - Margin Analytics
  38.  *  - XVA Analytics
  39.  *
  40.  *  DROP Computational Core implements libraries for the following:
  41.  *  - Algorithm Support
  42.  *  - Computation Support
  43.  *  - Function Analysis
  44.  *  - Model Validation
  45.  *  - Numerical Analysis
  46.  *  - Numerical Optimizer
  47.  *  - Spline Builder
  48.  *  - Statistical Learning
  49.  *
  50.  *  Documentation for DROP is Spread Over:
  51.  *
  52.  *  - Main                     => https://lakshmidrip.github.io/DROP/
  53.  *  - Wiki                     => https://github.com/lakshmiDRIP/DROP/wiki
  54.  *  - GitHub                   => https://github.com/lakshmiDRIP/DROP
  55.  *  - Repo Layout Taxonomy     => https://github.com/lakshmiDRIP/DROP/blob/master/Taxonomy.md
  56.  *  - Javadoc                  => https://lakshmidrip.github.io/DROP/Javadoc/index.html
  57.  *  - Technical Specifications => https://github.com/lakshmiDRIP/DROP/tree/master/Docs/Internal
  58.  *  - Release Versions         => https://lakshmidrip.github.io/DROP/version.html
  59.  *  - Community Credits        => https://lakshmidrip.github.io/DROP/credits.html
  60.  *  - Issues Catalog           => https://github.com/lakshmiDRIP/DROP/issues
  61.  *  - JUnit                    => https://lakshmidrip.github.io/DROP/junit/index.html
  62.  *  - Jacoco                   => https://lakshmidrip.github.io/DROP/jacoco/index.html
  63.  *
  64.  *  Licensed under the Apache License, Version 2.0 (the "License");
  65.  *      you may not use this file except in compliance with the License.
  66.  *  
  67.  *  You may obtain a copy of the License at
  68.  *      http://www.apache.org/licenses/LICENSE-2.0
  69.  *  
  70.  *  Unless required by applicable law or agreed to in writing, software
  71.  *      distributed under the License is distributed on an "AS IS" BASIS,
  72.  *      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  73.  *  
  74.  *  See the License for the specific language governing permissions and
  75.  *      limitations under the License.
  76.  */

  77. /**
  78.  * <i>Yylex</i> is an Adaptation of the Yylex Class from the RFC4627 compliant JSON Simple
  79.  * (https://code.google.com/p/json-simple/).
  80.  *
  81.  *  <br><br>
  82.  *  <ul>
  83.  *      <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/NumericalCore.md">Numerical Core Module</a></li>
  84.  *      <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/AlgorithmSupportLibrary.md">Algorithm Support</a></li>
  85.  *      <li><b>Project</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/json">JSON</a></li>
  86.  *      <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/json/parser">Parser</a></li>
  87.  *  </ul>
  88.  *
  89.  * @author Fang Yidong
  90.  * @author Lakshmi Krishnamurthy
  91.  */

  92. public class Yylex {

  93.       /** This character denotes the end of file */
  94.       public static final int YYEOF = -1;

  95.       /** initial size of the lookahead buffer */
  96.       private static final int ZZ_BUFFERSIZE = 16384;

  97.       /** lexical states */
  98.       public static final int YYINITIAL = 0;
  99.       public static final int STRING_BEGIN = 2;

  100.       /**
  101.        * ZZ_LEXSTATE[l] is the state in the DFA for the lexical state l
  102.        * ZZ_LEXSTATE[l+1] is the state in the DFA for the lexical state l
  103.        *                  at the beginning of a line
  104.        * l is of the form l = 2*k, k a non negative integer
  105.        */
  106.       private static final int ZZ_LEXSTATE[] = {
  107.          0,  0,  1, 1
  108.       };

  109.       /**
  110.        * Translates characters to character classes
  111.        */
  112.       private static final String ZZ_CMAP_PACKED =
  113.         "\11\0\1\7\1\7\2\0\1\7\22\0\1\7\1\0\1\11\10\0"+
  114.         "\1\6\1\31\1\2\1\4\1\12\12\3\1\32\6\0\4\1\1\5"+
  115.         "\1\1\24\0\1\27\1\10\1\30\3\0\1\22\1\13\2\1\1\21"+
  116.         "\1\14\5\0\1\23\1\0\1\15\3\0\1\16\1\24\1\17\1\20"+
  117.         "\5\0\1\25\1\0\1\26\uff82\0";

  118.       /**
  119.        * Translates characters to character classes
  120.        */
  121.       private static final char [] ZZ_CMAP = zzUnpackCMap(ZZ_CMAP_PACKED);

  122.       /**
  123.        * Translates DFA states to action switch labels.
  124.        */
  125.       private static final int [] ZZ_ACTION = zzUnpackAction();

  126.       private static final String ZZ_ACTION_PACKED_0 =
  127.         "\2\0\2\1\1\2\1\3\1\4\3\1\1\5\1\6"+
  128.         "\1\7\1\10\1\11\1\12\1\13\1\14\1\15\5\0"+
  129.         "\1\14\1\16\1\17\1\20\1\21\1\22\1\23\1\24"+
  130.         "\1\0\1\25\1\0\1\25\4\0\1\26\1\27\2\0"+
  131.         "\1\30";

  132.       private static int [] zzUnpackAction() {
  133.         int [] result = new int[45];
  134.         int offset = 0;
  135.         offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result);
  136.         return result;
  137.       }

  138.       private static int zzUnpackAction(String packed, int offset, int [] result) {
  139.         int i = 0;       /* index in packed string  */
  140.         int j = offset;  /* index in unpacked array */
  141.         int l = packed.length();
  142.         while (i < l) {
  143.           int count = packed.charAt(i++);
  144.           int value = packed.charAt(i++);
  145.           do result[j++] = value; while (--count > 0);
  146.         }
  147.         return j;
  148.       }


  149.       /**
  150.        * Translates a state to a row index in the transition table
  151.        */
  152.       private static final int [] ZZ_ROWMAP = zzUnpackRowMap();

  153.       private static final String ZZ_ROWMAP_PACKED_0 =
  154.         "\0\0\0\33\0\66\0\121\0\154\0\207\0\66\0\242"+
  155.         "\0\275\0\330\0\66\0\66\0\66\0\66\0\66\0\66"+
  156.         "\0\363\0\u010e\0\66\0\u0129\0\u0144\0\u015f\0\u017a\0\u0195"+
  157.         "\0\66\0\66\0\66\0\66\0\66\0\66\0\66\0\66"+
  158.         "\0\u01b0\0\u01cb\0\u01e6\0\u01e6\0\u0201\0\u021c\0\u0237\0\u0252"+
  159.         "\0\66\0\66\0\u026d\0\u0288\0\66";

  160.       private static int [] zzUnpackRowMap() {
  161.         int [] result = new int[45];
  162.         int offset = 0;
  163.         offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result);
  164.         return result;
  165.       }

  166.       private static int zzUnpackRowMap(String packed, int offset, int [] result) {
  167.         int i = 0;  /* index in packed string  */
  168.         int j = offset;  /* index in unpacked array */
  169.         int l = packed.length();
  170.         while (i < l) {
  171.           int high = packed.charAt(i++) << 16;
  172.           result[j++] = high | packed.charAt(i++);
  173.         }
  174.         return j;
  175.       }

  176.       /**
  177.        * The transition table of the DFA
  178.        */
  179.       private static final int ZZ_TRANS [] = {
  180.         2, 2, 3, 4, 2, 2, 2, 5, 2, 6,
  181.         2, 2, 7, 8, 2, 9, 2, 2, 2, 2,
  182.         2, 10, 11, 12, 13, 14, 15, 16, 16, 16,
  183.         16, 16, 16, 16, 16, 17, 18, 16, 16, 16,
  184.         16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
  185.         16, 16, 16, 16, -1, -1, -1, -1, -1, -1,
  186.         -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  187.         -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  188.         -1, -1, -1, -1, 4, -1, -1, -1, -1, -1,
  189.         -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  190.         -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  191.         -1, 4, 19, 20, -1, -1, -1, -1, -1, -1,
  192.         -1, -1, -1, -1, -1, 20, -1, -1, -1, -1,
  193.         -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  194.         -1, -1, 5, -1, -1, -1, -1, -1, -1, -1,
  195.         -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  196.         -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  197.         -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  198.         21, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  199.         -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  200.         -1, -1, -1, -1, -1, 22, -1, -1, -1, -1,
  201.         -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  202.         -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  203.         23, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  204.         -1, -1, -1, 16, 16, 16, 16, 16, 16, 16,
  205.         16, -1, -1, 16, 16, 16, 16, 16, 16, 16,
  206.         16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
  207.         -1, -1, -1, -1, -1, -1, -1, -1, 24, 25,
  208.         26, 27, 28, 29, 30, 31, 32, -1, -1, -1,
  209.         -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  210.         33, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  211.         -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  212.         -1, -1, -1, -1, -1, -1, 34, 35, -1, -1,
  213.         34, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  214.         -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  215.         -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  216.         -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  217.         36, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  218.         -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  219.         -1, -1, -1, -1, -1, -1, -1, 37, -1, -1,
  220.         -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  221.         -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  222.         -1, 38, -1, -1, -1, -1, -1, -1, -1, -1,
  223.         -1, -1, -1, 39, -1, 39, -1, 39, -1, -1,
  224.         -1, -1, -1, 39, 39, -1, -1, -1, -1, 39,
  225.         39, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  226.         -1, -1, 33, -1, 20, -1, -1, -1, -1, -1,
  227.         -1, -1, -1, -1, -1, -1, 20, -1, -1, -1,
  228.         -1, -1, -1, -1, -1, -1, -1, -1, -1, 35,
  229.         -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  230.         -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  231.         -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  232.         -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  233.         -1, -1, -1, 38, -1, -1, -1, -1, -1, -1,
  234.         -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  235.         -1, -1, -1, -1, -1, -1, -1, -1, -1, 40,
  236.         -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  237.         -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  238.         -1, -1, -1, -1, 41, -1, -1, -1, -1, -1,
  239.         -1, -1, -1, -1, -1, 42, -1, 42, -1, 42,
  240.         -1, -1, -1, -1, -1, 42, 42, -1, -1, -1,
  241.         -1, 42, 42, -1, -1, -1, -1, -1, -1, -1,
  242.         -1, -1, 43, -1, 43, -1, 43, -1, -1, -1,
  243.         -1, -1, 43, 43, -1, -1, -1, -1, 43, 43,
  244.         -1, -1, -1, -1, -1, -1, -1, -1, -1, 44,
  245.         -1, 44, -1, 44, -1, -1, -1, -1, -1, 44,
  246.         44, -1, -1, -1, -1, 44, 44, -1, -1, -1,
  247.         -1, -1, -1, -1, -1,
  248.       };

  249.       /* error codes */
  250.       private static final int ZZ_UNKNOWN_ERROR = 0;
  251.       private static final int ZZ_NO_MATCH = 1;
  252.       private static final int ZZ_PUSHBACK_2BIG = 2;

  253.       /* error messages for the codes above */
  254.       private static final String ZZ_ERROR_MSG[] = {
  255.         "Unkown internal scanner error",
  256.         "Error: could not match input",
  257.         "Error: pushback value was too large"
  258.       };

  259.       /**
  260.        * ZZ_ATTRIBUTE[aState] contains the attributes of state <code>aState</code>
  261.        */
  262.       private static final int [] ZZ_ATTRIBUTE = zzUnpackAttribute();

  263.       private static final String ZZ_ATTRIBUTE_PACKED_0 =
  264.         "\2\0\1\11\3\1\1\11\3\1\6\11\2\1\1\11"+
  265.         "\5\0\10\11\1\0\1\1\1\0\1\1\4\0\2\11"+
  266.         "\2\0\1\11";

  267.       private static int [] zzUnpackAttribute() {
  268.         int [] result = new int[45];
  269.         int offset = 0;
  270.         offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result);
  271.         return result;
  272.       }

  273.       private static int zzUnpackAttribute(String packed, int offset, int [] result) {
  274.         int i = 0;       /* index in packed string  */
  275.         int j = offset;  /* index in unpacked array */
  276.         int l = packed.length();
  277.         while (i < l) {
  278.           int count = packed.charAt(i++);
  279.           int value = packed.charAt(i++);
  280.           do result[j++] = value; while (--count > 0);
  281.         }
  282.         return j;
  283.       }

  284.       /** the input device */
  285.       private java.io.Reader zzReader;

  286.       /** the current state of the DFA */
  287.       private int zzState;

  288.       /** the current lexical state */
  289.       private int zzLexicalState = YYINITIAL;

  290.       /** this buffer contains the current text to be matched and is
  291.           the source of the yytext() string */
  292.       private char zzBuffer[] = new char[ZZ_BUFFERSIZE];

  293.       /** the textposition at the last accepting state */
  294.       private int zzMarkedPos;

  295.       /** the current text position in the buffer */
  296.       private int zzCurrentPos;

  297.       /** startRead marks the beginning of the yytext() string in the buffer */
  298.       private int zzStartRead;

  299.       /** endRead marks the last character in the buffer, that has been read
  300.           from input */
  301.       private int zzEndRead;

  302.       /** number of newlines encountered up to the start of the matched text */
  303.       int yyline;

  304.       /** the number of characters up to the start of the matched text */
  305.       private int yychar;

  306.       /**
  307.        * the number of characters from the last newline up to the start of the
  308.        * matched text
  309.        */
  310.       int yycolumn;

  311.       /**
  312.        * zzAtBOL == true <=> the scanner is currently at the beginning of a line
  313.        */
  314.       boolean zzAtBOL = true;

  315.       /** zzAtEOF == true <=> the scanner is at the EOF */
  316.       private boolean zzAtEOF;

  317.       /* user code: */
  318.     private StringBuffer sb=new StringBuffer();

  319.     int getPosition(){
  320.             return yychar;
  321.     }



  322.       /**
  323.        * Creates a new scanner
  324.        * There is also a java.io.InputStream version of this constructor.
  325.        *
  326.        * @param   in  the java.io.Reader to read input from.
  327.        */
  328.       public Yylex(java.io.Reader in) {
  329.         this.zzReader = in;
  330.       }

  331.       /**
  332.        * Creates a new scanner.
  333.        * There is also java.io.Reader version of this constructor.
  334.        *
  335.        * @param   in  the java.io.Inputstream to read input from.
  336.        */
  337.       Yylex(java.io.InputStream in) {
  338.         this(new java.io.InputStreamReader(in));
  339.       }

  340.       /**
  341.        * Unpacks the compressed character translation table.
  342.        *
  343.        * @param packed   the packed character translation table
  344.        * @return         the unpacked character translation table
  345.        */
  346.       private static char [] zzUnpackCMap(String packed) {
  347.         char [] map = new char[0x10000];
  348.         int i = 0;  /* index in packed string  */
  349.         int j = 0;  /* index in unpacked array */
  350.         while (i < 90) {
  351.           int  count = packed.charAt(i++);
  352.           char value = packed.charAt(i++);
  353.           do map[j++] = value; while (--count > 0);
  354.         }
  355.         return map;
  356.       }


  357.       /**
  358.        * Refills the input buffer.
  359.        *
  360.        * @return      <code>false</code>, iff there was new input.
  361.        *
  362.        * @exception   java.io.IOException  if any I/O-Error occurs
  363.        */
  364.       private boolean zzRefill() throws java.io.IOException {

  365.         /* first: make room (if you can) */
  366.         if (zzStartRead > 0) {
  367.           System.arraycopy(zzBuffer, zzStartRead,
  368.                            zzBuffer, 0,
  369.                            zzEndRead-zzStartRead);

  370.           /* translate stored positions */
  371.           zzEndRead-= zzStartRead;
  372.           zzCurrentPos-= zzStartRead;
  373.           zzMarkedPos-= zzStartRead;
  374.           zzStartRead = 0;
  375.         }

  376.         /* is the buffer big enough? */
  377.         if (zzCurrentPos >= zzBuffer.length) {
  378.           /* if not: blow it up */
  379.           char newBuffer[] = new char[zzCurrentPos*2];
  380.           System.arraycopy(zzBuffer, 0, newBuffer, 0, zzBuffer.length);
  381.           zzBuffer = newBuffer;
  382.         }

  383.         /* finally: fill the buffer with new input */
  384.         int numRead = zzReader.read(zzBuffer, zzEndRead,
  385.                                                 zzBuffer.length-zzEndRead);

  386.         if (numRead > 0) {
  387.           zzEndRead+= numRead;
  388.           return false;
  389.         }
  390.         // unlikely but not impossible: read 0 characters, but not at end of stream    
  391.         if (numRead == 0) {
  392.           int c = zzReader.read();
  393.           if (c == -1) {
  394.             return true;
  395.           } else {
  396.             zzBuffer[zzEndRead++] = (char) c;
  397.             return false;
  398.           }    
  399.         }

  400.             // numRead < 0
  401.         return true;
  402.       }

  403.        
  404.       /**
  405.        * Closes the input stream.
  406.        *
  407.        * @throws java.io.IOException Thrown if the Inputs are Invalid
  408.        */
  409.       public final void yyclose() throws java.io.IOException {
  410.         zzAtEOF = true;            /* indicate end of file */
  411.         zzEndRead = zzStartRead;  /* invalidate buffer    */

  412.         if (zzReader != null)
  413.           zzReader.close();
  414.       }


  415.       /**
  416.        * Resets the scanner to read from a new input stream.
  417.        * Does not close the old reader.
  418.        *
  419.        * All internal variables are reset, the old input stream
  420.        * <b>cannot</b> be reused (internal buffer is discarded and lost).
  421.        *
  422.        * @param reader   the new input stream
  423.        */
  424.       public final void yyreset(java.io.Reader reader) {
  425.         zzReader = reader;
  426.         zzAtBOL  = true;
  427.         zzAtEOF  = false;
  428.         zzEndRead = zzStartRead = 0;
  429.         zzCurrentPos = zzMarkedPos = 0;
  430.         yyline = yychar = yycolumn = 0;
  431.         zzLexicalState = YYINITIAL;
  432.       }


  433.       /**
  434.        * Returns the current lexical state.
  435.        *
  436.        * @return The Current Lexical State.
  437.        */

  438.       public final int yystate() {
  439.         return zzLexicalState;
  440.       }


  441.       /**
  442.        * Enters a new lexical state
  443.        *
  444.        * @param newState the new lexical state
  445.        */
  446.       public final void yybegin(int newState) {
  447.         zzLexicalState = newState;
  448.       }


  449.       /**
  450.        * Returns the text matched by the current regular expression.
  451.        *
  452.        * @return The Text.
  453.        */

  454.       public final String yytext() {
  455.         return new String( zzBuffer, zzStartRead, zzMarkedPos-zzStartRead );
  456.       }


  457.       /**
  458.        * Returns the character at position <b>pos</b> from the
  459.        * matched text.
  460.        *
  461.        * It is equivalent to yytext().charAt(pos), but faster
  462.        *
  463.        * @param pos the position of the character to fetch.
  464.        *            A value from 0 to yylength()-1.
  465.        *
  466.        * @return the character at position pos
  467.        */
  468.       public final char yycharat(int pos) {
  469.         return zzBuffer[zzStartRead+pos];
  470.       }


  471.       /**
  472.        * Returns the length of the matched text region.
  473.        *
  474.        * @return The Length.
  475.        */
  476.       public final int yylength() {
  477.         return zzMarkedPos-zzStartRead;
  478.       }


  479.       /**
  480.        * Reports an error that occured while scanning.
  481.        *
  482.        * In a wellformed scanner (no or only correct usage of
  483.        * yypushback(int) and a match-all fallback rule) this method
  484.        * will only be called with things that "Can't Possibly Happen".
  485.        * If this method is called, something is seriously wrong
  486.        * (e.g. a JFlex bug producing a faulty scanner etc.).
  487.        *
  488.        * Usual syntax/scanner level error handling should be done
  489.        * in error fallback rules.
  490.        *
  491.        * @param   errorCode  the code of the errormessage to display
  492.        */
  493.       private void zzScanError(int errorCode) {
  494.         String message;
  495.         try {
  496.           message = ZZ_ERROR_MSG[errorCode];
  497.         }
  498.         catch (ArrayIndexOutOfBoundsException e) {
  499.           message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR];
  500.         }

  501.         throw new Error(message);
  502.       }


  503.       /**
  504.        * Pushes the specified amount of characters back into the input stream.
  505.        *
  506.        * They will be read again by then next call of the scanning method
  507.        *
  508.        * @param number  the number of characters to be read again.
  509.        *                This number must not be greater than yylength()!
  510.        */
  511.       public void yypushback(int number)  {
  512.         if ( number > yylength() )
  513.           zzScanError(ZZ_PUSHBACK_2BIG);

  514.         zzMarkedPos -= number;
  515.       }


  516.       /**
  517.        * Resumes scanning until the next regular expression is matched,
  518.        * the end of input is encountered or an I/O-Error occurs.
  519.        *
  520.        * @return      the next token
  521.        *
  522.        * @throws   java.io.IOException  if any I/O-Error occurs
  523.        *
  524.        * @throws ParseException Thrown if Inputs are Invalid
  525.        */

  526.       public Yytoken yylex() throws java.io.IOException, ParseException {
  527.         int zzInput;
  528.         int zzAction;

  529.         // cached fields:
  530.         int zzCurrentPosL;
  531.         int zzMarkedPosL;
  532.         int zzEndReadL = zzEndRead;
  533.         char [] zzBufferL = zzBuffer;
  534.         char [] zzCMapL = ZZ_CMAP;

  535.         int [] zzTransL = ZZ_TRANS;
  536.         int [] zzRowMapL = ZZ_ROWMAP;
  537.         int [] zzAttrL = ZZ_ATTRIBUTE;

  538.         while (true) {
  539.           zzMarkedPosL = zzMarkedPos;

  540.           yychar+= zzMarkedPosL-zzStartRead;

  541.           zzAction = -1;

  542.           zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL;
  543.      
  544.           zzState = ZZ_LEXSTATE[zzLexicalState];


  545.           zzForAction: {
  546.             while (true) {
  547.        
  548.               if (zzCurrentPosL < zzEndReadL)
  549.                 zzInput = zzBufferL[zzCurrentPosL++];
  550.               else if (zzAtEOF) {
  551.                 zzInput = YYEOF;
  552.                 break zzForAction;
  553.               }
  554.               else {
  555.                 // store back cached positions
  556.                 zzCurrentPos  = zzCurrentPosL;
  557.                 zzMarkedPos   = zzMarkedPosL;
  558.                 boolean eof = zzRefill();
  559.                 // get translated positions and possibly new buffer
  560.                 zzCurrentPosL  = zzCurrentPos;
  561.                 zzMarkedPosL   = zzMarkedPos;
  562.                 zzBufferL      = zzBuffer;
  563.                 zzEndReadL     = zzEndRead;
  564.                 if (eof) {
  565.                   zzInput = YYEOF;
  566.                   break zzForAction;
  567.                 }
  568.                 else {
  569.                   zzInput = zzBufferL[zzCurrentPosL++];
  570.                 }
  571.               }
  572.               int zzNext = zzTransL[ zzRowMapL[zzState] + zzCMapL[zzInput] ];
  573.               if (zzNext == -1) break zzForAction;
  574.               zzState = zzNext;

  575.               int zzAttributes = zzAttrL[zzState];
  576.               if ( (zzAttributes & 1) == 1 ) {
  577.                 zzAction = zzState;
  578.                 zzMarkedPosL = zzCurrentPosL;
  579.                 if ( (zzAttributes & 8) == 8 ) break zzForAction;
  580.               }

  581.             }
  582.           }

  583.           // store back cached position
  584.           zzMarkedPos = zzMarkedPosL;

  585.           switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) {
  586.             case 11:
  587.               { sb.append(yytext());
  588.               }
  589.             case 25: break;
  590.             case 4:
  591.               { sb.delete(0, sb.length());yybegin(STRING_BEGIN);
  592.               }
  593.             case 26: break;
  594.             case 16:
  595.               { sb.append('\b');
  596.               }
  597.             case 27: break;
  598.             case 6:
  599.               { return new Yytoken(Yytoken.TYPE_RIGHT_BRACE,null);
  600.               }
  601.             case 28: break;
  602.             case 23:
  603.               { Boolean val=Boolean.valueOf(yytext()); return new Yytoken(Yytoken.TYPE_VALUE, val);
  604.               }
  605.             case 29: break;
  606.             case 22:
  607.               { return new Yytoken(Yytoken.TYPE_VALUE, null);
  608.               }
  609.             case 30: break;
  610.             case 13:
  611.               { yybegin(YYINITIAL);return new Yytoken(Yytoken.TYPE_VALUE, sb.toString());
  612.               }
  613.             case 31: break;
  614.             case 12:
  615.               { sb.append('\\');
  616.               }
  617.             case 32: break;
  618.             case 21:
  619.               { Double val=Double.valueOf(yytext()); return new Yytoken(Yytoken.TYPE_VALUE, val);
  620.               }
  621.             case 33: break;
  622.             case 1:
  623.               { throw new ParseException(yychar, ParseException.ERROR_UNEXPECTED_CHAR, yycharat (0));
  624.               }
  625.             case 34: break;
  626.             case 8:
  627.               { return new Yytoken(Yytoken.TYPE_RIGHT_SQUARE,null);
  628.               }
  629.             case 35: break;
  630.             case 19:
  631.               { sb.append('\r');
  632.               }
  633.             case 36: break;
  634.             case 15:
  635.               { sb.append('/');
  636.               }
  637.             case 37: break;
  638.             case 10:
  639.               { return new Yytoken(Yytoken.TYPE_COLON,null);
  640.               }
  641.             case 38: break;
  642.             case 14:
  643.               { sb.append('"');
  644.               }
  645.             case 39: break;
  646.             case 5:
  647.               { return new Yytoken(Yytoken.TYPE_LEFT_BRACE,null);
  648.               }
  649.             case 40: break;
  650.             case 17:
  651.               { sb.append('\f');
  652.               }
  653.             case 41: break;
  654.             case 24:
  655.               { try{
  656.                                                                                                                     int ch=Integer.parseInt(yytext().substring(2),16);
  657.                                                                                                                     sb.append((char)ch);
  658.                                                                                                             }
  659.                                                                                                             catch(Exception e){
  660.                                                                                                                     throw new ParseException(yychar, ParseException.ERROR_UNEXPECTED_EXCEPTION, e);
  661.                                                                                                             }
  662.               }
  663.             case 42: break;
  664.             case 20:
  665.               { sb.append('\t');
  666.               }
  667.             case 43: break;
  668.             case 7:
  669.               { return new Yytoken(Yytoken.TYPE_LEFT_SQUARE,null);
  670.               }
  671.             case 44: break;
  672.             case 2:
  673.               { Long val=Long.valueOf(yytext()); return new Yytoken(Yytoken.TYPE_VALUE, val);
  674.               }
  675.             case 45: break;
  676.             case 18:
  677.               { sb.append('\n');
  678.               }
  679.             case 46: break;
  680.             case 9:
  681.               { return new Yytoken(Yytoken.TYPE_COMMA,null);
  682.               }
  683.             case 47: break;
  684.             case 3:
  685.               {
  686.               }
  687.             case 48: break;
  688.             default:
  689.               if (zzInput == YYEOF && zzStartRead == zzCurrentPos) {
  690.                 zzAtEOF = true;
  691.                 return null;
  692.               }
  693.               else {
  694.                 zzScanError(ZZ_NO_MATCH);
  695.               }
  696.           }
  697.         }
  698.       }
  699.     }