http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/4231ac35/datacat/parsers/src/main/java/org/apache/airavata/datacat/parsers/gridchem/finalcoord/FinalCoordLexer.java ---------------------------------------------------------------------- diff --git a/datacat/parsers/src/main/java/org/apache/airavata/datacat/parsers/gridchem/finalcoord/FinalCoordLexer.java b/datacat/parsers/src/main/java/org/apache/airavata/datacat/parsers/gridchem/finalcoord/FinalCoordLexer.java new file mode 100644 index 0000000..c4849eb --- /dev/null +++ b/datacat/parsers/src/main/java/org/apache/airavata/datacat/parsers/gridchem/finalcoord/FinalCoordLexer.java @@ -0,0 +1,799 @@ +/* +* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +* +*/ +package org.apache.airavata.datacat.parsers.gridchem.finalcoord;/* The following code was generated by JFlex 1.4.3 on 8/3/14 9:30 PM */ + +import java_cup.runtime.Symbol; + +/** + * This class is a scanner generated by + * <a href="http://www.jflex.de/">JFlex</a> 1.4.3 + * on 8/3/14 9:30 PM from the specification file + * <tt>finalcoord.flex</tt> + */ +public class FinalCoordLexer implements java_cup.runtime.Scanner { + + /** + * This character denotes the end of file + */ + public static final int YYEOF = -1; + /** + * lexical states + */ + public static final int INPUTF = 30; + public static final int ITER2 = 4; + public static final int INPUTE = 28; + public static final int INPUTD = 26; + public static final int INPUTC = 24; + public static final int INPUTB = 22; + public static final int INPUTA = 20; + public static final int INTVALUE = 8; + public static final int INPUT = 18; + public static final int IGNOREALL = 16; + public static final int ITER = 2; + public static final int YYINITIAL = 0; + /** + * the current lexical state + */ + private int zzLexicalState = YYINITIAL; + public static final int FLOAT2 = 14; + public static final int FLOAT1 = 12; + public static final int FLOATVALUE = 10; + public static final int ITER3 = 6; + /** + * initial size of the lookahead buffer + */ + private static final int ZZ_BUFFERSIZE = 16384; + /** + * this buffer contains the current text to be matched and is + * the source of the yytext() string + */ + private char zzBuffer[] = new char[ZZ_BUFFERSIZE]; + /** + * ZZ_LEXSTATE[l] is the state in the DFA for the lexical state l + * ZZ_LEXSTATE[l+1] is the state in the DFA for the lexical state l + * at the beginning of a line + * l is of the form l = 2*k, k a non negative integer + */ + private static final int ZZ_LEXSTATE[] = { + 0, 0, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9 + }; + /** + * Translates characters to character classes + */ + private static final char[] ZZ_CMAP = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 19, 3, 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 23, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 31, 28, 4, 0, 27, 33, 0, 0, 34, 20, 30, 32, + 0, 0, 0, 5, 26, 0, 0, 0, 24, 25, 18, 0, 0, 0, 0, 29, + 0, 7, 0, 0, 17, 22, 15, 0, 0, 8, 0, 0, 0, 0, 10, 9, + 14, 0, 11, 0, 6, 16, 0, 0, 21, 12, 0, 0, 2, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + }; + /** + * Translates DFA states to action switch labels. + */ + private static final int[] ZZ_ACTION = zzUnpackAction(); + private static final String ZZ_ACTION_PACKED_0 = + "\12\0\6\1\1\2\2\1\1\3\1\1\1\4\10\1" + + "\23\0\1\5\1\6\1\7\122\0\1\10\41\0\1\11" + + "\3\0\1\12\11\0\1\13\130\0\1\14\1\15"; + /** + * 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\43\0\106\0\151\0\214\0\257\0\322\0\365" + + "\0\u0118\0\u013b\0\u015e\0\u0181\0\u01a4\0\u01c7\0\u01ea\0\u020d" + + "\0\u0230\0\u0230\0\u0253\0\u0276\0\u0276\0\u0299\0\u0299\0\u02bc" + + "\0\u02df\0\u0302\0\u0325\0\u0348\0\u036b\0\u038e\0\u03b1\0\u03d4" + + "\0\u03f7\0\u041a\0\u043d\0\u0460\0\u02bc\0\u0483\0\u0302\0\u04a6" + + "\0\u0348\0\u04c9\0\u04ec\0\u050f\0\u0532\0\u0555\0\u0578\0\u059b" + + "\0\u05be\0\u0483\0\u04a6\0\u04c9\0\u05e1\0\u0604\0\u0627\0\u064a" + + "\0\u066d\0\u0690\0\u06b3\0\u06d6\0\u06f9\0\u071c\0\u073f\0\u0762" + + "\0\u0785\0\u07a8\0\u07cb\0\u07ee\0\u0811\0\u0834\0\u0857\0\u087a" + + "\0\u089d\0\u08c0\0\u08e3\0\u0906\0\u0929\0\u094c\0\u096f\0\u0992" + + "\0\u09b5\0\u09d8\0\u09fb\0\u0a1e\0\u0a41\0\u0a64\0\u0a87\0\u0aaa" + + "\0\u0acd\0\u0af0\0\u0b13\0\u0b36\0\u0b59\0\u0b7c\0\u0b9f\0\u0bc2" + + "\0\u0be5\0\u0c08\0\u0c2b\0\u0c4e\0\u0c71\0\u0c94\0\u0cb7\0\u0cda" + + "\0\u0cfd\0\u0d20\0\u0d43\0\u0d66\0\u0d89\0\u0dac\0\u0dcf\0\u0df2" + + "\0\u0e15\0\u0e38\0\u0e5b\0\u0e7e\0\u0ea1\0\u0ec4\0\u0ee7\0\u0f0a" + + "\0\u0f2d\0\u0f50\0\u0f73\0\u0f96\0\u0fb9\0\u0fdc\0\u0fff\0\u1022" + + "\0\u1045\0\u1068\0\u108b\0\u10ae\0\u10d1\0\u10f4\0\u015e\0\u1117" + + "\0\u113a\0\u115d\0\u1180\0\u11a3\0\u11c6\0\u11e9\0\u120c\0\u122f" + + "\0\u1252\0\u1275\0\u1298\0\u12bb\0\u12de\0\u1301\0\u1324\0\u1347" + + "\0\u136a\0\u138d\0\u13b0\0\u13d3\0\u13f6\0\u1419\0\u143c\0\u145f" + + "\0\u1482\0\u14a5\0\u14c8\0\u14eb\0\u150e\0\u1531\0\u1554\0\u1577" + + "\0\u015e\0\u159a\0\u15bd\0\u15e0\0\u015e\0\u1603\0\u1626\0\u1649" + + "\0\u166c\0\u168f\0\u16b2\0\u16d5\0\u16f8\0\u171b\0\u015e\0\u173e" + + "\0\u1761\0\u1784\0\u17a7\0\u17ca\0\u17ed\0\u1810\0\u1833\0\u1856" + + "\0\u1879\0\u189c\0\u18bf\0\u18e2\0\u1905\0\u1928\0\u194b\0\u196e" + + "\0\u1991\0\u19b4\0\u19d7\0\u19fa\0\u1a1d\0\u1a40\0\u1a63\0\u1a86" + + "\0\u1aa9\0\u1acc\0\u1aef\0\u1b12\0\u1b35\0\u1b58\0\u1b7b\0\u1b9e" + + "\0\u1bc1\0\u1be4\0\u1c07\0\u1c2a\0\u1c4d\0\u1c70\0\u1c93\0\u1cb6" + + "\0\u1cd9\0\u1cfc\0\u1d1f\0\u1d42\0\u1d65\0\u1d88\0\u1dab\0\u1dce" + + "\0\u1df1\0\u1e14\0\u1e37\0\u1e5a\0\u1e7d\0\u1ea0\0\u1ec3\0\u1ee6" + + "\0\u1f09\0\u1f2c\0\u1f4f\0\u1f72\0\u1f95\0\u1fb8\0\u1fdb\0\u1ffe" + + "\0\u2021\0\u2044\0\u2067\0\u208a\0\u20ad\0\u20d0\0\u20f3\0\u2116" + + "\0\u2139\0\u215c\0\u217f\0\u21a2\0\u21c5\0\u21e8\0\u220b\0\u222e" + + "\0\u2251\0\u2274\0\u2297\0\u22ba\0\u22dd\0\u2300\0\u2323\0\u015e" + + "\0\u015e"; + /** + * The transition table of the DFA + */ + private static final int[] ZZ_TRANS = zzUnpackTrans(); + private static final String ZZ_TRANS_PACKED_0 = + "\5\13\1\14\14\13\1\15\25\13\1\16\22\13\1\17" + + "\1\13\1\20\54\13\1\21\1\22\20\13\1\23\20\13" + + "\1\24\1\25\20\13\1\25\20\13\1\26\1\27\20\13" + + "\1\27\20\13\1\30\1\31\20\13\1\31\20\13\1\32" + + "\1\33\20\13\1\33\20\13\1\34\1\35\20\13\1\35" + + "\42\13\1\36\17\13\51\0\1\37\57\0\1\40\25\0" + + "\1\41\51\0\1\42\60\0\1\43\10\0\1\21\42\0" + + "\1\21\21\0\1\44\20\0\1\24\42\0\1\26\42\0" + + "\1\45\1\0\1\46\40\0\1\45\42\0\1\47\1\0" + + "\1\50\40\0\1\47\42\0\1\51\1\0\1\52\40\0" + + "\1\51\64\0\1\53\26\0\1\54\57\0\1\55\25\0" + + "\1\56\50\0\1\57\61\0\1\60\31\0\1\61\20\0" + + "\1\62\42\0\1\63\42\0\1\64\64\0\1\65\25\0" + + "\1\66\43\0\1\67\45\0\1\70\45\0\1\71\62\0" + + "\1\72\30\0\1\73\42\0\1\74\27\0\1\75\40\0" + + "\1\76\55\0\1\77\36\0\1\100\61\0\1\101\31\0" + + "\1\102\42\0\1\103\30\0\1\104\44\0\1\105\36\0" + + "\1\106\50\0\1\107\63\0\1\110\27\0\1\111\42\0" + + "\1\112\31\0\1\113\40\0\1\114\45\0\1\115\44\0" + + "\1\116\64\0\1\117\26\0\1\120\42\0\1\121\26\0" + + "\1\122\60\0\1\123\36\0\1\124\36\0\1\125\62\0" + + "\1\126\30\0\1\127\42\0\1\130\32\0\1\131\44\0" + + "\1\132\42\0\1\133\42\0\1\134\65\0\1\135\25\0" + + "\1\136\42\0\1\137\33\0\1\140\37\0\1\141\42\0" + + "\1\142\46\0\1\143\31\0\1\144\61\0\1\145\42\0" + + "\1\146\34\0\1\147\40\0\1\150\42\0\1\151\44\0" + + "\1\152\62\0\1\153\30\0\1\154\42\0\1\155\35\0" + + "\1\156\34\0\1\157\42\0\1\160\47\0\1\161\31\0" + + "\1\162\61\0\1\163\42\0\1\164\30\0\1\165\57\0" + + "\1\166\42\0\1\167\45\0\1\170\52\0\1\171\24\0" + + "\1\172\42\0\1\173\27\0\1\174\44\0\1\175\42\0" + + "\1\176\45\0\1\177\67\0\1\200\23\0\1\201\42\0" + + "\1\202\31\0\1\203\36\0\1\204\42\0\1\205\51\0" + + "\1\206\61\0\1\207\31\0\1\210\42\0\1\211\25\0" + + "\1\212\43\0\1\213\42\0\1\214\50\0\1\215\50\0" + + "\1\216\42\0\1\217\34\0\1\220\33\0\1\221\42\0" + + "\1\222\51\0\1\223\50\0\1\224\42\0\1\225\36\0" + + "\1\226\33\0\1\227\42\0\1\230\47\0\1\231\50\0" + + "\1\232\42\0\1\233\30\0\1\234\42\0\1\235\42\0" + + "\1\236\46\0\1\237\50\0\1\240\42\0\1\241\37\0" + + "\1\242\34\0\1\243\42\0\1\244\45\0\1\245\50\0" + + "\1\246\42\0\1\247\31\0\1\250\57\0\1\251\42\0" + + "\1\207\30\0\1\252\50\0\1\253\42\0\1\254\40\0" + + "\1\255\36\0\1\256\50\0\1\257\42\0\1\260\34\0" + + "\1\261\50\0\1\262\42\0\1\263\34\0\1\264\50\0" + + "\1\265\42\0\1\266\41\0\1\267\43\0\1\270\42\0" + + "\1\271\42\0\1\272\42\0\1\273\42\0\1\274\42\0" + + "\1\275\42\0\1\276\42\0\1\277\42\0\1\300\42\0" + + "\1\301\42\0\1\302\42\0\1\303\42\0\1\304\42\0" + + "\1\305\42\0\1\306\42\0\1\307\42\0\1\310\42\0" + + "\1\311\42\0\1\312\42\0\1\313\42\0\1\314\42\0" + + "\1\315\42\0\1\316\42\0\1\317\42\0\1\320\42\0" + + "\1\321\42\0\1\322\42\0\1\323\42\0\1\324\42\0" + + "\1\325\42\0\1\326\42\0\1\327\42\0\1\330\42\0" + + "\1\331\42\0\1\332\42\0\1\333\42\0\1\334\42\0" + + "\1\335\42\0\1\336\42\0\1\337\42\0\1\340\42\0" + + "\1\341\42\0\1\342\42\0\1\343\42\0\1\344\42\0" + + "\1\345\42\0\1\346\42\0\1\347\42\0\1\350\42\0" + + "\1\351\42\0\1\352\42\0\1\353\42\0\1\354\42\0" + + "\1\355\42\0\1\356\42\0\1\357\42\0\1\360\42\0" + + "\1\361\42\0\1\362\42\0\1\363\42\0\1\364\42\0" + + "\1\365\42\0\1\366\42\0\1\367\42\0\1\370\42\0" + + "\1\371\42\0\1\372\42\0\1\373\42\0\1\374\42\0" + + "\1\375\42\0\1\376\42\0\1\377\42\0\1\u0100\42\0" + + "\1\u0101\42\0\1\u0102\42\0\1\u0103\42\0\1\u0104\42\0" + + "\1\u0105\42\0\1\u0106\42\0\1\u0107\42\0\1\u0108\42\0" + + "\1\u0109\42\0\1\u010a\42\0\1\u010b\42\0\1\u010c\42\0" + + "\1\u010d\42\0\1\u010e\42\0\1\u010f\42\0\1\u0110\42\0" + + "\1\u0111\17\0"; + /* 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 = + "\12\0\1\11\23\1\23\0\3\1\122\0\1\11\41\0" + + "\1\11\3\0\1\11\11\0\1\11\130\0\2\11"; + /* user code: */ + public static boolean DEBUG = false; + /** + * the input device + */ + private java.io.Reader zzReader; + /** + * the current state of the DFA + */ + private int zzState; + /** + * the textposition at the last accepting state + */ + private int zzMarkedPos; + /** + * 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; + /** + * denotes if the user-EOF-code has already been executed + */ + private boolean zzEOFDone; + + /** + * 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 FinalCoordLexer(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 FinalCoordLexer(java.io.InputStream in) { + this(new java.io.InputStreamReader(in)); + } + + private static int[] zzUnpackAction() { + int[] result = new int[273]; + 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; + } + + private static int[] zzUnpackRowMap() { + int[] result = new int[273]; + 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; + } + + private static int[] zzUnpackTrans() { + int[] result = new int[9030]; + 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; + } + + private static int[] zzUnpackAttribute() { + int[] result = new int[273]; + 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; + } + + /** + * Runs the scanner on input files. + * <p/> + * This is a standalone scanner, 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 FinalCoordLexer <inputfile>"); + } else { + for (int i = 0; i < argv.length; i++) { + FinalCoordLexer scanner = null; + try { + scanner = new FinalCoordLexer(new java.io.FileReader(argv[i])); + while (!scanner.zzAtEOF) scanner.next_token(); + } catch (java.io.FileNotFoundException e) { + System.out.println("File not found : \"" + argv[i] + "\""); + } catch (java.io.IOException e) { + System.out.println("IO error scanning file \"" + argv[i] + "\""); + System.out.println(e); + } catch (Exception e) { + System.out.println("Unexpected exception:"); + e.printStackTrace(); + } + } + } + } + + /** + * Refills the input buffer. + * + * @return <code>false</code>, iff there was new input. + * @throws 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; + 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) { + zzEndRead += numRead; + return false; + } + // unlikely but not impossible: read 0 characters, but not at end of stream + if (numRead == 0) { + int c = zzReader.read(); + if (c == -1) { + return true; + } else { + zzBuffer[zzEndRead++] = (char) c; + return false; + } + } + + // numRead < 0 + return true; + } + + /** + * 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. + * <p/> + * 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; + zzEOFDone = false; + zzEndRead = zzStartRead = 0; + zzCurrentPos = zzMarkedPos = 0; + yyline = yychar = 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. + * <p/> + * 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. + * <p/> + * 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.). + * <p/> + * 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. + * <p/> + * 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 + * @throws java.io.IOException if any I/O-Error occurs + */ + public java_cup.runtime.Symbol next_token() throws java.io.IOException { + int zzInput; + int zzAction; + + // cached fields: + 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; + + zzAction = -1; + + zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL; + + zzState = ZZ_LEXSTATE[zzLexicalState]; + + + zzForAction: + { + while (true) { + + if (zzCurrentPosL < zzEndReadL) + zzInput = zzBufferL[zzCurrentPosL++]; + else if (zzAtEOF) { + zzInput = YYEOF; + break zzForAction; + } else { + // store back cached positions + zzCurrentPos = zzCurrentPosL; + zzMarkedPos = zzMarkedPosL; + boolean eof = zzRefill(); + // get translated positions and possibly new buffer + 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; + } + + } + } + + // store back cached position + zzMarkedPos = zzMarkedPosL; + + switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) { + case 5: { + yybegin(INPUTD); + return new Symbol(FinalCoordSym.INPUT5, new Float(yytext())); + } + case 14: + break; + case 7: { + yybegin(INPUT); + return new Symbol(FinalCoordSym.INPUT7, new Float(yytext())); + } + case 15: + break; + case 3: { + yybegin(INPUTB); + return new Symbol(FinalCoordSym.INPUT3, new Integer(yytext())); + } + case 16: + break; + case 8: { + yybegin(IGNOREALL); + return new Symbol(FinalCoordSym.SCFDONE); + } + case 17: + break; + case 11: { + yybegin(INPUTF); + return new Symbol(FinalCoordSym.INPUT1); + } + case 18: + break; + case 2: { + yybegin(INPUTA); + return new Symbol(FinalCoordSym.INPUT2, new Integer(yytext())); + } + case 19: + break; + case 12: { + yybegin(ITER); + return new Symbol(FinalCoordSym.DASH2); + } + case 20: + break; + case 9: { + yybegin(ITER); + return new Symbol(FinalCoordSym.FOUNDITER); + } + case 21: + break; + case 10: { + yybegin(ITER); + return new Symbol(FinalCoordSym.FOUNDITER); + } + case 22: + break; + case 6: { + yybegin(INPUTE); + return new Symbol(FinalCoordSym.INPUT6, new Float(yytext())); + } + case 23: + break; + case 4: { + yybegin(INPUTC); + return new Symbol(FinalCoordSym.INPUT4, new Integer(yytext())); + } + case 24: + break; + case 13: { + yybegin(INPUT); + return new Symbol(FinalCoordSym.DASH1); + } + case 25: + break; + case 1: { + } + case 26: + break; + default: + if (zzInput == YYEOF && zzStartRead == zzCurrentPos) { + zzAtEOF = true; + zzDoEOF(); + { + return new java_cup.runtime.Symbol(FinalCoordSym.EOF); + } + } else { + zzScanError(ZZ_NO_MATCH); + } + } + } + } + + /** + * Converts an int token code into the name of the + * token by reflection on the cup symbol class/interface sym + * <p/> + * This code was contributed by Karl Meissner <[email protected]> + */ + private String getTokenName(int token) { + try { + java.lang.reflect.Field[] classFields = FinalCoordSym.class.getFields(); + for (int i = 0; i < classFields.length; i++) { + if (classFields[i].getInt(null) == token) { + return classFields[i].getName(); + } + } + } catch (Exception e) { + e.printStackTrace(System.err); + } + + return "UNKNOWN TOKEN"; + } + + /** + * Same as next_token but also prints the token to standard out + * for debugging. + * <p/> + * This code was contributed by Karl Meissner <[email protected]> + */ + public java_cup.runtime.Symbol debug_next_token() throws java.io.IOException { + java_cup.runtime.Symbol s = next_token(); + System.out.println(" --" + yytext() + "--" + getTokenName(s.sym) + "--"); + return s; + } + + +}
http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/4231ac35/datacat/parsers/src/main/java/org/apache/airavata/datacat/parsers/gridchem/finalcoord/FinalCoordParser.java ---------------------------------------------------------------------- diff --git a/datacat/parsers/src/main/java/org/apache/airavata/datacat/parsers/gridchem/finalcoord/FinalCoordParser.java b/datacat/parsers/src/main/java/org/apache/airavata/datacat/parsers/gridchem/finalcoord/FinalCoordParser.java new file mode 100644 index 0000000..24e3cde --- /dev/null +++ b/datacat/parsers/src/main/java/org/apache/airavata/datacat/parsers/gridchem/finalcoord/FinalCoordParser.java @@ -0,0 +1,466 @@ +/* +* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +* +*/ +package org.apache.airavata.datacat.parsers.gridchem.finalcoord; + +import java_cup.runtime.lr_parser; +import org.apache.airavata.datacat.parsers.gridchem.GridChemQueueParser; + +import javax.swing.*; +import java.io.FileReader; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Stack; + + +public class FinalCoordParser extends java_cup.runtime.lr_parser implements GridChemQueueParser { + + /** + * Constructor which uses a file reader. + */ + public FinalCoordParser(final FileReader fileReader) { + super(new FinalCoordLexer(fileReader)); + } + + + + + /** + * Production table. + */ + protected static final short _production_table[][] = + lr_parser.unpackFromStrings(new String[]{ + "\000\016\000\002\003\005\000\002\002\004\000\002\004" + + "\003\000\002\005\004\000\002\005\003\000\002\006\006" + + "\000\002\017\004\000\002\017\003\000\002\020\010\000" + + "\002\012\003\000\002\013\003\000\002\014\003\000\002" + + "\015\003\000\002\016\003"}); + /** + * Parse-action table. + */ + protected static final short[][] _action_table = + lr_parser.unpackFromStrings(new String[]{ + "\000\032\000\004\005\005\001\002\000\004\004\010\001" + + "\002\000\004\004\uffff\001\002\000\004\002\007\001\002" + + "\000\004\002\000\001\002\000\004\007\015\001\002\000" + + "\006\004\010\006\013\001\002\000\006\004\ufffd\006\ufffd" + + "\001\002\000\004\002\001\001\002\000\006\004\ufffe\006" + + "\ufffe\001\002\000\004\011\016\001\002\000\004\012\ufff8" + + "\001\002\000\004\012\025\001\002\000\006\010\ufffa\011" + + "\ufffa\001\002\000\006\010\022\011\016\001\002\000\006" + + "\004\ufffc\006\ufffc\001\002\000\006\010\ufffb\011\ufffb\001" + + "\002\000\004\013\026\001\002\000\004\013\ufff7\001\002" + + "\000\004\016\027\001\002\000\004\017\ufff6\001\002\000" + + "\004\017\031\001\002\000\004\020\ufff5\001\002\000\004" + + "\020\033\001\002\000\006\010\ufff4\011\ufff4\001\002\000" + + "\006\010\ufff9\011\ufff9\001\002"}); + /** + * <code>reduce_goto</code> table. + */ + protected static final short[][] _reduce_table = + lr_parser.unpackFromStrings(new String[]{ + "\000\032\000\006\003\005\004\003\001\001\000\006\005" + + "\010\006\011\001\001\000\002\001\001\000\002\001\001" + + "\000\002\001\001\000\002\001\001\000\004\006\013\001" + + "\001\000\002\001\001\000\002\001\001\000\002\001\001" + + "\000\010\012\016\017\020\020\017\001\001\000\002\001" + + "\001\000\004\013\023\001\001\000\002\001\001\000\006" + + "\012\016\020\022\001\001\000\002\001\001\000\002\001" + + "\001\000\002\001\001\000\002\001\001\000\004\014\027" + + "\001\001\000\002\001\001\000\004\015\031\001\001\000" + + "\002\001\001\000\004\016\033\001\001\000\002\001\001" + + "\000\002\001\001"}); + /** + * Instance of action encapsulation class. + */ + protected CUP$parser$actions action_obj; + //Each string is of the format + //center# atomic# x_coord y_coord z_coord + private ArrayList<String> result = new ArrayList<String>(); + private String tempStr = ""; + + /** + * Default constructor. + */ + public FinalCoordParser() { + super(); + } + + /** + * Constructor which sets the default scanner. + */ + public FinalCoordParser(java_cup.runtime.Scanner s) { + super(s); + } + + /** + * Access to production table. + */ + + @Override + public short[][] production_table() { + return _production_table; + } + + /** + * Access to parse-action table. + */ + @Override + public short[][] action_table() { + return _action_table; + } + + + + /** + * Access to <code>reduce_goto</code> table. + */ + + @Override + public short[][] reduce_table() { + return _reduce_table; + } + + public ArrayList<String> getResult() { + return result; + } + + public void addToResult(String value) { + result.add(value); + } + + public String getTempStr() { + return tempStr; + } + + public void setTempStr(String s) { + this.tempStr = s; + } + + /*Adding the parsed data to the hash map */ + @Override + public HashMap<String, String> getParsedData() throws Exception { + parse(); + HashMap<String,String> results= new HashMap<String,String>(); + int zCount=0; + int xCount=0; + int yCount=0; + int center=0; + int atom=0; + for(int i=0;i<result.size();i++){ + String singleString= result.get(i); + String[] temp=singleString.split(" "); + if(temp.length>1){ + String keyElement=temp[0]; + String dataElement=temp[1]; + if(keyElement.equals("Z")){ + results.put("FinalCoordParser_Z_coord_"+zCount,dataElement); + zCount++; + }else if(keyElement.equals("Y")){ + results.put("FinalCoordParser_Y_coord_"+yCount,dataElement); + yCount++; + }else if(keyElement.equals("X")) { + results.put("FinalCoordParser_X_coord_" + xCount, dataElement); + xCount++; + }else if(keyElement.equals("Atom")) { + results.put("FinalCoordParser_AtomicNumber_" + atom, dataElement); + atom++; + }else if(keyElement.equals("center")) { + results.put("FinalCoordParser_CenterNumber_" + center, dataElement); + center++; + } + } + + + } + + return results; + } + + + + + /** + * Action encapsulation object initializer. + */ + protected void init_actions() { + action_obj = new CUP$parser$actions(this); + } + + /** + * Invoke a user supplied parse action. + */ + public java_cup.runtime.Symbol do_action( + int act_num, + java_cup.runtime.lr_parser parser, + Stack stack, + int top) + throws Exception { + /* call code in generated class */ + return action_obj.CUP$parser$do_action(act_num, parser, stack, top); + } + + /** + * Indicates start state. + */ + public int start_state() { + return 0; + } + + /** + * Indicates start production. + */ + public int start_production() { + return 1; + } + + /** + * <code>EOF</code> Symbol index. + */ + public int EOF_sym() { + return 0; + } + + /** + * <code>error</code> Symbol index. + */ + public int error_sym() { + return 1; + } + + +} + +/** + * Cup generated class to encapsulate user supplied action code. + */ +class CUP$parser$actions { + + + private static final String tableLabel = "SCF Intermediate Results:"; + //__________________________________ + public static boolean DEBUG = false; + private static JTable table; + // private static String cycle = "0"; + private final FinalCoordParser FinalCoordParser; + + /** + * Constructor + */ + CUP$parser$actions(FinalCoordParser FinalCoordParser) { + this.FinalCoordParser = FinalCoordParser; + } + +// } + + public static JTable getTable() { + return table; + } + + public static String getTableLabel() { + return tableLabel; + } + + /** + * Method with the actual generated action code. + */ + public final java_cup.runtime.Symbol CUP$parser$do_action( + int CUP$parser$act_num, + java_cup.runtime.lr_parser CUP$parser$parser, + Stack CUP$parser$stack, + int CUP$parser$top) + throws Exception { + /* Symbol object for return from actions */ + java_cup.runtime.Symbol CUP$parser$result; + + /* select the action based on the action number */ + switch (CUP$parser$act_num) { + /*. . . . . . . . . . . . . . . . . . . .*/ + case 13: // inp7 ::= INPUT7 + { + Object RESULT = null; + int in7left = ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top - 0)).left; + int in7right = ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top - 0)).right; + Float in7 = (Float) ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top - 0)).value; + //___________________________________________________________________ + if (DEBUG) System.out.println("CUP:Input: z coordinate " + in7); + FinalCoordParser.setTempStr(FinalCoordParser.getTempStr() + "," + in7); + FinalCoordParser.getResult().add(FinalCoordParser.getTempStr()); + FinalCoordParser.setTempStr(""); + FinalCoordParser.addToResult("Z "+in7); + CUP$parser$result = new java_cup.runtime.Symbol(12/*inp7*/, ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top - 0)).left, ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top - 0)).right, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 12: // inp6 ::= INPUT6 + { + Object RESULT = null; + int in6left = ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top - 0)).left; + int in6right = ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top - 0)).right; + Float in6 = (Float) ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top - 0)).value; + //___________________________________________________________________ + if (DEBUG) System.out.println("CUP:Input: y coordinate " + in6); + FinalCoordParser.setTempStr(FinalCoordParser.getTempStr() + "," + in6); + FinalCoordParser.addToResult("Y "+in6); + CUP$parser$result = new java_cup.runtime.Symbol(11/*inp6*/, ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top - 0)).left, ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top - 0)).right, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 11: // inp5 ::= INPUT5 + { + Object RESULT = null; + int in5left = ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top - 0)).left; + int in5right = ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top - 0)).right; + Float in5 = (Float) ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top - 0)).value; + //___________________________________________________________________ + if (DEBUG) System.out.println("CUP:Input: x coordinate " + in5); + FinalCoordParser.setTempStr(FinalCoordParser.getTempStr() + "," + in5); + FinalCoordParser.addToResult("X "+in5); + CUP$parser$result = new java_cup.runtime.Symbol(10/*inp5*/, ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top - 0)).left, ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top - 0)).right, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 10: // inp3 ::= INPUT3 + { + Object RESULT = null; + int in3left = ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top - 0)).left; + int in3right = ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top - 0)).right; + Integer in3 = (Integer) ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top - 0)).value; + //___________________________________________________________________ + if (DEBUG) System.out.println("CUP:Input: atomic number " + in3); + FinalCoordParser.setTempStr(FinalCoordParser.getTempStr() + "," + in3); + FinalCoordParser.addToResult("Atom "+in3); + CUP$parser$result = new java_cup.runtime.Symbol(9/*inp3*/, ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top - 0)).left, ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top - 0)).right, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 9: // inp2 ::= INPUT2 + { + Object RESULT = null; + int in2left = ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top - 0)).left; + int in2right = ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top - 0)).right; + Integer in2 = (Integer) ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top - 0)).value; + //___________________________________________________________________ + if (DEBUG) System.out.println("CUP:Input: center number " + in2); + FinalCoordParser.addToResult("center "+in2); + FinalCoordParser.setTempStr(FinalCoordParser.getTempStr() + in2); + CUP$parser$result = new java_cup.runtime.Symbol(8/*inp2*/, ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top - 0)).left, ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top - 0)).right, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 8: // cycle2 ::= inp2 inp3 INPUT4 inp5 inp6 inp7 + { + Object RESULT = null; + + CUP$parser$result = new java_cup.runtime.Symbol(14/*cycle2*/, ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top - 5)).left, ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top - 0)).right, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 7: // cycle1 ::= cycle2 + { + Object RESULT = null; + + CUP$parser$result = new java_cup.runtime.Symbol(13/*cycle1*/, ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top - 0)).left, ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top - 0)).right, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 6: // cycle1 ::= cycle1 cycle2 + { + Object RESULT = null; + + CUP$parser$result = new java_cup.runtime.Symbol(13/*cycle1*/, ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top - 1)).left, ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top - 0)).right, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 5: // scfcycle ::= INPUT1 DASH1 cycle1 DASH2 + { + Object RESULT = null; + + CUP$parser$result = new java_cup.runtime.Symbol(4/*scfcycle*/, ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top - 3)).left, ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top - 0)).right, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 4: // scfpat ::= scfcycle + { + Object RESULT = null; + + CUP$parser$result = new java_cup.runtime.Symbol(3/*scfpat*/, ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top - 0)).left, ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top - 0)).right, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 3: // scfpat ::= scfpat scfcycle + { + Object RESULT = null; + if (DEBUG) System.out.println("CUP:Input: in scfpat"); + CUP$parser$result = new java_cup.runtime.Symbol(3/*scfpat*/, ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top - 1)).left, ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top - 0)).right, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 2: // scfintro ::= FOUNDITER + { + Object RESULT = null; + if (DEBUG) System.out.println("CUP:Input: found the start of Iteration"); + CUP$parser$result = new java_cup.runtime.Symbol(2/*scfintro*/, ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top - 0)).left, ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top - 0)).right, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 1: // $START ::= startpt EOF + { + Object RESULT = null; + int start_valleft = ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top - 1)).left; + int start_valright = ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top - 1)).right; + Object start_val = (Object) ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top - 1)).value; + RESULT = start_val; + CUP$parser$result = new java_cup.runtime.Symbol(0/*$START*/, ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top - 1)).left, ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top - 0)).right, RESULT); + } + /* ACCEPT */ + CUP$parser$parser.done_parsing(); + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 0: // startpt ::= scfintro scfpat SCFDONE + { + Object RESULT = null; + + CUP$parser$result = new java_cup.runtime.Symbol(1/*startpt*/, ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top - 2)).left, ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top - 0)).right, RESULT); + } + return CUP$parser$result; + + /* . . . . . .*/ + default: + throw new Exception( + "Invalid action number found in internal parse table"); + + } + } +} + http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/4231ac35/datacat/parsers/src/main/java/org/apache/airavata/datacat/parsers/gridchem/finalcoord/FinalCoordSym.java ---------------------------------------------------------------------- diff --git a/datacat/parsers/src/main/java/org/apache/airavata/datacat/parsers/gridchem/finalcoord/FinalCoordSym.java b/datacat/parsers/src/main/java/org/apache/airavata/datacat/parsers/gridchem/finalcoord/FinalCoordSym.java new file mode 100644 index 0000000..e30a7ab --- /dev/null +++ b/datacat/parsers/src/main/java/org/apache/airavata/datacat/parsers/gridchem/finalcoord/FinalCoordSym.java @@ -0,0 +1,48 @@ +/* +* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +* +*/ +package org.apache.airavata.datacat.parsers.gridchem.finalcoord; +//---------------------------------------------------- +// The following code was generated by CUP v0.10k +// Sun Aug 03 21:31:23 IST 2014 +//---------------------------------------------------- + +/** + * CUP generated class containing symbol constants. + */ +public class FinalCoordSym { + /* terminals */ + public static final int ENERGY = 11; + public static final int EOF = 0; + public static final int ITERATION = 10; + public static final int INPUT7 = 14; + public static final int error = 1; + public static final int INPUT6 = 13; + public static final int INPUT5 = 12; + public static final int INPUT4 = 9; + public static final int SCFDONE = 4; + public static final int INPUT3 = 8; + public static final int FOUNDITER = 3; + public static final int INPUT2 = 7; + public static final int DASH2 = 6; + public static final int INPUT1 = 2; + public static final int DASH1 = 5; +} + http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/4231ac35/datacat/parsers/src/main/java/org/apache/airavata/datacat/parsers/gridchem/g1/G1Lexer.java ---------------------------------------------------------------------- diff --git a/datacat/parsers/src/main/java/org/apache/airavata/datacat/parsers/gridchem/g1/G1Lexer.java b/datacat/parsers/src/main/java/org/apache/airavata/datacat/parsers/gridchem/g1/G1Lexer.java new file mode 100644 index 0000000..2c7d9e5 --- /dev/null +++ b/datacat/parsers/src/main/java/org/apache/airavata/datacat/parsers/gridchem/g1/G1Lexer.java @@ -0,0 +1,913 @@ +/* +* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +* +*/ +package org.apache.airavata.datacat.parsers.gridchem.g1;/* The following code was generated by JFlex 1.4.3 on 9/10/14 8:33 AM */ + +import java_cup.runtime.Symbol; +import org.apache.airavata.datacat.parsers.gridchem.Settings; + + +/** + * This class is a scanner generated by + * <a href="http://www.jflex.de/">JFlex</a> 1.4.3 + * on 9/10/14 8:33 AM from the specification file + * <tt>g1.flex</tt> + */ +public class G1Lexer implements java_cup.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 FLOATMP3 = 24; + public static final int ITER2 = 4; + public static final int FLOATMP2 = 22; + public static final int FLOATMP1 = 20; + public static final int MPOPT = 18; + public static final int INTMP = 28; + public static final int INTVALUE = 8; + public static final int IGNOREALL = 26; + public static final int ITER = 2; + public static final int YYINITIAL = 0; + public static final int MP2 = 16; + public static final int FLOAT2 = 14; + public static final int FLOAT1 = 12; + public static final int FLOATVALUE = 10; + public static final int ITER3 = 6; + + /** + * ZZ_LEXSTATE[l] is the state in the DFA for the lexical state l + * ZZ_LEXSTATE[l+1] is the state in the DFA for the lexical state l + * at the beginning of a line + * l is of the form l = 2*k, k a non negative integer + */ + private static final int ZZ_LEXSTATE[] = { + 0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, + 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 2, 2, 12, 12 + }; + + /** + * Translates characters to character classes + */ + private static final char [] ZZ_CMAP = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 14, 0, 0, 0, 0, 0, 0, 0, 29, 7, 0, 3, 0, 46, 4, 1, + 2, 48, 44, 47, 2, 2, 45, 2, 2, 2, 27, 0, 0, 6, 0, 0, + 0, 0, 0, 24, 26, 28, 25, 49, 31, 41, 0, 0, 42, 32, 8, 36, + 43, 0, 30, 23, 5, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, + 0, 33, 11, 35, 39, 12, 16, 0, 22, 20, 0, 0, 38, 10, 21, 15, + 19, 0, 13, 17, 18, 9, 0, 0, 34, 0, 37, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + }; + + /** + * Translates DFA states to action switch labels. + */ + private static final int [] ZZ_ACTION = zzUnpackAction(); + + private static final String ZZ_ACTION_PACKED_0 = + "\15\0\7\1\1\2\25\1\1\3\1\1\42\0\1\4"+ + "\1\5\1\6\10\0\1\7\1\10\1\11\107\0\1\12"+ + "\41\0\1\13\7\0\1\14\22\0\1\15\1\16\4\0"+ + "\1\17\1\20\12\0\1\21\2\0\1\22\1\0\1\23"+ + "\16\0\1\24\2\0\1\25\11\0\1\26\1\27\4\0"+ + "\1\30"; + + private static int [] zzUnpackAction() { + int [] result = new int[282]; + 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\63\0\146\0\231\0\314\0\377\0\u0132\0\u0165"+ + "\0\u0198\0\u01cb\0\u01fe\0\u0231\0\u0264\0\u0297\0\u02ca\0\u02fd"+ + "\0\u0330\0\u0363\0\u0396\0\u03c9\0\u03fc\0\u03fc\0\u042f\0\u0462"+ + "\0\u0495\0\u04c8\0\u04fb\0\u052e\0\u0561\0\u0594\0\u05c7\0\u05fa"+ + "\0\u062d\0\u0660\0\u0693\0\u06c6\0\u06f9\0\u072c\0\u075f\0\u0792"+ + "\0\u07c5\0\u07f8\0\u082b\0\u082b\0\u085e\0\u0891\0\u08c4\0\u08f7"+ + "\0\u092a\0\u095d\0\u0990\0\u042f\0\u09c3\0\u0495\0\u09f6\0\u04fb"+ + "\0\u0a29\0\u0a5c\0\u0a8f\0\u0ac2\0\u0af5\0\u0b28\0\u0b5b\0\u0b8e"+ + "\0\u0bc1\0\u06f9\0\u0bf4\0\u075f\0\u0c27\0\u07c5\0\u0c5a\0\u0c8d"+ + "\0\u0cc0\0\u0cf3\0\u0d26\0\u0d59\0\u0d8c\0\u0dbf\0\u09c3\0\u09f6"+ + "\0\u0a29\0\u0df2\0\u0e25\0\u0e58\0\u0e8b\0\u0ebe\0\u0ef1\0\u0f24"+ + "\0\u0f57\0\u0bf4\0\u0c27\0\u0c5a\0\u0f8a\0\u0fbd\0\u0ff0\0\u1023"+ + "\0\u1056\0\u1089\0\u10bc\0\u10ef\0\u1122\0\u1155\0\u1188\0\u11bb"+ + "\0\u11ee\0\u1221\0\u1254\0\u1287\0\u12ba\0\u12ed\0\u1320\0\u1353"+ + "\0\u1386\0\u13b9\0\u13ec\0\u141f\0\u1452\0\u1485\0\u14b8\0\u14eb"+ + "\0\u151e\0\u1551\0\u1584\0\u15b7\0\u15ea\0\u161d\0\u1650\0\u1683"+ + "\0\u16b6\0\u16e9\0\u171c\0\u174f\0\u1782\0\u17b5\0\u17e8\0\u181b"+ + "\0\u184e\0\u1881\0\u18b4\0\u18e7\0\u191a\0\u194d\0\u1980\0\u19b3"+ + "\0\u19e6\0\u1a19\0\u1a4c\0\u1a7f\0\u1ab2\0\u1ae5\0\u1b18\0\u1b4b"+ + "\0\u1b7e\0\u1bb1\0\u1be4\0\u1c17\0\u1c4a\0\u1c7d\0\u1cb0\0\u1ce3"+ + "\0\u1d16\0\u1d49\0\u1d7c\0\u0297\0\u1daf\0\u1de2\0\u1e15\0\u1e48"+ + "\0\u1e7b\0\u1eae\0\u1ee1\0\u1f14\0\u1f47\0\u1f7a\0\u1fad\0\u1fe0"+ + "\0\u2013\0\u2046\0\u2079\0\u20ac\0\u20df\0\u2112\0\u2145\0\u2178"+ + "\0\u21ab\0\u21de\0\u2211\0\u2244\0\u2277\0\u22aa\0\u22dd\0\u2310"+ + "\0\u2343\0\u2376\0\u23a9\0\u23dc\0\u240f\0\u0297\0\u2442\0\u2475"+ + "\0\u24a8\0\u24db\0\u250e\0\u2541\0\u2574\0\u0297\0\u25a7\0\u25da"+ + "\0\u260d\0\u2640\0\u2673\0\u26a6\0\u26d9\0\u270c\0\u273f\0\u2772"+ + "\0\u27a5\0\u27d8\0\u280b\0\u283e\0\u2871\0\u28a4\0\u28d7\0\u290a"+ + "\0\u0297\0\u0297\0\u293d\0\u2970\0\u29a3\0\u29d6\0\u0297\0\u0297"+ + "\0\u2a09\0\u2a3c\0\u2a6f\0\u2aa2\0\u2ad5\0\u2b08\0\u2b3b\0\u2b6e"+ + "\0\u2ba1\0\u2bd4\0\u0297\0\u2c07\0\u2c3a\0\u0297\0\u2c6d\0\u0297"+ + "\0\u2ca0\0\u2cd3\0\u2d06\0\u2d39\0\u2d6c\0\u2d9f\0\u2dd2\0\u2e05"+ + "\0\u2e38\0\u2e6b\0\u2e9e\0\u2ed1\0\u2f04\0\u2f37\0\u0297\0\u2f6a"+ + "\0\u2f9d\0\u0297\0\u2fd0\0\u3003\0\u3036\0\u3069\0\u309c\0\u30cf"+ + "\0\u3102\0\u3135\0\u3168\0\u0297\0\u0297\0\u319b\0\u31ce\0\u3201"+ + "\0\u3234\0\u0297"; + + private static int [] zzUnpackRowMap() { + int [] result = new int[282]; + 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 = + "\10\16\1\17\57\16\1\20\21\16\1\21\6\16\1\22"+ + "\1\16\1\23\3\16\1\24\103\16\1\25\1\26\50\16"+ + "\2\25\1\26\2\25\4\16\1\27\1\30\50\16\2\27"+ + "\1\30\2\27\4\16\1\31\1\32\50\16\2\31\1\32"+ + "\2\31\4\16\1\33\1\34\50\16\2\33\1\34\2\33"+ + "\7\16\1\35\32\16\1\36\27\16\1\37\21\16\1\40"+ + "\4\16\1\41\1\16\1\42\1\16\1\43\3\16\1\44"+ + "\20\16\1\45\1\46\50\16\2\45\1\46\2\45\4\16"+ + "\1\47\1\50\50\16\2\47\1\50\2\47\4\16\1\51"+ + "\1\52\50\16\2\51\1\52\2\51\4\16\1\53\1\54"+ + "\50\16\2\53\1\54\2\53\2\16\74\0\1\55\110\0"+ + "\1\56\45\0\1\57\5\0\1\60\72\0\1\61\63\0"+ + "\1\62\44\0\1\63\41\0\1\25\51\0\2\25\1\0"+ + "\2\25\4\0\1\64\1\0\1\65\47\0\2\64\1\0"+ + "\2\64\4\0\1\64\51\0\2\64\1\0\2\64\4\0"+ + "\1\66\1\0\1\67\47\0\2\66\1\0\2\66\4\0"+ + "\1\66\51\0\2\66\1\0\2\66\4\0\1\70\1\0"+ + "\1\71\47\0\2\70\1\0\2\70\4\0\1\70\51\0"+ + "\2\70\1\0\2\70\41\0\1\72\76\0\1\73\46\0"+ + "\1\74\45\0\1\75\122\0\1\76\40\0\1\77\63\0"+ + "\1\100\44\0\1\101\41\0\1\102\1\0\1\103\47\0"+ + "\2\102\1\0\2\102\4\0\1\102\51\0\2\102\1\0"+ + "\2\102\4\0\1\104\1\0\1\105\47\0\2\104\1\0"+ + "\2\104\4\0\1\104\51\0\2\104\1\0\2\104\4\0"+ + "\1\106\1\0\1\107\47\0\2\106\1\0\2\106\4\0"+ + "\1\106\51\0\2\106\1\0\2\106\4\0\1\53\51\0"+ + "\2\53\1\0\2\53\14\0\1\110\104\0\1\111\42\0"+ + "\1\112\77\0\1\113\60\0\1\114\75\0\1\115\42\0"+ + "\1\116\42\0\1\117\51\0\2\117\1\0\2\117\4\0"+ + "\1\120\51\0\2\120\1\0\2\120\4\0\1\121\51\0"+ + "\2\121\1\0\2\121\36\0\1\122\102\0\1\123\42\0"+ + "\1\124\42\0\1\125\106\0\1\126\51\0\1\127\75\0"+ + "\1\130\42\0\1\131\42\0\1\132\51\0\2\132\1\0"+ + "\2\132\4\0\1\133\51\0\2\133\1\0\2\133\4\0"+ + "\1\134\51\0\2\134\1\0\2\134\15\0\1\135\117\0"+ + "\1\136\35\0\1\137\55\0\1\140\62\0\1\141\70\0"+ + "\1\142\62\0\1\143\106\0\1\144\47\0\1\145\75\0"+ + "\1\146\35\0\1\147\112\0\1\150\25\0\1\151\70\0"+ + "\1\152\62\0\1\153\52\0\1\154\102\0\1\155\44\0"+ + "\1\156\76\0\1\157\46\0\1\160\56\0\1\161\62\0"+ + "\1\162\104\0\1\163\57\0\1\164\65\0\1\165\44\0"+ + "\1\166\120\0\1\167\24\0\1\170\56\0\1\171\62\0"+ + "\1\172\65\0\1\173\55\0\1\174\77\0\1\175\54\0"+ + "\1\176\61\0\1\177\55\0\1\200\75\0\1\201\46\0"+ + "\1\202\63\0\1\203\61\0\1\204\77\0\1\205\53\0"+ + "\1\206\62\0\1\207\55\0\1\210\75\0\1\211\54\0"+ + "\1\212\76\0\1\213\41\0\1\214\76\0\1\215\53\0"+ + "\1\216\56\0\1\217\115\0\1\220\47\0\1\221\76\0"+ + "\1\222\46\0\1\223\41\0\1\224\57\0\1\225\72\0"+ + "\1\226\56\0\1\227\115\0\1\230\34\0\1\231\113\0"+ + "\1\232\24\0\1\233\64\0\1\234\64\0\1\235\62\0"+ + "\1\236\105\0\1\237\71\0\1\240\60\0\1\241\64\0"+ + "\1\242\24\0\1\243\66\0\1\244\62\0\1\245\62\0"+ + "\1\246\105\0\1\247\41\0\1\250\106\0\1\251\31\0"+ + "\1\252\102\0\1\253\60\0\1\254\62\0\1\255\53\0"+ + "\1\256\104\0\1\257\25\0\1\260\117\0\1\261\31\0"+ + "\1\262\100\0\1\263\62\0\1\264\53\0\1\265\56\0"+ + "\1\266\75\0\1\267\45\0\1\270\64\0\1\271\63\0"+ + "\1\272\62\0\1\273\67\0\1\274\67\0\1\275\32\0"+ + "\1\276\112\0\1\277\45\0\1\300\65\0\1\301\62\0"+ + "\1\302\67\0\1\303\57\0\1\304\111\0\1\305\27\0"+ + "\1\306\63\0\1\307\61\0\1\310\62\0\1\311\64\0"+ + "\1\312\113\0\1\313\67\0\1\314\55\0\1\315\27\0"+ + "\1\316\62\0\1\317\62\0\1\320\64\0\1\321\65\0"+ + "\1\322\71\0\1\323\65\0\1\324\71\0\1\325\62\0"+ + "\1\326\44\0\1\327\66\0\1\330\107\0\1\331\35\0"+ + "\1\332\74\0\1\333\62\0\1\334\44\0\1\335\51\0"+ + "\1\336\117\0\1\337\46\0\1\340\41\0\1\341\62\0"+ + "\1\342\64\0\1\343\115\0\1\344\70\0\1\345\54\0"+ + "\1\346\25\0\1\347\62\0\1\350\64\0\1\351\67\0"+ + "\1\352\111\0\1\353\46\0\1\354\67\0\1\355\71\0"+ + "\1\356\70\0\1\357\54\0\1\360\53\0\1\361\40\0"+ + "\1\362\75\0\1\363\65\0\1\364\42\0\1\365\77\0"+ + "\1\366\107\0\1\367\35\0\1\370\45\0\1\371\61\0"+ + "\1\372\75\0\1\373\43\0\1\374\105\0\1\375\37\0"+ + "\1\376\74\0\1\377\45\0\1\u0100\76\0\1\u0101\106\0"+ + "\1\u0102\36\0\1\u0103\64\0\1\u0104\53\0\1\u0105\112\0"+ + "\1\u0106\23\0\1\u0107\121\0\1\u0108\32\0\1\u0109\52\0"+ + "\1\u010a\70\0\1\u010b\62\0\1\u010c\70\0\1\u010d\62\0"+ + "\1\u010e\62\0\1\u010f\66\0\1\u0110\50\0\1\u0111\62\0"+ + "\1\u0112\72\0\1\u0113\105\0\1\u0114\62\0\1\u0115\34\0"+ + "\1\u0116\57\0\1\u0117\61\0\1\u0118\56\0\1\u0119\76\0"+ + "\1\u011a\35\0"; + + private static int [] zzUnpackTrans() { + int [] result = new int[12903]; + 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 = + "\15\0\1\11\36\1\42\0\3\1\10\0\3\1\107\0"+ + "\1\11\41\0\1\11\7\0\1\11\22\0\2\11\4\0"+ + "\2\11\12\0\1\11\2\0\1\11\1\0\1\11\16\0"+ + "\1\11\2\0\1\11\11\0\2\11\4\0\1\11"; + + private static int [] zzUnpackAttribute() { + int [] result = new int[282]; + 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 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; + + /** denotes if the user-EOF-code has already been executed */ + private boolean zzEOFDone; + + /* user code: */ + public static boolean DEBUG = false; + + + /** + * 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 G1Lexer(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 G1Lexer(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; + 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) { + zzEndRead+= numRead; + return false; + } + // unlikely but not impossible: read 0 characters, but not at end of stream + if (numRead == 0) { + int c = zzReader.read(); + if (c == -1) { + return true; + } else { + zzBuffer[zzEndRead++] = (char) c; + return false; + } + } + + // numRead < 0 + return true; + } + + + /** + * 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; + zzEOFDone = false; + zzEndRead = zzStartRead = 0; + zzCurrentPos = zzMarkedPos = 0; + yyline = yychar = 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.runtime.Symbol next_token() throws java.io.IOException { + int zzInput; + int zzAction; + + // cached fields: + 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; + + zzAction = -1; + + zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL; + + zzState = ZZ_LEXSTATE[zzLexicalState]; + + + zzForAction: { + while (true) { + + if (zzCurrentPosL < zzEndReadL) + zzInput = zzBufferL[zzCurrentPosL++]; + else if (zzAtEOF) { + zzInput = YYEOF; + break zzForAction; + } + else { + // store back cached positions + zzCurrentPos = zzCurrentPosL; + zzMarkedPos = zzMarkedPosL; + boolean eof = zzRefill(); + // get translated positions and possibly new buffer + 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; + } + + } + } + + // store back cached position + zzMarkedPos = zzMarkedPosL; + + switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) { + case 23: + { yybegin(IGNOREALL); + return new Symbol(G1Sym.MPDONE); + } + case 25: break; + case 4: + { if (Settings.DEBUG) System.out.println("G1Flex: Found the energy in FLOATVALUE"); + if (Settings.DEBUG) System.out.println(yytext()); + yybegin(ITER); + return new Symbol(G1Sym.ENERGY1, new Float(yytext())); + } + case 26: break; + case 2: + { if (Settings.DEBUG) System.out.println("G1Flex: Found iteration"); + if (Settings.DEBUG) System.out.println(yytext()); + yybegin (ITER); + return new Symbol(G1Sym.ITERATION1, new Integer(yytext())); + } + case 27: break; + case 22: + { if (Settings.DEBUG) System.out.println("G1Flex: SCFDONE1, Optimization completed"); + yybegin(MP2); + return new Symbol(G1Sym.SCFDONE1); + } + case 28: break; + case 17: + { if (Settings.DEBUG) System.out.println("G1Flex: SCFDONE1, THE_END_OF_FILE"); + yybegin(MP2); + return new Symbol(G1Sym.SCFDONE1); + } + case 29: break; + case 12: + { if (Settings.DEBUG) System.out.println("G1Flex: Found the Step number for MP"); + yybegin(INTMP); + return new Symbol(G1Sym.NMP); + } + case 30: break; + case 24: + { if (Settings.DEBUG) System.out.println("G1lex: Found Number of steps"); + yybegin(ITER); + return new Symbol(G1Sym.FOUNDITER1); + } + case 31: break; + case 11: + { if (Settings.DEBUG) System.out.println("G1Flex: Found the Step number"); + yybegin(INTVALUE); + return new Symbol(G1Sym.NSearch1); + } + case 32: break; + case 9: + { if (Settings.DEBUG) System.out.println("G1Flex: Found the RMS force"); +if (Settings.DEBUG) System.out.println(yytext()); + yybegin(MPOPT); + return new Symbol(G1Sym.MPRGRAD, new Float(yytext())); + } + case 33: break; + case 3: + { if (Settings.DEBUG) System.out.println("G1Flex: Found iteration"); + if (Settings.DEBUG) System.out.println(yytext()); + yybegin (MPOPT); + return new Symbol(G1Sym.MPITER, new Integer(yytext())); + } + case 34: break; + case 21: + { if (Settings.DEBUG) System.out.println("G1Flex: Found the energy in ITER"); + yybegin(FLOATVALUE); + return new Symbol(G1Sym.Energ1); + } + case 35: break; + case 19: + { if (Settings.DEBUG) System.out.println("G1Flex: MPDONE, THE_END_OF_FILE"); + yybegin(IGNOREALL); + return new Symbol(G1Sym.MPDONE); + } + case 36: break; + case 10: + { if (Settings.DEBUG) System.out.println("G1Flex: Found MP2 energy"); + yybegin(FLOATMP1); + return new Symbol(G1Sym.MPEnerg); + } + case 37: break; + case 20: + { if (Settings.DEBUG) System.out.println("G1Flex: Found MP2(Full)"); + yybegin(MPOPT); + return new Symbol(G1Sym.MPStart); + } + case 38: break; + case 8: + { if (Settings.DEBUG) System.out.println("G1Flex: Found the maximum force"); + if (Settings.DEBUG) System.out.println(yytext()); + yybegin(MPOPT); + return new Symbol(G1Sym.MPMGRAD, new Float(yytext())); + } + case 39: break; + case 14: + { if (Settings.DEBUG) System.out.println("G1Flex: Found Maximum Force"); + yybegin(FLOAT1); + return new Symbol(G1Sym.MaxGrad1); + } + case 40: break; + case 5: + { if (Settings.DEBUG) System.out.println("G1lex: Found the maximum force"); + if (Settings.DEBUG) System.out.println(yytext()); + yybegin(ITER); + return new Symbol(G1Sym.MGRAD1, new Float(yytext())); + } + case 41: break; + case 15: + { if (Settings.DEBUG) System.out.println("G1Flex: Found RMS Force"); + yybegin(FLOATMP3); + return new Symbol(G1Sym.MPRms); + } + case 42: break; + case 16: + { if (Settings.DEBUG) System.out.println("G1Flex: Found Maximum Force"); + yybegin(FLOATMP2); + return new Symbol(G1Sym.MPMax); + } + case 43: break; + case 7: + { if (Settings.DEBUG) System.out.println("G1Flex: Found the energy"); + if (Settings.DEBUG) System.out.println(yytext()); + yybegin(MPOPT); + return new Symbol(G1Sym.MPENERGY, new Float(yytext())); + } + case 44: break; + case 6: + { if (Settings.DEBUG) System.out.println("G1Flex: Found the RMS force"); +if (Settings.DEBUG) System.out.println(yytext()); + yybegin(ITER); + return new Symbol(G1Sym.RGRAD1, new Float(yytext())); + } + case 45: break; + case 13: + { if (Settings.DEBUG) System.out.println("G1Flex: Found RMS Force"); + yybegin(FLOAT2); + return new Symbol(G1Sym.RmsGrad1); + } + case 46: break; + case 18: + { if (Settings.DEBUG) System.out.println("G1Flex: MPStart, THE_END_OF_FILE"); + yybegin(MPOPT); + return new Symbol(G1Sym.MPStart); + } + case 47: break; + case 1: + { + } + case 48: break; + default: + if (zzInput == YYEOF && zzStartRead == zzCurrentPos) { + zzAtEOF = true; + zzDoEOF(); + { return new java_cup.runtime.Symbol(G1Sym.EOF); } + } + else { + zzScanError(ZZ_NO_MATCH); + } + } + } + } + + /** + * Converts an int token code into the name of the + * token by reflection on the cup symbol class/interface sym + * + * This code was contributed by Karl Meissner <[email protected]> + */ + private String getTokenName(int token) { + try { + java.lang.reflect.Field [] classFields = G1Sym.class.getFields(); + for (int i = 0; i < classFields.length; i++) { + if (classFields[i].getInt(null) == token) { + return classFields[i].getName(); + } + } + } catch (Exception e) { + e.printStackTrace(System.err); + } + + return "UNKNOWN TOKEN"; + } + + /** + * Same as next_token but also prints the token to standard out + * for debugging. + * + * This code was contributed by Karl Meissner <[email protected]> + */ + public java_cup.runtime.Symbol debug_next_token() throws java.io.IOException { + java_cup.runtime.Symbol s = next_token(); + System.out.println( " --"+ yytext() + "--" + getTokenName(s.sym) + "--"); + return s; + } + + /** + * Runs the scanner on input files. + * + * This is a standalone scanner, 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 G1Lexer <inputfile>"); + } + else { + for (int i = 0; i < argv.length; i++) { + G1Lexer scanner = null; + try { + scanner = new G1Lexer( new java.io.FileReader(argv[i]) ); + while ( !scanner.zzAtEOF ) scanner.next_token(); + } + catch (java.io.FileNotFoundException e) { + System.out.println("File not found : \""+argv[i]+"\""); + } + catch (java.io.IOException e) { + System.out.println("IO error scanning file \""+argv[i]+"\""); + System.out.println(e); + } + catch (Exception e) { + System.out.println("Unexpected exception:"); + e.printStackTrace(); + } + } + } + } + + +}
