/*******************************************************************************
* Copyright © 2011, 2013 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*
*******************************************************************************/
package org.eclipse.edt.compiler.core.ast;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
/**
* This class is a scanner generated by
* <a href="http://www.jflex.de/">JFlex</a> 1.3.5
* on 11/25/03 3:51 PM from the specification file
* <tt>file:/D:/Eclipse30M4/eclipse/workspace/com.ibm.etools.egl.pgm.ASTGenPlugin/src/tools/EGLNodeNameUtilityGenerator.flex</tt>
*/
class NodeNameUtilityGenerator {
/** This character denotes the end of file */
final public static int YYEOF = -1;
/** initial size of the lookahead buffer */
final private static int YY_BUFFERSIZE = 16384;
/** lexical states */
final public static int YYINITIAL = 0;
/**
* Translates characters to character classes
*/
final private static String yycmap_packed =
"\11\2\1\0\1\5\2\0\1\4\16\2\4\0\1\6\3\0\1\1"+
"\5\0\1\11\4\0\1\10\12\3\3\0\1\7\3\0\32\1\4\0"+
"\1\1\1\0\1\20\3\1\1\13\3\1\1\16\2\1\1\21\1\15"+
"\1\17\1\23\2\1\1\14\1\22\1\12\6\1\4\0\41\2\2\0"+
"\4\1\4\0\1\1\12\0\1\1\4\0\1\1\5\0\27\1\1\0"+
"\37\1\1\0\u0128\1\2\0\22\1\34\0\136\1\2\0\11\1\2\0"+
"\7\1\16\0\2\1\16\0\5\1\11\0\1\1\21\0\117\2\21\0"+
"\3\2\27\0\1\1\13\0\1\1\1\0\3\1\1\0\1\1\1\0"+
"\24\1\1\0\54\1\1\0\10\1\2\0\32\1\14\0\202\1\1\0"+
"\4\2\5\0\71\1\2\0\2\1\2\0\2\1\3\0\46\1\2\0"+
"\2\1\67\0\46\1\2\0\1\1\7\0\47\1\11\0\21\2\1\0"+
"\27\2\1\0\3\2\1\0\1\2\1\0\2\2\1\0\1\2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\32\1\5\0\113\1\225\0\64\1\40\2\7\0"+
"\1\1\4\0\12\3\41\0\4\2\1\0\12\3\6\0\130\1\10\0"+
"\51\1\1\2\u0556\0\234\1\4\0\132\1\6\0\26\1\2\0\6\1"+
"\2\0\46\1\2\0\6\1\2\0\10\1\1\0\1\1\1\0\1\1"+
"\1\0\1\1\1\0\37\1\2\0\65\1\1\0\7\1\1\0\1\1"+
"\3\0\3\1\1\0\7\1\3\0\4\1\2\0\6\1\4\0\15\1"+
"\5\0\3\1\1\0\7\1\17\0\4\2\32\0\5\2\20\0\2\1"+
"\51\0\6\2\17\0\1\1\40\0\20\1\40\0\15\2\4\0\1\2"+
"\40\0\1\1\4\0\1\1\2\0\12\1\1\0\1\1\3\0\5\1"+
"\6\0\1\1\1\0\1\1\1\0\1\1\1\0\4\1\1\0\3\1"+
"\1\0\7\1\46\0\44\1\u0e81\0\3\1\31\0\11\1\6\2\1\0"+
"\5\1\2\0\3\1\6\0\124\1\4\0\2\2\2\0\2\1\2\0"+
"\136\1\6\0\50\1\4\0\136\1\21\0\30\1\u0248\0\u19b6\1\112\0"+
"\u51a6\1\132\0\u048d\1\u0773\0\u2ba4\1\u215c\0\u012e\1\322\0\7\1\14\0"+
"\5\1\5\0\1\1\1\2\12\1\1\0\15\1\1\0\5\1\1\0"+
"\1\1\1\0\2\1\1\0\2\1\1\0\154\1\41\0\u016b\1\22\0"+
"\100\1\2\0\66\1\50\0\14\1\44\0\4\2\17\0\2\1\30\0"+
"\3\1\31\0\1\1\6\0\3\1\1\0\1\1\1\0\207\1\2\0"+
"\1\2\4\0\1\1\13\0\12\3\7\0\32\1\4\0\1\1\1\0"+
"\32\1\12\0\132\1\3\0\6\1\2\0\6\1\2\0\6\1\2\0"+
"\3\1\3\0\2\1\3\0\2\1\22\0\3\2\4\0";
/**
* Translates characters to character classes
*/
final private static char [] yycmap = yy_unpack_cmap(yycmap_packed);
/**
* Translates a state to a row index in the transition table
*/
final private static int yy_rowMap [] = {
0, 20, 40, 60, 80, 40, 100, 120, 140, 160,
180, 200, 220, 180, 240, 260, 280, 300, 320, 340,
360, 380, 400, 420, 440, 460, 480, 500, 520, 540,
560, 580, 600, 620, 20, 640, 660, 680, 700, 20
};
/**
* The packed transition table of the DFA (part 0)
*/
final private static String yy_packed0 =
"\1\2\1\3\2\2\1\4\3\2\1\5\1\2\12\3"+
"\25\0\3\6\2\0\1\7\3\0\12\6\5\0\1\2"+
"\27\0\1\10\21\0\1\11\22\0\1\12\23\0\1\13"+
"\27\0\1\14\4\0\1\15\7\0\1\16\33\0\1\17"+
"\33\0\1\20\14\0\1\21\26\0\1\22\21\0\1\23"+
"\14\0\1\24\33\0\1\25\17\0\1\26\30\0\1\27"+
"\17\0\1\30\30\0\1\31\17\0\1\32\30\0\1\33"+
"\17\0\1\34\30\0\1\35\17\0\1\36\13\0\1\37"+
"\34\0\1\40\15\0\1\41\32\0\1\42\13\0\1\43"+
"\34\0\1\44\24\0\1\45\7\0\1\46\26\0\1\47"+
"\22\0\1\50\13\0";
/**
* The transition table of the DFA
*/
final private static int yytrans [] = yy_unpack();
/* error codes */
final private static int YY_UNKNOWN_ERROR = 0;
final private static int YY_ILLEGAL_STATE = 1;
final private static int YY_NO_MATCH = 2;
final private static int YY_PUSHBACK_2BIG = 3;
/* error messages for the codes above */
final private static String YY_ERROR_MSG[] = {
"Unkown internal scanner error",
"Internal error: unknown state",
"Error: could not match input",
"Error: pushback value was too large"
};
/**
* YY_ATTRIBUTE[aState] contains the attributes of state <code>aState</code>
*/
private final static byte YY_ATTRIBUTE[] = {
0, 9, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 9, 0, 0, 0, 0, 9
};
/** the input device */
private java.io.Reader yy_reader;
/** the current state of the DFA */
private int yy_state;
/** the current lexical state */
private int yy_lexical_state = YYINITIAL;
/** this buffer contains the current text to be matched and is
the source of the yytext() string */
private char yy_buffer[] = new char[YY_BUFFERSIZE];
/** the textposition at the last accepting state */
private int yy_markedPos;
/** the textposition at the last state to be included in yytext */
private int yy_pushbackPos;
/** the current text position in the buffer */
private int yy_currentPos;
/** startRead marks the beginning of the yytext() string in the buffer */
private int yy_startRead;
/** endRead marks the last character in the buffer, that has been read
from input */
private int yy_endRead;
/** 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;
/**
* yy_atBOL == true <=> the scanner is currently at the beginning of a line
*/
private boolean yy_atBOL = true;
/** yy_atEOF == true <=> the scanner is at the EOF */
private boolean yy_atEOF;
/** denotes if the user-EOF-code has already been executed */
private boolean yy_eof_done;
/* user code: */
private StringBuffer output = new StringBuffer();
private boolean terminalState = true;
private String parseIdentifier(String input) {
int index = input.indexOf(' ');
return input.substring(0, index);
}
private String parseInteger(String input) {
int index = input.lastIndexOf(' ');
return input.substring(index + 1, input.length());
}
/**
* 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.
*/
NodeNameUtilityGenerator(java.io.Reader in) {
this.yy_reader = 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.
*/
NodeNameUtilityGenerator(java.io.InputStream in) {
this(new java.io.InputStreamReader(in));
}
/**
* Unpacks the split, compressed DFA transition table.
*
* @return the unpacked transition table
*/
private static int [] yy_unpack() {
int [] trans = new int[720];
int offset = 0;
offset = yy_unpack(yy_packed0, offset, trans);
return trans;
}
/**
* Unpacks the compressed DFA transition table.
*
* @param packed the packed transition table
* @return the index of the last entry
*/
private static int yy_unpack(String packed, int offset, int [] trans) {
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 trans[j++] = value; while (--count > 0);
}
return j;
}
/**
* Unpacks the compressed character translation table.
*
* @param packed the packed character translation table
* @return the unpacked character translation table
*/
private static char [] yy_unpack_cmap(String packed) {
char [] map = new char[0x10000];
int i = 0; /* index in packed string */
int j = 0; /* index in unpacked array */
while (i < 1576) {
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 IOException if any I/O-Error occurs
*/
private boolean yy_refill() throws java.io.IOException {
/* first: make room (if you can) */
if (yy_startRead > 0) {
System.arraycopy(yy_buffer, yy_startRead,
yy_buffer, 0,
yy_endRead-yy_startRead);
/* translate stored positions */
yy_endRead-= yy_startRead;
yy_currentPos-= yy_startRead;
yy_markedPos-= yy_startRead;
yy_pushbackPos-= yy_startRead;
yy_startRead = 0;
}
/* is the buffer big enough? */
if (yy_currentPos >= yy_buffer.length) {
/* if not: blow it up */
char newBuffer[] = new char[yy_currentPos*2];
System.arraycopy(yy_buffer, 0, newBuffer, 0, yy_buffer.length);
yy_buffer = newBuffer;
}
/* finally: fill the buffer with new input */
int numRead = yy_reader.read(yy_buffer, yy_endRead,
yy_buffer.length-yy_endRead);
if (numRead < 0) {
return true;
}
else {
yy_endRead+= numRead;
return false;
}
}
/**
* Closes the input stream.
*/
final public void yyclose() throws java.io.IOException {
yy_atEOF = true; /* indicate end of file */
yy_endRead = yy_startRead; /* invalidate buffer */
if (yy_reader != null)
yy_reader.close();
}
/**
* Closes the current stream, and resets the
* scanner to read from a new input stream.
*
* 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>YY_INITIAL</tt>.
*
* @param reader the new input stream
*/
final public void yyreset(java.io.Reader reader) throws java.io.IOException {
yyclose();
yy_reader = reader;
yy_atBOL = true;
yy_atEOF = false;
yy_endRead = yy_startRead = 0;
yy_currentPos = yy_markedPos = yy_pushbackPos = 0;
yyline = yychar = yycolumn = 0;
yy_lexical_state = YYINITIAL;
}
/**
* Returns the current lexical state.
*/
final public int yystate() {
return yy_lexical_state;
}
/**
* Enters a new lexical state
*
* @param newState the new lexical state
*/
final public void yybegin(int newState) {
yy_lexical_state = newState;
}
/**
* Returns the text matched by the current regular expression.
*/
final public String yytext() {
return new String( yy_buffer, yy_startRead, yy_markedPos-yy_startRead );
}
/**
* 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
*/
final public char yycharat(int pos) {
return yy_buffer[yy_startRead+pos];
}
/**
* Returns the length of the matched text region.
*/
final public int yylength() {
return yy_markedPos-yy_startRead;
}
/**
* 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 yy_ScanError(int errorCode) {
String message;
try {
message = YY_ERROR_MSG[errorCode];
}
catch (ArrayIndexOutOfBoundsException e) {
message = YY_ERROR_MSG[YY_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()!
*/
private void yypushback(int number) {
if ( number > yylength() )
yy_ScanError(YY_PUSHBACK_2BIG);
yy_markedPos -= number;
}
/**
* Contains user EOF-code, which will be executed exactly once,
* when the end of file is reached
*/
private void yy_do_eof() {
if (!yy_eof_done) {
yy_eof_done = true;
output.insert(0,
"package org.eclipse.edt.compiler.core.ast;\n\n" +
"import java.util.*;\n\n" +
"public class NodeNameUtility {\n\n" +
"private static Map terminalIntToStringMap = new HashMap();\n" +
"private static Map nonterminalIntToStringMap = new HashMap();\n" +
"private static Map terminalStringToIntMap = new HashMap();\n" +
"private static Map nonterminalStringToIntMap = new HashMap();\n\n" +
"static {\n");
output.append("}\n\n");
output.append("private NodeNameUtility() { }\n\n");
output.append("public static int getNonterminalCount() {\n");
output.append("return nonterminalStringToIntMap.size();\n");
output.append("}\n\n");
output.append("public static String getTerminalName(int terminalType) {\n");
output.append("return (String)(terminalIntToStringMap.get(new Integer(terminalType)));\n");
output.append("}\n\n");
output.append("public static String getNonterminalName(int nonterminalType) {\n");
output.append("return (String)(nonterminalIntToStringMap.get(new Integer(nonterminalType)));\n");
output.append("}\n\n");
output.append("public static int getTerminalType(String terminalName) {\n");
output.append("return ((Integer)(terminalStringToIntMap.get(terminalName))).intValue();\n");
output.append("}\n\n");
output.append("public static int getNonterminalType(String nonterminalName) {\n");
output.append("return ((Integer)(nonterminalStringToIntMap.get(nonterminalName))).intValue();\n");
output.append("}\n\n");
output.append("}\n");
System.out.print(output.toString());
}
}
/**
* 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 IOException if any I/O-Error occurs
*/
public int yylex() throws java.io.IOException {
int yy_input;
int yy_action;
// cached fields:
int yy_currentPos_l;
int yy_startRead_l;
int yy_markedPos_l;
int yy_endRead_l = yy_endRead;
char [] yy_buffer_l = yy_buffer;
char [] yycmap_l = yycmap;
int [] yytrans_l = yytrans;
int [] yy_rowMap_l = yy_rowMap;
byte [] yy_attr_l = YY_ATTRIBUTE;
while (true) {
yy_markedPos_l = yy_markedPos;
yy_action = -1;
yy_startRead_l = yy_currentPos_l = yy_currentPos =
yy_startRead = yy_markedPos_l;
yy_state = yy_lexical_state;
yy_forAction: {
while (true) {
if (yy_currentPos_l < yy_endRead_l)
yy_input = yy_buffer_l[yy_currentPos_l++];
else if (yy_atEOF) {
yy_input = YYEOF;
break yy_forAction;
}
else {
// store back cached positions
yy_currentPos = yy_currentPos_l;
yy_markedPos = yy_markedPos_l;
boolean eof = yy_refill();
// get translated positions and possibly new buffer
yy_currentPos_l = yy_currentPos;
yy_markedPos_l = yy_markedPos;
yy_buffer_l = yy_buffer;
yy_endRead_l = yy_endRead;
if (eof) {
yy_input = YYEOF;
break yy_forAction;
}
else {
yy_input = yy_buffer_l[yy_currentPos_l++];
}
}
int yy_next = yytrans_l[ yy_rowMap_l[yy_state] + yycmap_l[yy_input] ];
if (yy_next == -1) break yy_forAction;
yy_state = yy_next;
int yy_attributes = yy_attr_l[yy_state];
if ( (yy_attributes & 1) == 1 ) {
yy_action = yy_state;
yy_markedPos_l = yy_currentPos_l;
if ( (yy_attributes & 8) == 8 ) break yy_forAction;
}
}
}
// store back cached position
yy_markedPos = yy_markedPos_l;
switch (yy_action) {
case 1:
case 2:
case 3:
case 4:
{ }
case 41: break;
case 34:
{ terminalState = true; }
case 42: break;
case 39:
{ terminalState = false; }
case 43: break;
case 13:
{
String identifier = parseIdentifier(yytext());
String integer = parseInteger(yytext());
if (terminalState) {
output.append("terminalIntToStringMap.put(new Integer(" + integer + "), \"" + getDisplayString(identifier) + "\");\n");
output.append("terminalStringToIntMap.put(\"" + getDisplayString(identifier) + "\", new Integer(" + integer + "));\n");
} else {
output.append("nonterminalIntToStringMap.put(new Integer(" + integer + "), \"" + identifier + "\");\n");
output.append("nonterminalStringToIntMap.put(\"" + identifier + "\", new Integer(" + integer + "));\n");
}
}
case 44: break;
default:
if (yy_input == YYEOF && yy_startRead == yy_currentPos) {
yy_atEOF = true;
yy_do_eof();
return YYEOF;
}
else {
yy_ScanError(YY_NO_MATCH);
}
}
}
}
private static Map stringsToDisplayStrings = new HashMap();
static {
stringsToDisplayStrings.put("RPAREN", ")");
stringsToDisplayStrings.put("LPAREN", "(");
stringsToDisplayStrings.put("RPAREN", ")");
stringsToDisplayStrings.put("BANG", "!");
stringsToDisplayStrings.put("COMMA", ",");
stringsToDisplayStrings.put("SEMI", ";");
stringsToDisplayStrings.put("DOT", ".");
stringsToDisplayStrings.put("COLON", ":");
stringsToDisplayStrings.put("ASSIGN", "=");
stringsToDisplayStrings.put("EQ", "==");
stringsToDisplayStrings.put("AND", "&&");
stringsToDisplayStrings.put("OR", "||");
stringsToDisplayStrings.put("NE", "!=");
stringsToDisplayStrings.put("LT", "<");
stringsToDisplayStrings.put("GT", ">");
stringsToDisplayStrings.put("LE", "<=");
stringsToDisplayStrings.put("GE", ">=");
stringsToDisplayStrings.put("PLUS", "+");
stringsToDisplayStrings.put("MINUS", "-");
stringsToDisplayStrings.put("TIMES", "*");
stringsToDisplayStrings.put("TIMESTIMES", "**");
stringsToDisplayStrings.put("CONCAT", "::");
stringsToDisplayStrings.put("DIV", "/");
stringsToDisplayStrings.put("MODULO", "%");
stringsToDisplayStrings.put("LBRACKET", "[");
stringsToDisplayStrings.put("RBRACKET", "]");
stringsToDisplayStrings.put("LCURLY", "{");
stringsToDisplayStrings.put("RCURLY", "}");
stringsToDisplayStrings.put("AT", "@");
}
private String getDisplayString(String str) {
String result = (String) stringsToDisplayStrings.get(str);
return result == null ? str : result;
}
/**
* Runs the scanner on input files.
*
* This is a standalone scanner, i.e. it will print any unmatched
* text to System.out unchanged.
*
* @param argv the command line, contains the filenames to run
* the scanner on.
*/
public static void main(String argv[]) {
if (argv.length == 0) {
System.out.println("Usage : java NodeNameUtilityGenerator <inputfile>");
}
else {
for (int i = 0; i < argv.length; i++) {
// Linux wants /, not \
String file = argv[i];
if (File.separatorChar == '/') {
file = file.replace('\\', '/');
}
NodeNameUtilityGenerator scanner = null;
try {
scanner = new NodeNameUtilityGenerator( new java.io.FileReader(file) );
while ( !scanner.yy_atEOF ) scanner.yylex();
}
catch (java.io.FileNotFoundException e) {
System.out.println("File not found : \""+file+"\"");
}
catch (java.io.IOException e) {
System.out.println("IO error scanning file \""+file+"\"");
System.out.println(e);
}
catch (Exception e) {
System.out.println("Unexpected exception:");
e.printStackTrace();
}
}
}
}
}