⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 minijool.java

📁 SkipOOMiniJOOL教学语言的编译器前端
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* The following code was generated by JFlex 1.4.1 on 07-6-20 上午3:52 */

package edu.ustc.cs.minijool.lexer;
/**
 * This class is a scanner generated by 
 * <a href="http://www.jflex.de/">JFlex</a> 1.4.1
 * on 07-6-20 上午3:52 from the specification file
 * <tt>D:/workspace/Lab2/JFlex/MiniJOOL.flex</tt>
 */
public class MiniJOOL {

  /** 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 char [] ZZ_CMAP = {
     0,  0,  0,  0,  0,  0,  0,  0,  0,  5,  2,  0,  2,  2,  0,  0, 
     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 
     3, 24,  1,  9,  9, 16, 25, 12, 17, 18,  6, 14, 21, 15, 23,  4, 
     8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  9, 13, 27, 22, 28,  9, 
     9,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7, 
     7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  9, 10,  9,  9,  9, 
     9, 31, 46, 29, 38, 39, 11,  7, 44, 34,  7,  7, 30,  7, 35, 37, 
    41,  7, 42, 32, 33, 45, 36, 43, 40,  7,  7, 19, 26, 20,  9,  0
  };

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

  private static final String ZZ_ACTION_PACKED_0 =
    "\1\0\2\1\1\2\1\3\1\4\1\5\1\6\1\5"+
    "\1\7\1\10\1\11\1\12\1\13\1\14\1\15\1\16"+
    "\1\17\1\20\1\21\1\22\2\1\1\23\1\24\13\5"+
    "\1\25\2\0\1\2\1\0\1\26\1\27\1\5\1\30"+
    "\1\31\1\32\1\33\1\34\1\35\1\36\1\37\1\40"+
    "\1\41\1\42\4\5\1\43\12\5\1\0\1\5\1\44"+
    "\1\45\4\5\1\46\1\47\10\5\1\2\2\5\1\50"+
    "\1\51\1\52\1\53\1\54\5\5\1\55\2\5\1\56"+
    "\1\5\1\57\1\5\1\60\2\5\1\61\1\62";

  private static int [] zzUnpackAction() {
    int [] result = new int[113];
    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\57\0\136\0\57\0\215\0\274\0\353\0\u011a"+
    "\0\u0149\0\57\0\u0178\0\u01a7\0\u01d6\0\57\0\57\0\57"+
    "\0\57\0\57\0\u0205\0\57\0\u0234\0\u0263\0\u0292\0\u02c1"+
    "\0\u02f0\0\u031f\0\u034e\0\u037d\0\u03ac\0\u03db\0\u040a\0\u0439"+
    "\0\u0468\0\u0497\0\u04c6\0\u04f5\0\57\0\136\0\u0524\0\u0553"+
    "\0\u0582\0\57\0\57\0\u05b1\0\57\0\57\0\57\0\57"+
    "\0\57\0\57\0\57\0\57\0\u05e0\0\57\0\u060f\0\u063e"+
    "\0\u066d\0\u069c\0\u06cb\0\353\0\u06fa\0\u0729\0\u0758\0\u0787"+
    "\0\u07b6\0\u07e5\0\u0814\0\u0843\0\u0872\0\u08a1\0\u08d0\0\u08ff"+
    "\0\57\0\57\0\u092e\0\u095d\0\u098c\0\u09bb\0\353\0\353"+
    "\0\u09ea\0\u0a19\0\u0a48\0\u0a77\0\u0aa6\0\u0ad5\0\u0b04\0\u0b33"+
    "\0\u0582\0\u0b62\0\u0b91\0\353\0\353\0\353\0\353\0\353"+
    "\0\u0bc0\0\u0bef\0\u0c1e\0\u0c4d\0\u0c7c\0\353\0\u0cab\0\u0cda"+
    "\0\353\0\u0d09\0\353\0\u0d38\0\353\0\u0d67\0\u0d96\0\353"+
    "\0\353";

  private static int [] zzUnpackRowMap() {
    int [] result = new int[113];
    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\2\4\1\5\1\4\1\6\1\7\1\10"+
    "\2\2\1\11\1\2\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\2\7\1\33\1\34\1\35"+
    "\1\36\1\37\2\7\1\40\1\7\1\41\1\42\1\43"+
    "\2\7\1\44\60\0\1\45\1\0\2\46\1\0\4\46"+
    "\1\47\44\46\4\0\1\50\1\0\1\51\17\0\1\52"+
    "\56\0\1\53\37\0\2\7\2\0\1\7\21\0\22\7"+
    "\10\0\1\10\55\0\2\7\2\0\1\7\21\0\2\7"+
    "\1\54\17\7\26\0\1\55\56\0\1\56\56\0\1\57"+
    "\56\0\1\60\56\0\1\61\61\0\1\62\57\0\1\63"+
    "\52\0\1\64\4\0\1\65\51\0\1\66\5\0\1\67"+
    "\31\0\2\7\2\0\1\7\21\0\1\7\1\70\20\7"+
    "\7\0\2\7\2\0\1\7\21\0\4\7\1\71\15\7"+
    "\7\0\2\7\2\0\1\7\21\0\15\7\1\72\1\7"+
    "\1\73\2\7\7\0\2\7\2\0\1\74\21\0\6\7"+
    "\1\75\13\7\7\0\2\7\2\0\1\7\21\0\12\7"+
    "\1\76\5\7\1\77\1\7\7\0\2\7\2\0\1\7"+
    "\21\0\10\7\1\100\11\7\7\0\2\7\2\0\1\7"+
    "\21\0\1\7\1\101\11\7\1\102\6\7\7\0\2\7"+
    "\2\0\1\7\21\0\15\7\1\103\4\7\7\0\2\7"+
    "\2\0\1\7\21\0\12\7\1\104\7\7\7\0\2\7"+
    "\2\0\1\7\21\0\17\7\1\105\2\7\7\0\2\7"+
    "\2\0\1\7\21\0\10\7\1\106\11\7\1\0\1\46"+
    "\10\0\3\46\24\0\1\46\1\0\1\46\6\0\1\46"+
    "\5\0\1\50\1\0\54\50\1\0\1\51\1\0\3\51"+
    "\1\107\50\51\7\0\2\7\2\0\1\7\21\0\1\7"+
    "\1\110\20\7\26\0\1\111\56\0\1\112\37\0\2\7"+
    "\2\0\1\7\21\0\2\7\1\113\17\7\7\0\2\7"+
    "\2\0\1\7\21\0\2\7\1\114\17\7\7\0\2\7"+
    "\2\0\1\7\21\0\20\7\1\115\1\7\7\0\2\7"+
    "\2\0\1\7\21\0\5\7\1\116\14\7\7\0\2\7"+
    "\2\0\1\7\21\0\4\7\1\117\15\7\7\0\2\7"+
    "\2\0\1\7\21\0\16\7\1\120\3\7\7\0\2\7"+
    "\2\0\1\7\21\0\1\7\1\121\20\7\7\0\2\7"+
    "\2\0\1\7\21\0\5\7\1\122\14\7\7\0\2\7"+
    "\2\0\1\7\21\0\3\7\1\123\16\7\7\0\2\7"+
    "\2\0\1\7\21\0\4\7\1\124\15\7\7\0\2\7"+
    "\2\0\1\7\21\0\5\7\1\125\14\7\7\0\2\7"+
    "\2\0\1\7\21\0\4\7\1\126\15\7\7\0\2\7"+
    "\2\0\1\7\21\0\5\7\1\127\14\7\7\0\2\7"+
    "\2\0\1\7\21\0\10\7\1\130\11\7\1\0\1\51"+
    "\1\0\1\51\1\131\1\51\1\107\50\51\7\0\2\7"+
    "\2\0\1\7\21\0\3\7\1\115\16\7\7\0\2\7"+
    "\2\0\1\7\21\0\3\7\1\132\16\7\7\0\2\7"+
    "\2\0\1\7\21\0\4\7\1\133\15\7\7\0\2\7"+
    "\2\0\1\7\21\0\12\7\1\134\7\7\7\0\2\7"+
    "\2\0\1\7\21\0\3\7\1\135\16\7\7\0\2\7"+
    "\2\0\1\7\21\0\1\7\1\136\20\7\7\0\2\7"+
    "\2\0\1\7\21\0\11\7\1\137\10\7\7\0\2\7"+
    "\2\0\1\7\21\0\12\7\1\140\7\7\7\0\2\7"+
    "\2\0\1\7\21\0\12\7\1\141\7\7\7\0\2\7"+
    "\2\0\1\7\21\0\6\7\1\142\13\7\7\0\2\7"+
    "\2\0\1\7\21\0\20\7\1\143\1\7\7\0\2\7"+
    "\2\0\1\7\21\0\1\7\1\144\20\7\7\0\2\7"+
    "\2\0\1\7\21\0\1\7\1\145\20\7\7\0\2\7"+
    "\2\0\1\7\21\0\3\7\1\146\16\7\7\0\2\7"+
    "\2\0\1\7\21\0\5\7\1\147\14\7\7\0\2\7"+
    "\2\0\1\7\21\0\6\7\1\150\13\7\7\0\2\7"+
    "\2\0\1\7\21\0\4\7\1\151\15\7\7\0\2\7"+
    "\2\0\1\7\21\0\15\7\1\152\4\7\7\0\2\7"+
    "\2\0\1\7\21\0\12\7\1\153\7\7\7\0\2\7"+
    "\2\0\1\7\21\0\12\7\1\154\7\7\7\0\2\7"+
    "\2\0\1\7\21\0\1\155\21\7\7\0\2\7\2\0"+
    "\1\7\21\0\11\7\1\156\10\7\7\0\2\7\2\0"+
    "\1\7\21\0\6\7\1\153\13\7\7\0\2\7\2\0"+
    "\1\7\21\0\2\7\1\157\17\7\7\0\2\7\2\0"+
    "\1\7\21\0\3\7\1\160\16\7\7\0\2\7\2\0"+
    "\1\7\21\0\6\7\1\161\13\7";

  private static int [] zzUnpackTrans() {
    int [] result = new int[3525];
    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\1\11\1\1\1\11\5\1\1\11\3\1\5\11"+
    "\1\1\1\11\20\1\1\11\2\0\1\1\1\0\2\11"+
    "\1\1\10\11\1\1\1\11\20\1\1\0\1\1\2\11"+
    "\47\1";

  private static int [] zzUnpackAttribute() {
    int [] result = new int[113];
    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 */
  private int yychar;

  /**
   * 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
   */
  private boolean zzAtBOL = true;

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

  /* user code: */
	public static void main(String argv[]) {		if (argv.length != 1) {			System.out.println	("Usage: java MiniJOOL inputfile");		}		else {			MiniJOOL l =null;			try	{				l = new MiniJOOL(new java.io.FileReader(argv[0]));				Symbol s = l.yylex();				while (s.getType() != Symbol.EOF) {					System.out.println(s);					s = l.yylex();				}			} catch (Exception e) {				System.out.println("Unexpected exception:");				e.printStackTrace();			}		}	}	private Symbol symbol(int type) {		return new Symbol(type, yytext(), yyline, yycolumn);	}

  /**
   * 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 MiniJOOL(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 MiniJOOL(java.io.InputStream in) {
    this(new java.io.InputStreamReader(in));
  }


  /**
   * 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;
    zzAtBOL  = true;
    zzAtEOF  = false;
    zzEndRead = zzStartRead = 0;
    zzCurrentPos = zzMarkedPos = zzPushbackPos = 0;
    yyline = yychar = yycolumn = 0;
    zzLexicalState = YYINITIAL;
  }


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

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -