Package edu.mit.csail.sdg.alloy4compiler.parser

Source Code of edu.mit.csail.sdg.alloy4compiler.parser.CompLexer


package edu.mit.csail.sdg.alloy4compiler.parser;

import edu.mit.csail.sdg.alloy4.Err;
import edu.mit.csail.sdg.alloy4.ErrorSyntax;
import edu.mit.csail.sdg.alloy4.Pos;
import edu.mit.csail.sdg.alloy4.Version;
import edu.mit.csail.sdg.alloy4compiler.ast.ExprConstant;
import edu.mit.csail.sdg.alloy4compiler.ast.ExprVar;
import java.util.List;
import java_cup_11a.runtime.*;

/** Autogenerated by JFlex 1.4.1 */


final class CompLexer implements java_cup_11a.runtime.Scanner {

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

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

  /** lexical states */
  public static final int YYINITIAL = 0;

  /**
   * Translates characters to character classes
   */
  private static final String ZZ_CMAP_PACKED =
    "\11\0\1\71\1\64\1\0\1\71\1\70\22\0\1\71\1\1\1\62"+
    "\1\2\1\67\1\0\1\3\1\65\1\4\1\5\1\6\1\7\1\10"+
    "\1\11\1\13\1\14\12\66\1\15\1\0\1\16\1\17\1\12\1\0"+
    "\1\20\10\67\1\56\11\67\1\61\7\67\1\21\1\63\1\22\1\23"+
    "\1\65\1\0\1\30\1\31\1\35\1\40\1\41\1\55\1\60\1\43"+
    "\1\45\1\46\1\44\1\36\1\50\1\37\1\47\1\54\1\57\1\34"+
    "\1\32\1\33\1\42\1\53\1\67\1\51\1\52\1\67\1\24\1\25"+
    "\1\26\1\27\uff81\0";

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

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

  private static final String ZZ_ACTION_PACKED_0 =
    "\1\0\1\1\1\2\1\3\1\4\1\5\1\6\1\7"+
    "\1\10\1\11\1\12\1\13\1\14\1\15\1\16\1\17"+
    "\1\20\1\21\1\22\1\23\1\24\1\25\1\26\1\27"+
    "\1\30\23\31\1\32\1\33\1\34\1\35\1\36\1\33"+
    "\1\37\1\40\1\41\1\0\1\42\1\43\1\44\1\45"+
    "\1\46\1\45\1\20\1\47\1\31\1\50\14\31\1\51"+
    "\5\31\1\52\3\31\1\47\12\31\1\53\1\0\1\54"+
    "\1\55\2\0\1\56\2\31\1\57\1\35\1\60\1\61"+
    "\1\62\1\63\1\64\2\31\1\65\1\31\1\66\1\31"+
    "\1\2\6\31\1\67\2\31\1\70\2\31\1\56\1\71"+
    "\6\31\1\72\1\73\1\74\1\31\1\75\1\0\1\33"+
    "\2\31\1\76\1\77\1\31\1\100\1\101\1\102\1\103"+
    "\1\104\4\31\1\105\1\106\1\31\1\107\1\31\1\110"+
    "\1\111\1\31\1\112\3\31\1\113\13\31\1\114\4\31"+
    "\1\115\1\31\1\116\2\31\1\117\2\31\1\120\1\121"+
    "\1\31\1\46\1\31\1\122\1\123\1\102\3\31\1\110"+
    "\1\67";

  private static int [] zzUnpackAction() {
    int [] result = new int[211];
    int offset = 0;
    offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result);
    return result;
  }

  private static int zzUnpackAction(String packed, int offset, int [] result) {
    int i = 0;       /* index in packed string  */
    int j = offset;  /* index in unpacked array */
    int l = packed.length();
    while (i < l) {
      int count = packed.charAt(i++);
      int value = packed.charAt(i++);
      do result[j++] = value; while (--count > 0);
    }
    return j;
  }


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

  private static final String ZZ_ROWMAP_PACKED_0 =
    "\0\0\0\72\0\72\0\72\0\164\0\72\0\72\0\72"+
    "\0\256\0\72\0\350\0\u0122\0\72\0\u015c\0\u0196\0\u01d0"+
    "\0\u020a\0\72\0\72\0\72\0\72\0\72\0\u0244\0\72"+
    "\0\72\0\u027e\0\u02b8\0\u02f2\0\u032c\0\u0366\0\u03a0\0\u03da"+
    "\0\u0414\0\u044e\0\u0488\0\u04c2\0\u04fc\0\u0536\0\u0570\0\u05aa"+
    "\0\u05e4\0\u061e\0\u0658\0\u0692\0\u06cc\0\72\0\u0706\0\72"+
    "\0\72\0\u0740\0\72\0\u077a\0\72\0\u07b4\0\72\0\72"+
    "\0\72\0\u07ee\0\72\0\72\0\72\0\72\0\u0828\0\u0862"+
    "\0\u089c\0\u08d6\0\u0910\0\u094a\0\u0984\0\u09be\0\u09f8\0\u0a32"+
    "\0\u0a6c\0\u0aa6\0\u0ae0\0\u0b1a\0\u0b54\0\u0b8e\0\u0bc8\0\u0c02"+
    "\0\u0c3c\0\u0c76\0\u0cb0\0\u0cea\0\u0d24\0\u0d5e\0\u04fc\0\u0d98"+
    "\0\u0dd2\0\u0e0c\0\u0e46\0\u0e80\0\u0eba\0\u0ef4\0\u0f2e\0\u0f68"+
    "\0\u0fa2\0\u0fdc\0\u1016\0\u1050\0\72\0\u108a\0\u10c4\0\72"+
    "\0\u10fe\0\u1138\0\u04fc\0\u04fc\0\u04fc\0\u04fc\0\u04fc\0\u04fc"+
    "\0\u04fc\0\u1172\0\u11ac\0\u04fc\0\u11e6\0\u04fc\0\u1220\0\u04fc"+
    "\0\u125a\0\u1294\0\u12ce\0\u1308\0\u1342\0\u137c\0\u13b6\0\u13f0"+
    "\0\u142a\0\u04fc\0\u1464\0\u149e\0\u04fc\0\u04fc\0\u14d8\0\u1512"+
    "\0\u154c\0\u1586\0\u15c0\0\u15fa\0\u04fc\0\u04fc\0\u04fc\0\u1634"+
    "\0\u0fdc\0\u166e\0\u108a\0\u16a8\0\u16e2\0\u04fc\0\u04fc\0\u171c"+
    "\0\u04fc\0\u04fc\0\u1756\0\u04fc\0\u04fc\0\u1790\0\u17ca\0\u1804"+
    "\0\u183e\0\u04fc\0\u04fc\0\u1878\0\u04fc\0\u18b2\0\u18ec\0\u04fc"+
    "\0\u1926\0\u04fc\0\u1960\0\u199a\0\u19d4\0\u04fc\0\u1a0e\0\u1a48"+
    "\0\u1a82\0\u1abc\0\u1af6\0\u1b30\0\u1b6a\0\u1ba4\0\u1bde\0\u1c18"+
    "\0\u1c52\0\u04fc\0\u1c8c\0\u1cc6\0\u1d00\0\u1d3a\0\u04fc\0\u1d74"+
    "\0\u04fc\0\u1dae\0\u1de8\0\u04fc\0\u1e22\0\u1e5c\0\u04fc\0\u04fc"+
    "\0\u1e96\0\u04fc\0\u1ed0\0\u04fc\0\u04fc\0\u04fc\0\u1f0a\0\u1f44"+
    "\0\u1f7e\0\u04fc\0\u04fc";

  private static int [] zzUnpackRowMap() {
    int [] result = new int[211];
    int offset = 0;
    offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result);
    return result;
  }

  private static int zzUnpackRowMap(String packed, int offset, int [] result) {
    int i = 0/* index in packed string  */
    int j = offset;  /* index in unpacked array */
    int l = packed.length();
    while (i < l) {
      int high = packed.charAt(i++) << 16;
      result[j++] = high | packed.charAt(i++);
    }
    return j;
  }

  /**
   * The transition table of the DFA
   */
  private static final int [] ZZ_TRANS = zzUnpackTrans();

  private static final String ZZ_TRANS_PACKED_0 =
    "\1\2\1\3\1\4\1\5\1\6\1\7\1\10\1\11"+
    "\1\12\1\13\1\14\1\15\1\16\1\17\1\20\1\21"+
    "\1\22\1\23\1\24\1\25\1\26\1\27\1\30\1\31"+
    "\1\32\1\33\1\34\1\35\1\36\1\37\1\40\1\41"+
    "\1\42\1\43\1\44\2\45\1\46\1\45\1\47\1\50"+
    "\3\45\1\51\1\52\1\53\2\45\1\54\1\55\1\2"+
    "\1\56\1\2\1\57\1\45\2\56\75\0\1\60\75\0"+
    "\1\61\73\0\1\62\1\63\71\0\1\64\4\0\1\65"+
    "\60\0\1\66\5\0\1\62\67\0\1\67\2\0\1\15"+
    "\71\0\1\70\1\71\1\72\64\0\1\73\3\0\1\74"+
    "\1\75\77\0\1\76\74\0\1\45\1\77\1\100\3\45"+
    "\1\101\1\102\23\45\2\0\3\45\32\0\12\45\1\103"+
    "\20\45\2\0\3\45\32\0\11\45\1\104\1\105\2\45"+
    "\1\106\1\45\1\107\13\45\2\0\3\45\32\0\13\45"+
    "\1\110\17\45\2\0\3\45\32\0\12\45\1\111\20\45"+
    "\2\0\3\45\32\0\13\45\1\112\17\45\2\0\3\45"+
    "\32\0\11\45\1\113\5\45\1\114\13\45\2\0\3\45"+
    "\32\0\17\45\1\115\13\45\2\0\3\45\32\0\15\45"+
    "\1\116\15\45\2\0\3\45\32\0\6\45\1\117\1\120"+
    "\11\45\1\121\11\45\2\0\3\45\32\0\7\45\1\122"+
    "\23\45\2\0\3\45\32\0\33\45\2\0\3\45\32\0"+
    "\7\45\1\123\1\124\7\45\1\125\4\45\1\126\5\45"+
    "\2\0\3\45\32\0\4\45\1\127\2\45\1\130\14\45"+
    "\1\131\6\45\2\0\3\45\32\0\17\45\1\132\13\45"+
    "\2\0\3\45\32\0\1\133\3\45\1\134\26\45\2\0"+
    "\3\45\32\0\1\135\11\45\1\136\4\45\1\137\13\45"+
    "\2\0\3\45\32\0\7\45\1\140\23\45\2\0\3\45"+
    "\32\0\3\45\1\141\27\45\2\0\3\45\2\0\62\55"+
    "\1\142\1\143\6\55\30\0\33\144\2\0\1\144\1\57"+
    "\1\144\2\0\64\62\1\56\3\62\1\56\1\62\12\0"+
    "\1\145\57\0\6\146\1\147\63\146\12\0\1\150\107\0"+
    "\2\45\1\151\30\45\2\0\3\45\32\0\2\45\1\152"+
    "\30\45\2\0\3\45\32\0\6\45\1\153\24\45\2\0"+
    "\3\45\32\0\10\45\1\154\22\45\2\0\3\45\32\0"+
    "\3\45\1\155\27\45\2\0\3\45\32\0\3\45\1\156"+
    "\23\45\1\157\3\45\2\0\3\45\32\0\20\45\1\160"+
    "\12\45\2\0\3\45\32\0\30\45\1\161\2\45\2\0"+
    "\3\45\32\0\20\45\1\162\12\45\2\0\3\45\32\0"+
    "\15\45\1\163\15\45\2\0\3\45\32\0\7\45\1\164"+
    "\23\45\2\0\3\45\32\0\11\45\1\165\21\45\2\0"+
    "\3\45\32\0\3\45\1\166\27\45\2\0\3\45\32\0"+
    "\7\45\1\167\23\45\2\0\3\45\32\0\3\45\1\170"+
    "\3\45\1\171\23\45\2\0\3\45\32\0\2\45\1\172"+
    "\30\45\2\0\3\45\32\0\2\45\1\173\30\45\2\0"+
    "\3\45\32\0\12\45\1\174\20\45\2\0\3\45\32\0"+
    "\1\175\2\45\1\176\7\45\1\177\10\45\1\200\6\45"+
    "\2\0\3\45\32\0\15\45\1\201\15\45\2\0\3\45"+
    "\32\0\3\45\1\202\27\45\2\0\3\45\32\0\11\45"+
    "\1\203\21\45\2\0\3\45\32\0\24\45\1\204\6\45"+
    "\2\0\3\45\32\0\25\45\1\205\5\45\2\0\3\45"+
    "\32\0\11\45\1\206\21\45\2\0\3\45\32\0\11\45"+
    "\1\207\21\45\2\0\3\45\32\0\10\45\1\210\22\45"+
    "\2\0\3\45\32\0\4\45\1\211\26\45\2\0\3\45"+
    "\32\0\11\45\1\212\3\45\1\213\15\45\2\0\3\45"+
    "\32\0\5\45\1\214\25\45\2\0\3\45\32\0\7\45"+
    "\1\215\23\45\2\0\3\45\32\0\4\45\1\216\26\45"+
    "\2\0\3\45\32\0\3\45\1\217\27\45\2\0\3\45"+
    "\32\0\4\45\1\220\26\45\2\0\3\45\32\0\33\221"+
    "\2\0\3\221\2\0\64\55\1\0\5\55\30\0\33\144"+
    "\2\0\3\144\2\0\6\146\1\222\71\146\1\222\5\146"+
    "\1\223\55\146\30\0\3\45\1\224\27\45\2\0\3\45"+
    "\32\0\11\45\1\225\21\45\2\0\3\45\32\0\11\45"+
    "\1\226\21\45\2\0\3\45\32\0\2\45\1\227\30\45"+
    "\2\0\3\45\32\0\5\45\1\230\25\45\2\0\3\45"+
    "\32\0\11\45\1\231\21\45\2\0\3\45\32\0\11\45"+
    "\1\232\21\45\2\0\3\45\32\0\16\45\1\233\14\45"+
    "\2\0\3\45\32\0\11\45\1\234\21\45\2\0\3\45"+
    "\32\0\20\45\1\235\12\45\2\0\3\45\32\0\5\45"+
    "\1\236\25\45\2\0\3\45\32\0\11\45\1\237\21\45"+
    "\2\0\3\45\32\0\1\240\32\45\2\0\3\45\32\0"+
    "\11\45\1\241\21\45\2\0\3\45\32\0\23\45\1\242"+
    "\7\45\2\0\3\45\32\0\7\45\1\243\23\45\2\0"+
    "\3\45\32\0\6\45\1\244\24\45\2\0\3\45\32\0"+
    "\7\45\1\245\23\45\2\0\3\45\32\0\12\45\1\246"+
    "\20\45\2\0\3\45\32\0\3\45\1\247\27\45\2\0"+
    "\3\45\32\0\10\45\1\250\22\45\2\0\3\45\32\0"+
    "\23\45\1\251\7\45\2\0\3\45\32\0\3\45\1\252"+
    "\27\45\2\0\3\45\32\0\15\45\1\253\15\45\2\0"+
    "\3\45\2\0\6\146\1\222\5\146\1\56\55\146\30\0"+
    "\4\45\1\254\26\45\2\0\3\45\32\0\4\45\1\255"+
    "\26\45\2\0\3\45\32\0\14\45\1\256\16\45\2\0"+
    "\3\45\32\0\17\45\1\257\13\45\2\0\3\45\32\0"+
    "\3\45\1\260\27\45\2\0\3\45\32\0\7\45\1\261"+
    "\23\45\2\0\3\45\32\0\12\45\1\262\20\45\2\0"+
    "\3\45\32\0\5\45\1\263\25\45\2\0\3\45\32\0"+
    "\15\45\1\264\15\45\2\0\3\45\32\0\6\45\1\265"+
    "\24\45\2\0\3\45\32\0\15\45\1\266\15\45\2\0"+
    "\3\45\32\0\1\267\32\45\2\0\3\45\32\0\7\45"+
    "\1\270\23\45\2\0\3\45\32\0\1\271\32\45\2\0"+
    "\3\45\32\0\3\45\1\272\27\45\2\0\3\45\32\0"+
    "\15\45\1\273\15\45\2\0\3\45\32\0\6\45\1\274"+
    "\24\45\2\0\3\45\32\0\10\45\1\275\22\45\2\0"+
    "\3\45\32\0\2\45\1\276\30\45\2\0\3\45\32\0"+
    "\3\45\1\277\27\45\2\0\3\45\32\0\11\45\1\300"+
    "\21\45\2\0\3\45\32\0\11\45\1\301\21\45\2\0"+
    "\3\45\32\0\3\45\1\302\27\45\2\0\3\45\32\0"+
    "\3\45\1\303\27\45\2\0\3\45\32\0\30\45\1\304"+
    "\2\45\2\0\3\45\32\0\5\45\1\305\25\45\2\0"+
    "\3\45\32\0\7\45\1\306\23\45\2\0\3\45\32\0"+
    "\22\45\1\307\10\45\2\0\3\45\32\0\2\45\1\310"+
    "\30\45\2\0\3\45\32\0\3\45\1\311\27\45\2\0"+
    "\3\45\32\0\2\45\1\312\30\45\2\0\3\45\32\0"+
    "\15\45\1\313\15\45\2\0\3\45\32\0\11\45\1\314"+
    "\21\45\2\0\3\45\32\0\3\45\1\315\27\45\2\0"+
    "\3\45\32\0\3\45\1\316\27\45\2\0\3\45\32\0"+
    "\15\45\1\317\15\45\2\0\3\45\32\0\17\45\1\320"+
    "\13\45\2\0\3\45\32\0\23\45\1\321\7\45\2\0"+
    "\3\45\32\0\7\45\1\322\23\45\2\0\3\45\32\0"+
    "\11\45\1\323\21\45\2\0\3\45\2\0";

  private static int [] zzUnpackTrans() {
    int [] result = new int[8120];
    int offset = 0;
    offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result);
    return result;
  }

  private static int zzUnpackTrans(String packed, int offset, int [] result) {
    int i = 0;       /* index in packed string  */
    int j = offset;  /* index in unpacked array */
    int l = packed.length();
    while (i < l) {
      int count = packed.charAt(i++);
      int value = packed.charAt(i++);
      value--;
      do result[j++] = value; while (--count > 0);
    }
    return j;
  }


  /* error codes */
  private static final int ZZ_UNKNOWN_ERROR = 0;
  private static final int ZZ_NO_MATCH = 1;
  private static final int ZZ_PUSHBACK_2BIG = 2;

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

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

  private static final String ZZ_ATTRIBUTE_PACKED_0 =
    "\1\0\3\11\1\1\3\11\1\1\1\11\2\1\1\11"+
    "\4\1\5\11\1\1\2\11\24\1\1\11\1\1\2\11"+
    "\1\1\1\11\1\1\1\11\1\0\3\11\1\1\4\11"+
    "\44\1\1\0\1\1\1\11\2\0\1\11\51\1\1\0"+
    "\101\1";

  private static int [] zzUnpackAttribute() {
    int [] result = new int[211];
    int offset = 0;
    offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result);
    return result;
  }

  private static int zzUnpackAttribute(String packed, int offset, int [] result) {
    int i = 0;       /* index in packed string  */
    int j = offset;  /* index in unpacked array */
    int l = packed.length();
    while (i < l) {
      int count = packed.charAt(i++);
      int value = packed.charAt(i++);
      do result[j++] = value; while (--count > 0);
    }
    return j;
  }

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

  /** the current state of the DFA */
  private int zzState;

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

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

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

  /** the textposition at the last state to be included in yytext */
  private int zzPushbackPos;

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

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

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

  /** number of newlines encountered up to the start of the matched text */
  private int yyline;

  /** the number of characters up to the start of the matched text */

  /**
   * the number of characters from the last newline up to the start of the
   * matched text
   */
  private int yycolumn;

  /**
   * zzAtBOL == true <=> the scanner is currently at the beginning of a line
   */

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

  /** denotes if the user-EOF-code has already been executed */
  private boolean zzEOFDone;

  /* user code: */
public String alloy_filename="";
public int alloy_lineoffset=0; // If not zero, it is added to the current LINE NUMBER
public List<Object> alloy_seenDollar;
public CompModule alloy_module;
private final Pos alloy_here(String txt) {
    return new Pos(alloy_filename,yycolumn+1,yyline+1+alloy_lineoffset,yycolumn+txt.length(),yyline+1);
}
private final Symbol alloy_sym(String txt, int type) {
    Pos p = alloy_here(txt); return new Symbol(type, p, p);
}
private final Symbol alloy_string(String txt) throws Err {
    Pos p = alloy_here(txt);
    if (!Version.experimental) throw new ErrorSyntax(p, "String literal is not currently supported.");
    StringBuilder sb = new StringBuilder(txt.length());
    for(int i=0; i<txt.length(); i++) {
       char c = txt.charAt(i);
       if (c=='\r' || c=='\n') throw new ErrorSyntax(p, "String literal cannot span multiple lines; use \\n instead.");
       if (c=='\\') {
          i++;
          if (i>=txt.length()) throw new ErrorSyntax(p, "String literal cannot end with a single \\");
          c = txt.charAt(i);
          if (c=='n') c='\n'; else if (c!='\'' && c!='\"' && c!='\\') throw new ErrorSyntax(p, "String literal currenty only supports\nfour escape sequences: \\\\, \\n, \\\', and \\\"");
       }
       sb.append(c);
    }
    txt = sb.toString();
    if (txt.length()==2) throw new ErrorSyntax(p, "Empty string is not allowed; try rewriting your model to use an empty set instead.");
    return new Symbol(CompSym.STR, p, ExprConstant.Op.STRING.make(p, txt));
}
private final Symbol alloy_id(String txt) throws Err {
    Pos p=alloy_here(txt);
    if (alloy_seenDollar.size()==0 && txt.indexOf('$')>=0) alloy_seenDollar.add(null);
    return new Symbol(CompSym.ID, p, ExprVar.make(p,txt));
}
private final Symbol alloy_num(String txt) throws Err {
    Pos p=alloy_here(txt);
    int n=0;
    try {
       n=Integer.parseInt(txt);
    } catch(NumberFormatException ex) {
       throw new ErrorSyntax(p, "The number "+txt+" is too large to be stored in a Java integer");
    }
    return new Symbol(CompSym.NUMBER, p, ExprConstant.Op.NUMBER.make(p, n));
}


  /**
   * Creates a new scanner
   * There is also a java.io.InputStream version of this constructor.
   *
   * @param   in  the java.io.Reader to read input from.
   */
  public CompLexer(java.io.Reader in) {
    this.zzReader = in;
  }

  /**
   * Creates a new scanner.
   * There is also java.io.Reader version of this constructor.
   *
   * @param   in  the java.io.Inputstream to read input from.
   */
  public CompLexer(java.io.InputStream in) {
    this(new java.io.InputStreamReader(in));
  }

  /**
   * Unpacks the compressed character translation table.
   *
   * @param packed   the packed character translation table
   * @return         the unpacked character translation table
   */
  private static char [] zzUnpackCMap(String packed) {
    char [] map = new char[0x10000];
    int i = 0/* index in packed string  */
    int j = 0/* index in unpacked array */
    while (i < 146) {
      int  count = packed.charAt(i++);
      char value = packed.charAt(i++);
      do map[j++] = value; while (--count > 0);
    }
    return map;
  }


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

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

      /* translate stored positions */
      zzEndRead-= zzStartRead;
      zzCurrentPos-= zzStartRead;
      zzMarkedPos-= zzStartRead;
      zzPushbackPos-= zzStartRead;
      zzStartRead = 0;
    }

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

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

    if (numRead < 0) {
      return true;
    }
    else {
      zzEndRead+= numRead;
      return false;
    }
  }


  /**
   * Closes the input stream.
   */
  public final void yyclose() throws java.io.IOException {
    zzAtEOF = true;            /* indicate end of file */
    zzEndRead = zzStartRead;  /* invalidate buffer    */

    if (zzReader != null)
      zzReader.close();
  }


  /**
   * Resets the scanner to read from a new input stream.
   * Does not close the old reader.
   *
   * All internal variables are reset, the old input stream
   * <b>cannot</b> be reused (internal buffer is discarded and lost).
   * Lexical state is set to <tt>ZZ_INITIAL</tt>.
   *
   * @param reader   the new input stream
   */
  public final void yyreset(java.io.Reader reader) {
    zzReader = reader;
    zzAtEOF  = false;
    zzEndRead = zzStartRead = 0;
    zzCurrentPos = zzMarkedPos = zzPushbackPos = 0;
yyline=yycolumn=0;
    zzLexicalState = YYINITIAL;
  }


  /**
   * Returns the current lexical state.
   */
  public final int yystate() {
    return zzLexicalState;
  }


  /**
   * Enters a new lexical state
   *
   * @param newState the new lexical state
   */
  public final void yybegin(int newState) {
    zzLexicalState = newState;
  }


  /**
   * Returns the text matched by the current regular expression.
   */
  public final String yytext() {
    return new String( zzBuffer, zzStartRead, zzMarkedPos-zzStartRead );
  }


  /**
   * Returns the character at position <tt>pos</tt> from the
   * matched text.
   *
   * It is equivalent to yytext().charAt(pos), but faster
   *
   * @param pos the position of the character to fetch.
   *            A value from 0 to yylength()-1.
   *
   * @return the character at position pos
   */
  public final char yycharat(int pos) {
    return zzBuffer[zzStartRead+pos];
  }


  /**
   * Returns the length of the matched text region.
   */
  public final int yylength() {
    return zzMarkedPos-zzStartRead;
  }


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

    throw new Error(message);
  }


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

    zzMarkedPos -= number;
  }


  /**
   * Contains user EOF-code, which will be executed exactly once,
   * when the end of file is reached
   */
  private void zzDoEOF() throws java.io.IOException {
    if (!zzEOFDone) {
      zzEOFDone = true;
      yyclose();
    }
  }


  /**
   * Resumes scanning until the next regular expression is matched,
   * the end of input is encountered or an I/O-Error occurs.
   *
   * @return      the next token
   * @exception   java.io.IOException  if any I/O-Error occurs
   */
  public java_cup_11a.runtime.Symbol next_token() throws java.io.IOException,Err  {
    int zzInput;
    int zzAction;

    int zzCurrentPosL;
    int zzMarkedPosL;
    int zzEndReadL = zzEndRead;
    char [] zzBufferL = zzBuffer;
    char [] zzCMapL = ZZ_CMAP;

    int [] zzTransL = ZZ_TRANS;
    int [] zzRowMapL = ZZ_ROWMAP;
    int [] zzAttrL = ZZ_ATTRIBUTE;

    while (true) {
      zzMarkedPosL = zzMarkedPos;

      boolean zzR = false;
      for (zzCurrentPosL = zzStartRead; zzCurrentPosL < zzMarkedPosL;
                                                             zzCurrentPosL++) {
        switch (zzBufferL[zzCurrentPosL]) {
        case '\u000B':
        case '\u000C':
        case '\u0085':
        case '\u2028':
        case '\u2029':
          yyline++;
          yycolumn = 0;
          zzR = false;
          break;
        case '\r':
          yyline++;
          yycolumn = 0;
          zzR = true;
          break;
        case '\n':
          if (zzR)
            zzR = false;
          else {
            yyline++;
            yycolumn = 0;
          }
          break;
        default:
          zzR = false;
          yycolumn++;
        }
      }

      if (zzR) {
        boolean zzPeek;
        if (zzMarkedPosL < zzEndReadL)
          zzPeek = zzBufferL[zzMarkedPosL] == '\n';
        else if (zzAtEOF)
          zzPeek = false;
        else {
          boolean eof = zzRefill();
          zzEndReadL = zzEndRead;
          zzMarkedPosL = zzMarkedPos;
          zzBufferL = zzBuffer;
          if (eof)
            zzPeek = false;
          else
            zzPeek = zzBufferL[zzMarkedPosL] == '\n';
        }
        if (zzPeek) yyline--;
      }
      zzAction = -1;

      zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL;

      zzState = zzLexicalState;


      zzForAction: {
        while (true) {

          if (zzCurrentPosL < zzEndReadL)
            zzInput = zzBufferL[zzCurrentPosL++];
          else if (zzAtEOF) {
            zzInput = YYEOF;
            break zzForAction;
          }
          else {
            zzCurrentPos  = zzCurrentPosL;
            zzMarkedPos   = zzMarkedPosL;
            boolean eof = zzRefill();
            zzCurrentPosL  = zzCurrentPos;
            zzMarkedPosL   = zzMarkedPos;
            zzBufferL      = zzBuffer;
            zzEndReadL     = zzEndRead;
            if (eof) {
              zzInput = YYEOF;
              break zzForAction;
            }
            else {
              zzInput = zzBufferL[zzCurrentPosL++];
            }
          }
          int zzNext = zzTransL[ zzRowMapL[zzState] + zzCMapL[zzInput] ];
          if (zzNext == -1) break zzForAction;
          zzState = zzNext;

          int zzAttributes = zzAttrL[zzState];
          if ( (zzAttributes & 1) == 1 ) {
            zzAction = zzState;
            zzMarkedPosL = zzCurrentPosL;
            if ( (zzAttributes & 8) == 8 ) break zzForAction;
          }

        }
      }

      zzMarkedPos = zzMarkedPosL;

      switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) {
        case 4:
          { return alloy_sym(yytext(), CompSym.AMPERSAND   );
          }
        case 84: break;
        case 50:
          { return alloy_sym(yytext(), CompSym.SEQ         );
          }
        case 85: break;
        case 38:
          { return alloy_sym(yytext(), CompSym.IMPLIES     );
          }
        case 86: break;
        case 23:
          { return alloy_sym(yytext(), CompSym.RBRACE      );
          }
        case 87: break;
        case 80:
          { return alloy_sym(yytext(), CompSym.EXACTLY     );
          }
        case 88: break;
        case 53:
          { return alloy_sym(yytext(), CompSym.RUN         );
          }
        case 89: break;
        case 36:
          { return alloy_sym(yytext(), CompSym.SHL         );
          }
        case 90: break;
        case 35:
          { return alloy_sym(yytext(), CompSym.DOMAIN      );
          }
        case 91: break;
        case 60:
          { return alloy_sym(yytext(), CompSym.SIGINT      );
          }
        case 92: break;
        case 24:
          { return alloy_sym(yytext(), CompSym.TILDE       );
          }
        case 93: break;
        case 21:
          { return alloy_sym(yytext(), CompSym.LBRACE      );
          }
        case 94: break;
        case 7:
          { return alloy_sym(yytext(), CompSym.STAR        );
          }
        case 95: break;
        case 30:
          { return alloy_sym(yytext(), CompSym.PLUSPLUS    );
          }
        case 96: break;
        case 58:
          { return alloy_sym(yytext(), CompSym.FUN         );
          }
        case 97: break;
        case 79:
          { return alloy_sym(yytext(), CompSym.STRING      );
          }
        case 98: break;
        case 55:
          { return alloy_sym(yytext(), CompSym.EXH         );
          }
        case 99: break;
        case 56:
          { return alloy_sym(yytext(), CompSym.INT         );
          }
        case 100: break;
        case 52:
          { return alloy_sym(yytext(), CompSym.SIG         );
          }
        case 101: break;
        case 73:
          { return alloy_sym(yytext(), CompSym.PRED        );
          }
        case 102: break;
        case 25:
          { return alloy_id  (yytext());
          }
        case 103: break;
        case 64:
          { return alloy_sym(yytext(), CompSym.LONE        );
          }
        case 104: break;
        case 41:
          { return alloy_sym(yytext(), CompSym.NO          );
          }
        case 105: break;
        case 9:
          { return alloy_sym(yytext(), CompSym.COMMA       );
          }
        case 106: break;
        case 40:
          { return alloy_sym(yytext(), CompSym.AS          );
          }
        case 107: break;
        case 63:
          { return alloy_sym(yytext(), CompSym.THIS        );
          }
        case 108: break;
        case 13:
          { return alloy_sym(yytext(), CompSym.SLASH       );
          }
        case 109: break;
        case 48:
          { return alloy_sym(yytext(), CompSym.BUT         );
          }
        case 110: break;
        case 43:
          { return alloy_string(yytext());
          }
        case 111: break;
        case 66:
          { return alloy_sym(yytext(), CompSym.DISJ        );
          }
        case 112: break;
        case 32:
          { return alloy_sym(yytext(), CompSym.SHA         );
          }
        case 113: break;
        case 39:
          { return alloy_sym(yytext(), CompSym.OR          );
          }
        case 114: break;
        case 45:
          { return alloy_sym(yytext(), CompSym.SHR         );
          }
        case 115: break;
        case 82:
          { return alloy_sym(yytext(), CompSym.PRIVATE     );
          }
        case 116: break;
        case 31:
          { return alloy_sym(yytext(), CompSym.ARROW       );
          }
        case 117: break;
        case 33:
          { return alloy_sym(yytext(), CompSym.GTE         );
          }
        case 118: break;
        case 20:
          { return alloy_sym(yytext(), CompSym.CARET       );
          }
        case 119: break;
        case 46:
          { return alloy_sym(yytext(), CompSym.IFF         );
          }
        case 120: break;
        case 67:
          { return alloy_sym(yytext(), CompSym.ELSE        );
          }
        case 121: break;
        case 3:
          { return alloy_sym(yytext(), CompSym.HASH        );
          }
        case 122: break;
        case 12:
          { return alloy_sym(yytext(), CompSym.DOT         );
          }
        case 123: break;
        case 22:
          { return alloy_sym(yytext(), CompSym.BAR         );
          }
        case 124: break;
        case 77:
          { return alloy_sym(yytext(), CompSym.EXPECT      );
          }
        case 125: break;
        case 8:
          { return alloy_sym(yytext(), CompSym.PLUS        );
          }
        case 126: break;
        case 37:
          { return alloy_sym(yytext(), CompSym.LTE         );
          }
        case 127: break;
        case 57:
          { return alloy_sym(yytext(), CompSym.ONE         );
          }
        case 128: break;
        case 71:
          { return alloy_sym(yytext(), CompSym.OPEN        );
          }
        case 129: break;
        case 11:
          { return alloy_sym(yytext(), CompSym.GT          );
          }
        case 130: break;
        case 78:
          { return alloy_sym(yytext(), CompSym.MODULE      );
          }
        case 131: break;
        case 14:
          { return alloy_sym(yytext(), CompSym.COLON       );
          }
        case 132: break;
        case 51:
          { return alloy_sym(yytext(), CompSym.SUM         );
          }
        case 133: break;
        case 72:
          { return alloy_sym(yytext(), CompSym.PART        );
          }
        case 134: break;
        case 16:
          { return alloy_sym(yytext(), CompSym.EQUALS      );
          }
        case 135: break;
        case 81:
          { return alloy_sym(yytext(), CompSym.EXTENDS     );
          }
        case 136: break;
        case 1:
          { throw new ErrorSyntax(alloy_here(" "), "Syntax error at the "+yytext()+" character.");
          }
        case 137: break;
        case 26:
          { throw new ErrorSyntax(alloy_here(yytext()),"String literal is missing its closing \" character");
          }
        case 138: break;
        case 59:
          { return alloy_sym(yytext(), CompSym.FOR         );
          }
        case 139: break;
        case 28:
          { return alloy_num (yytext());
          }
        case 140: break;
        case 70:
          { return alloy_sym(yytext(), CompSym.IDEN        );
          }
        case 141: break;
        case 15:
          { return alloy_sym(yytext(), CompSym.LT          );
          }
        case 142: break;
        case 17:
          { return alloy_sym(yytext(), CompSym.AT          );
          }
        case 143: break;
        case 34:
          { return alloy_sym(yytext(), CompSym.RANGE       );
          }
        case 144: break;
        case 69:
          { return alloy_sym(yytext(), CompSym.UNIV        );
          }
        case 145: break;
        case 2:
          { return alloy_sym(yytext(), CompSym.NOT         );
          }
        case 146: break;
        case 49:
          { return alloy_sym(yytext(), CompSym.SET         );
          }
        case 147: break;
        case 6:
          { return alloy_sym(yytext(), CompSym.RPAREN      );
          }
        case 148: break;
        case 42:
          { return alloy_sym(yytext(), CompSym.IN          );
          }
        case 149: break;
        case 75:
          { return alloy_sym(yytext(), CompSym.CHECK       );
          }
        case 150: break;
        case 29:
          { return alloy_sym(yytext(), CompSym.AND         );
          }
        case 151: break;
        case 62:
          { return alloy_sym(yytext(), CompSym.SOME        );
          }
        case 152: break;
        case 74:
          { return alloy_sym(yytext(), CompSym.FACT        );
          }
        case 153: break;
        case 10:
          { return alloy_sym(yytext(), CompSym.MINUS       );
          }
        case 154: break;
        case 5:
          { return alloy_sym(yytext(), CompSym.LPAREN      );
          }
        case 155: break;
        case 65:
          { return alloy_sym(yytext(), CompSym.NONE        );
          }
        case 156: break;
        case 18:
          { return alloy_sym(yytext(), CompSym.LBRACKET    );
          }
        case 157: break;
        case 19:
          { return alloy_sym(yytext(), CompSym.RBRACKET    );
          }
        case 158: break;
        case 68:
          { return alloy_sym(yytext(), CompSym.ENUM        );
          }
        case 159: break;
        case 47:
          { return alloy_sym(yytext(), CompSym.ALL         );
          }
        case 160: break;
        case 83:
          { return alloy_sym(yytext(), CompSym.ABSTRACT    );
          }
        case 161: break;
        case 76:
          { return alloy_sym(yytext(), CompSym.ASSERT      );
          }
        case 162: break;
        case 61:
          { throw new ErrorSyntax(alloy_here(yytext()),"String literal cannot be followed by a legal identifier character.");
          }
        case 163: break;
        case 54:
          { return alloy_sym(yytext(), CompSym.LET         );
          }
        case 164: break;
        case 27:
          {
          }
        case 165: break;
        case 44:
          { throw new ErrorSyntax(alloy_here(yytext()),"Name cannot start with a number.");
          }
        case 166: break;
        default:
          if (zzInput == YYEOF && zzStartRead == zzCurrentPos) {
            zzAtEOF = true;
            zzDoEOF();
              {   return new Symbol(CompSym.EOF, alloy_here(" "), alloy_here(" "));
}
          }
          else {
            zzScanError(ZZ_NO_MATCH);
          }
      }
    }
  }


}
TOP

Related Classes of edu.mit.csail.sdg.alloy4compiler.parser.CompLexer

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.