--- /dev/null
+/* Generated By:JavaCC: Do not edit this line. ExpressionParser.java */\r
+package org.simantics.sysdyn.expressionParser;\r
+\r
+import java.util.List;\r
+import java.util.ArrayList;\r
+\r
+public class ExpressionParser implements ExpressionParserConstants {\r
+\r
+/*** Parser ********************************************************/\r
+\r
+// https://javacc.dev.java.net/doc/javaccgrm.html\r
+// add_op -> add_op()\r
+// [ add_op ] -> ( add_op() )?\r
+// { add_op term } -> ( add_op() term() )*\r
+ final public void arithmetic_expression() throws ParseException {\r
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
+ case 27:\r
+ case 28:\r
+ case 29:\r
+ case 30:\r
+ add_op();\r
+ break;\r
+ default:\r
+ jj_la1[0] = jj_gen;\r
+ ;\r
+ }\r
+ term();\r
+ label_1:\r
+ while (true) {\r
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
+ case 27:\r
+ case 28:\r
+ case 29:\r
+ case 30:\r
+ ;\r
+ break;\r
+ default:\r
+ jj_la1[1] = jj_gen;\r
+ break label_1;\r
+ }\r
+ add_op();\r
+ term();\r
+ }\r
+ }\r
+\r
+ final public void add_op() throws ParseException {\r
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
+ case 27:\r
+ jj_consume_token(27);\r
+ break;\r
+ case 28:\r
+ jj_consume_token(28);\r
+ break;\r
+ case 29:\r
+ jj_consume_token(29);\r
+ break;\r
+ case 30:\r
+ jj_consume_token(30);\r
+ break;\r
+ default:\r
+ jj_la1[2] = jj_gen;\r
+ jj_consume_token(-1);\r
+ throw new ParseException();\r
+ }\r
+ }\r
+\r
+ final public void term() throws ParseException {\r
+ primary();\r
+ label_2:\r
+ while (true) {\r
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
+ case 31:\r
+ case 32:\r
+ case 33:\r
+ case 34:\r
+ ;\r
+ break;\r
+ default:\r
+ jj_la1[3] = jj_gen;\r
+ break label_2;\r
+ }\r
+ mul_op();\r
+ primary();\r
+ }\r
+ }\r
+\r
+ final public void mul_op() throws ParseException {\r
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
+ case 31:\r
+ jj_consume_token(31);\r
+ break;\r
+ case 32:\r
+ jj_consume_token(32);\r
+ break;\r
+ case 33:\r
+ jj_consume_token(33);\r
+ break;\r
+ case 34:\r
+ jj_consume_token(34);\r
+ break;\r
+ default:\r
+ jj_la1[4] = jj_gen;\r
+ jj_consume_token(-1);\r
+ throw new ParseException();\r
+ }\r
+ }\r
+\r
+ final public void primary() throws ParseException {\r
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
+ case UNSIGNED_NUMBER:\r
+ jj_consume_token(UNSIGNED_NUMBER);\r
+ break;\r
+ case UNSIGNED_INTEGER:\r
+ jj_consume_token(UNSIGNED_INTEGER);\r
+ break;\r
+ case STRING:\r
+ jj_consume_token(STRING);\r
+ break;\r
+ case 39:\r
+ jj_consume_token(39);\r
+ break;\r
+ case 40:\r
+ jj_consume_token(40);\r
+ break;\r
+ case 41:\r
+ jj_consume_token(41);\r
+ break;\r
+ default:\r
+ jj_la1[5] = jj_gen;\r
+ jj_consume_token(-1);\r
+ throw new ParseException();\r
+ }\r
+ }\r
+\r
+ /** Generated Token Manager. */\r
+ public ExpressionParserTokenManager token_source;\r
+ SimpleCharStream jj_input_stream;\r
+ /** Current token. */\r
+ public Token token;\r
+ /** Next token. */\r
+ public Token jj_nt;\r
+ private int jj_ntk;\r
+ private int jj_gen;\r
+ final private int[] jj_la1 = new int[6];\r
+ static private int[] jj_la1_0;\r
+ static private int[] jj_la1_1;\r
+ static {\r
+ jj_la1_init_0();\r
+ jj_la1_init_1();\r
+ }\r
+ private static void jj_la1_init_0() {\r
+ jj_la1_0 = new int[] {0x78000000,0x78000000,0x78000000,0x80000000,0x80000000,0x0,};\r
+ }\r
+ private static void jj_la1_init_1() {\r
+ jj_la1_1 = new int[] {0x0,0x0,0x0,0x7,0x7,0x68380,};\r
+ }\r
+\r
+ /** Constructor with InputStream. */\r
+ public ExpressionParser(java.io.InputStream stream) {\r
+ this(stream, null);\r
+ }\r
+ /** Constructor with InputStream and supplied encoding */\r
+ public ExpressionParser(java.io.InputStream stream, String encoding) {\r
+ try { jj_input_stream = new SimpleCharStream(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); }\r
+ token_source = new ExpressionParserTokenManager(jj_input_stream);\r
+ token = new Token();\r
+ jj_ntk = -1;\r
+ jj_gen = 0;\r
+ for (int i = 0; i < 6; i++) jj_la1[i] = -1;\r
+ }\r
+\r
+ /** Reinitialise. */\r
+ public void ReInit(java.io.InputStream stream) {\r
+ ReInit(stream, null);\r
+ }\r
+ /** Reinitialise. */\r
+ public void ReInit(java.io.InputStream stream, String encoding) {\r
+ try { jj_input_stream.ReInit(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); }\r
+ token_source.ReInit(jj_input_stream);\r
+ token = new Token();\r
+ jj_ntk = -1;\r
+ jj_gen = 0;\r
+ for (int i = 0; i < 6; i++) jj_la1[i] = -1;\r
+ }\r
+\r
+ /** Constructor. */\r
+ public ExpressionParser(java.io.Reader stream) {\r
+ jj_input_stream = new SimpleCharStream(stream, 1, 1);\r
+ token_source = new ExpressionParserTokenManager(jj_input_stream);\r
+ token = new Token();\r
+ jj_ntk = -1;\r
+ jj_gen = 0;\r
+ for (int i = 0; i < 6; i++) jj_la1[i] = -1;\r
+ }\r
+\r
+ /** Reinitialise. */\r
+ public void ReInit(java.io.Reader stream) {\r
+ jj_input_stream.ReInit(stream, 1, 1);\r
+ token_source.ReInit(jj_input_stream);\r
+ token = new Token();\r
+ jj_ntk = -1;\r
+ jj_gen = 0;\r
+ for (int i = 0; i < 6; i++) jj_la1[i] = -1;\r
+ }\r
+\r
+ /** Constructor with generated Token Manager. */\r
+ public ExpressionParser(ExpressionParserTokenManager tm) {\r
+ token_source = tm;\r
+ token = new Token();\r
+ jj_ntk = -1;\r
+ jj_gen = 0;\r
+ for (int i = 0; i < 6; i++) jj_la1[i] = -1;\r
+ }\r
+\r
+ /** Reinitialise. */\r
+ public void ReInit(ExpressionParserTokenManager tm) {\r
+ token_source = tm;\r
+ token = new Token();\r
+ jj_ntk = -1;\r
+ jj_gen = 0;\r
+ for (int i = 0; i < 6; i++) jj_la1[i] = -1;\r
+ }\r
+\r
+ private Token jj_consume_token(int kind) throws ParseException {\r
+ Token oldToken;\r
+ if ((oldToken = token).next != null) token = token.next;\r
+ else token = token.next = token_source.getNextToken();\r
+ jj_ntk = -1;\r
+ if (token.kind == kind) {\r
+ jj_gen++;\r
+ return token;\r
+ }\r
+ token = oldToken;\r
+ jj_kind = kind;\r
+ throw generateParseException();\r
+ }\r
+\r
+\r
+/** Get the next Token. */\r
+ final public Token getNextToken() {\r
+ if (token.next != null) token = token.next;\r
+ else token = token.next = token_source.getNextToken();\r
+ jj_ntk = -1;\r
+ jj_gen++;\r
+ return token;\r
+ }\r
+\r
+/** Get the specific Token. */\r
+ final public Token getToken(int index) {\r
+ Token t = token;\r
+ for (int i = 0; i < index; i++) {\r
+ if (t.next != null) t = t.next;\r
+ else t = t.next = token_source.getNextToken();\r
+ }\r
+ return t;\r
+ }\r
+\r
+ private int jj_ntk() {\r
+ if ((jj_nt=token.next) == null)\r
+ return (jj_ntk = (token.next=token_source.getNextToken()).kind);\r
+ else\r
+ return (jj_ntk = jj_nt.kind);\r
+ }\r
+\r
+ private java.util.List<int[]> jj_expentries = new java.util.ArrayList<int[]>();\r
+ private int[] jj_expentry;\r
+ private int jj_kind = -1;\r
+\r
+ /** Generate ParseException. */\r
+ public ParseException generateParseException() {\r
+ jj_expentries.clear();\r
+ boolean[] la1tokens = new boolean[51];\r
+ if (jj_kind >= 0) {\r
+ la1tokens[jj_kind] = true;\r
+ jj_kind = -1;\r
+ }\r
+ for (int i = 0; i < 6; i++) {\r
+ if (jj_la1[i] == jj_gen) {\r
+ for (int j = 0; j < 32; j++) {\r
+ if ((jj_la1_0[i] & (1<<j)) != 0) {\r
+ la1tokens[j] = true;\r
+ }\r
+ if ((jj_la1_1[i] & (1<<j)) != 0) {\r
+ la1tokens[32+j] = true;\r
+ }\r
+ }\r
+ }\r
+ }\r
+ for (int i = 0; i < 51; i++) {\r
+ if (la1tokens[i]) {\r
+ jj_expentry = new int[1];\r
+ jj_expentry[0] = i;\r
+ jj_expentries.add(jj_expentry);\r
+ }\r
+ }\r
+ int[][] exptokseq = new int[jj_expentries.size()][];\r
+ for (int i = 0; i < jj_expentries.size(); i++) {\r
+ exptokseq[i] = jj_expentries.get(i);\r
+ }\r
+ return new ParseException(token, exptokseq, tokenImage);\r
+ }\r
+\r
+ /** Enable tracing. */\r
+ final public void enable_tracing() {\r
+ }\r
+\r
+ /** Disable tracing. */\r
+ final public void disable_tracing() {\r
+ }\r
+\r
+}\r
--- /dev/null
+options {\r
+ JDK_VERSION = "1.6";\r
+ STATIC = false;\r
+}\r
+\r
+PARSER_BEGIN(ExpressionParser)\r
+package org.simantics.sysdyn.expressionParser;\r
+\r
+import java.util.List;\r
+import java.util.ArrayList;\r
+\r
+public class ExpressionParser {\r
+}\r
+PARSER_END(ExpressionParser)\r
+\r
+/*** Lexer *********************************************************/\r
+\r
+SKIP:\r
+{ <WHITESPACE: " " | "\n" | "\r" | "\t" > \r
+| <COMMENT1: "/*" (~["*"] | "*" ~["/"])* "*/" > \r
+| <COMMENT2: "//" (~["\n"])* >\r
+}\r
+\r
+TOKEN:\r
+{\r
+ "(" | ")" | "{" | "}" | "[" | "]" | "." | ":" | ";" | ","\r| "if" | "then" | "else" | "elseif"\r
+| "or" | "and" | "not"\r
+| "<" | "<=" | ">" | ">=" | "==" | "<>"\r
+| "+" | "-" | ".+" | ".-"\r
+| "*" | "/" | ".*" | "./"\r
+| "^" | ".^"\r
+| "=" | ":=" \r
+| "false" | "true" | "end" | "annotation"\r
+| "each" | "fine" | "redeclare" | "replaceable"\r
+| <STRING: "\"" (~["\"", "\\", "\n"] | "\\" ~["\n"])* "\"">\r
+ { matchedToken.image = matchedToken.image.substring(1,matchedToken.image.length()-1); }\r
+| <IDENT: ["a"-"z","A"-"Z","_"] (["a"-"z","A"-"Z","_","0"-"9"])* >\r
+| <UNSIGNED_INTEGER: (["0"-"9"])+ >\r
+| <UNSIGNED_NUMBER: \r
+ ( <UNSIGNED_INTEGER> "." (<UNSIGNED_INTEGER>)? (["e","E"] <UNSIGNED_INTEGER>)?\r
+ | "." <UNSIGNED_INTEGER> (["e","E"] <UNSIGNED_INTEGER>)?\r
+ | <UNSIGNED_INTEGER> ["e","E"] <UNSIGNED_INTEGER>\r
+ ) >\r
+}\r
+\r
+/*** Parser ********************************************************/\r
+\r
+// https://javacc.dev.java.net/doc/javaccgrm.html\r
+// add_op -> add_op()\r
+// [ add_op ] -> ( add_op() )?\r
+// { add_op term } -> ( add_op() term() )*\r
+\r
+void arithmetic_expression() : {\r
+} {\r
+ (add_op())? term() (add_op() term())*\r
+}\r
+\r
+void add_op() : {\r
+} {\r
+ "+" | "-" | ".+" | ".-"\r
+}\r
+\r
+void term() : {\r
+} {\r
+ // TODO primary -> factor\r
+ primary() ( mul_op() primary() )*\r
+}\r
+\r
+void mul_op() : {\r
+} {\r
+ "*" | "/" | ".*" | "./"\r
+}\r
+\r
+void primary() : {\r
+} {\r
+ <UNSIGNED_NUMBER>\r
+ | <UNSIGNED_INTEGER>\r
+ | <STRING>\r
+ | "false"\r
+ | "true"\r
+ // | name() function_call_args()\r
+ // | component_reference()\r
+ // | "(" output_expression_list() ")"\r
+ // | "[" expression_list() { ";" expression_list() } "]"\r
+ // | "{" function_arguments() "}"\r
+ | "end"\r
+}
\ No newline at end of file
--- /dev/null
+/* Generated By:JavaCC: Do not edit this line. ExpressionParserConstants.java */\r
+package org.simantics.sysdyn.expressionParser;\r
+\r
+\r
+/**\r
+ * Token literal values and constants.\r
+ * Generated by org.javacc.parser.OtherFilesGen#start()\r
+ */\r
+public interface ExpressionParserConstants {\r
+\r
+ /** End of File. */\r
+ int EOF = 0;\r
+ /** RegularExpression Id. */\r
+ int WHITESPACE = 1;\r
+ /** RegularExpression Id. */\r
+ int COMMENT1 = 2;\r
+ /** RegularExpression Id. */\r
+ int COMMENT2 = 3;\r
+ /** RegularExpression Id. */\r
+ int STRING = 47;\r
+ /** RegularExpression Id. */\r
+ int IDENT = 48;\r
+ /** RegularExpression Id. */\r
+ int UNSIGNED_INTEGER = 49;\r
+ /** RegularExpression Id. */\r
+ int UNSIGNED_NUMBER = 50;\r
+\r
+ /** Lexical state. */\r
+ int DEFAULT = 0;\r
+\r
+ /** Literal token values. */\r
+ String[] tokenImage = {\r
+ "<EOF>",\r
+ "<WHITESPACE>",\r
+ "<COMMENT1>",\r
+ "<COMMENT2>",\r
+ "\"(\"",\r
+ "\")\"",\r
+ "\"{\"",\r
+ "\"}\"",\r
+ "\"[\"",\r
+ "\"]\"",\r
+ "\".\"",\r
+ "\":\"",\r
+ "\";\"",\r
+ "\",\"",\r
+ "\"if\"",\r
+ "\"then\"",\r
+ "\"else\"",\r
+ "\"elseif\"",\r
+ "\"or\"",\r
+ "\"and\"",\r
+ "\"not\"",\r
+ "\"<\"",\r
+ "\"<=\"",\r
+ "\">\"",\r
+ "\">=\"",\r
+ "\"==\"",\r
+ "\"<>\"",\r
+ "\"+\"",\r
+ "\"-\"",\r
+ "\".+\"",\r
+ "\".-\"",\r
+ "\"*\"",\r
+ "\"/\"",\r
+ "\".*\"",\r
+ "\"./\"",\r
+ "\"^\"",\r
+ "\".^\"",\r
+ "\"=\"",\r
+ "\":=\"",\r
+ "\"false\"",\r
+ "\"true\"",\r
+ "\"end\"",\r
+ "\"annotation\"",\r
+ "\"each\"",\r
+ "\"fine\"",\r
+ "\"redeclare\"",\r
+ "\"replaceable\"",\r
+ "<STRING>",\r
+ "<IDENT>",\r
+ "<UNSIGNED_INTEGER>",\r
+ "<UNSIGNED_NUMBER>",\r
+ };\r
+\r
+}\r
--- /dev/null
+/* Generated By:JavaCC: Do not edit this line. ExpressionParserTokenManager.java */\r
+package org.simantics.sysdyn.expressionParser;\r
+import java.util.List;\r
+import java.util.ArrayList;\r
+\r
+/** Token Manager. */\r
+public class ExpressionParserTokenManager implements ExpressionParserConstants\r
+{\r
+\r
+ /** Debug output. */\r
+ public java.io.PrintStream debugStream = System.out;\r
+ /** Set debug output. */\r
+ public void setDebugStream(java.io.PrintStream ds) { debugStream = ds; }\r
+private final int jjStopStringLiteralDfa_0(int pos, long active0)
+{\r
+ switch (pos)
+ {\r
+ case 0:\r
+ if ((active0 & 0x7f80001fc000L) != 0L)\r
+ {\r
+ jjmatchedKind = 48;\r
+ return 7;\r
+ }\r
+ if ((active0 & 0x100000000L) != 0L)\r
+ return 13;\r
+ if ((active0 & 0x1660000400L) != 0L)\r
+ return 9;\r
+ return -1;\r
+ case 1:\r
+ if ((active0 & 0x7f80001b8000L) != 0L)\r
+ {\r
+ jjmatchedKind = 48;\r
+ jjmatchedPos = 1;\r
+ return 7;\r
+ }\r
+ if ((active0 & 0x44000L) != 0L)\r
+ return 7;\r
+ return -1;\r
+ case 2:\r
+ if ((active0 & 0x7d8000038000L) != 0L)\r
+ {\r
+ jjmatchedKind = 48;\r
+ jjmatchedPos = 2;\r
+ return 7;\r
+ }\r
+ if ((active0 & 0x20000180000L) != 0L)\r
+ return 7;\r
+ return -1;\r
+ case 3:\r
+ if ((active0 & 0x648000000000L) != 0L)\r
+ {\r
+ if (jjmatchedPos != 3)\r
+ {\r
+ jjmatchedKind = 48;\r
+ jjmatchedPos = 3;\r
+ }\r
+ return 7;\r
+ }\r
+ if ((active0 & 0x190000038000L) != 0L)\r
+ return 7;\r
+ return -1;\r
+ case 4:\r
+ if ((active0 & 0x640000020000L) != 0L)\r
+ {\r
+ jjmatchedKind = 48;\r
+ jjmatchedPos = 4;\r
+ return 7;\r
+ }\r
+ if ((active0 & 0x8000000000L) != 0L)\r
+ return 7;\r
+ return -1;\r
+ case 5:\r
+ if ((active0 & 0x640000000000L) != 0L)\r
+ {\r
+ jjmatchedKind = 48;\r
+ jjmatchedPos = 5;\r
+ return 7;\r
+ }\r
+ if ((active0 & 0x20000L) != 0L)\r
+ return 7;\r
+ return -1;\r
+ case 6:\r
+ if ((active0 & 0x640000000000L) != 0L)\r
+ {\r
+ jjmatchedKind = 48;\r
+ jjmatchedPos = 6;\r
+ return 7;\r
+ }\r
+ return -1;\r
+ case 7:\r
+ if ((active0 & 0x640000000000L) != 0L)\r
+ {\r
+ jjmatchedKind = 48;\r
+ jjmatchedPos = 7;\r
+ return 7;\r
+ }\r
+ return -1;\r
+ case 8:\r
+ if ((active0 & 0x200000000000L) != 0L)\r
+ return 7;\r
+ if ((active0 & 0x440000000000L) != 0L)\r
+ {\r
+ jjmatchedKind = 48;\r
+ jjmatchedPos = 8;\r
+ return 7;\r
+ }\r
+ return -1;\r
+ case 9:\r
+ if ((active0 & 0x400000000000L) != 0L)\r
+ {\r
+ jjmatchedKind = 48;\r
+ jjmatchedPos = 9;\r
+ return 7;\r
+ }\r
+ if ((active0 & 0x40000000000L) != 0L)\r
+ return 7;\r
+ return -1;\r
+ default :\r
+ return -1;\r
+ }\r
+}\r
+private final int jjStartNfa_0(int pos, long active0)
+{\r
+ return jjMoveNfa_0(jjStopStringLiteralDfa_0(pos, active0), pos + 1);\r
+}\r
+private int jjStopAtPos(int pos, int kind)\r
+{\r
+ jjmatchedKind = kind;\r
+ jjmatchedPos = pos;\r
+ return pos + 1;\r
+}\r
+private int jjMoveStringLiteralDfa0_0()\r
+{\r
+ switch(curChar)\r
+ {\r
+ case 40:\r
+ return jjStopAtPos(0, 4);\r
+ case 41:\r
+ return jjStopAtPos(0, 5);\r
+ case 42:\r
+ return jjStopAtPos(0, 31);\r
+ case 43:\r
+ return jjStopAtPos(0, 27);\r
+ case 44:\r
+ return jjStopAtPos(0, 13);\r
+ case 45:\r
+ return jjStopAtPos(0, 28);\r
+ case 46:\r
+ jjmatchedKind = 10;\r
+ return jjMoveStringLiteralDfa1_0(0x1660000000L);\r
+ case 47:\r
+ return jjStartNfaWithStates_0(0, 32, 13);\r
+ case 58:\r
+ jjmatchedKind = 11;\r
+ return jjMoveStringLiteralDfa1_0(0x4000000000L);\r
+ case 59:\r
+ return jjStopAtPos(0, 12);\r
+ case 60:\r
+ jjmatchedKind = 21;\r
+ return jjMoveStringLiteralDfa1_0(0x4400000L);\r
+ case 61:\r
+ jjmatchedKind = 37;\r
+ return jjMoveStringLiteralDfa1_0(0x2000000L);\r
+ case 62:\r
+ jjmatchedKind = 23;\r
+ return jjMoveStringLiteralDfa1_0(0x1000000L);\r
+ case 91:\r
+ return jjStopAtPos(0, 8);\r
+ case 93:\r
+ return jjStopAtPos(0, 9);\r
+ case 94:\r
+ return jjStopAtPos(0, 35);\r
+ case 97:\r
+ return jjMoveStringLiteralDfa1_0(0x40000080000L);\r
+ case 101:\r
+ return jjMoveStringLiteralDfa1_0(0xa0000030000L);\r
+ case 102:\r
+ return jjMoveStringLiteralDfa1_0(0x108000000000L);\r
+ case 105:\r
+ return jjMoveStringLiteralDfa1_0(0x4000L);\r
+ case 110:\r
+ return jjMoveStringLiteralDfa1_0(0x100000L);\r
+ case 111:\r
+ return jjMoveStringLiteralDfa1_0(0x40000L);\r
+ case 114:\r
+ return jjMoveStringLiteralDfa1_0(0x600000000000L);\r
+ case 116:\r
+ return jjMoveStringLiteralDfa1_0(0x10000008000L);\r
+ case 123:\r
+ return jjStopAtPos(0, 6);\r
+ case 125:\r
+ return jjStopAtPos(0, 7);\r
+ default :\r
+ return jjMoveNfa_0(0, 0);\r
+ }\r
+}\r
+private int jjMoveStringLiteralDfa1_0(long active0)\r
+{\r
+ try { curChar = input_stream.readChar(); }\r
+ catch(java.io.IOException e) {\r
+ jjStopStringLiteralDfa_0(0, active0);\r
+ return 1;\r
+ }\r
+ switch(curChar)\r
+ {\r
+ case 42:\r
+ if ((active0 & 0x200000000L) != 0L)\r
+ return jjStopAtPos(1, 33);\r
+ break;\r
+ case 43:\r
+ if ((active0 & 0x20000000L) != 0L)\r
+ return jjStopAtPos(1, 29);\r
+ break;\r
+ case 45:\r
+ if ((active0 & 0x40000000L) != 0L)\r
+ return jjStopAtPos(1, 30);\r
+ break;\r
+ case 47:\r
+ if ((active0 & 0x400000000L) != 0L)\r
+ return jjStopAtPos(1, 34);\r
+ break;\r
+ case 61:\r
+ if ((active0 & 0x400000L) != 0L)\r
+ return jjStopAtPos(1, 22);\r
+ else if ((active0 & 0x1000000L) != 0L)\r
+ return jjStopAtPos(1, 24);\r
+ else if ((active0 & 0x2000000L) != 0L)\r
+ return jjStopAtPos(1, 25);\r
+ else if ((active0 & 0x4000000000L) != 0L)\r
+ return jjStopAtPos(1, 38);\r
+ break;\r
+ case 62:\r
+ if ((active0 & 0x4000000L) != 0L)\r
+ return jjStopAtPos(1, 26);\r
+ break;\r
+ case 94:\r
+ if ((active0 & 0x1000000000L) != 0L)\r
+ return jjStopAtPos(1, 36);\r
+ break;\r
+ case 97:\r
+ return jjMoveStringLiteralDfa2_0(active0, 0x88000000000L);\r
+ case 101:\r
+ return jjMoveStringLiteralDfa2_0(active0, 0x600000000000L);\r
+ case 102:\r
+ if ((active0 & 0x4000L) != 0L)\r
+ return jjStartNfaWithStates_0(1, 14, 7);\r
+ break;\r
+ case 104:\r
+ return jjMoveStringLiteralDfa2_0(active0, 0x8000L);\r
+ case 105:\r
+ return jjMoveStringLiteralDfa2_0(active0, 0x100000000000L);\r
+ case 108:\r
+ return jjMoveStringLiteralDfa2_0(active0, 0x30000L);\r
+ case 110:\r
+ return jjMoveStringLiteralDfa2_0(active0, 0x60000080000L);\r
+ case 111:\r
+ return jjMoveStringLiteralDfa2_0(active0, 0x100000L);\r
+ case 114:\r
+ if ((active0 & 0x40000L) != 0L)\r
+ return jjStartNfaWithStates_0(1, 18, 7);\r
+ return jjMoveStringLiteralDfa2_0(active0, 0x10000000000L);\r
+ default :\r
+ break;\r
+ }\r
+ return jjStartNfa_0(0, active0);\r
+}\r
+private int jjMoveStringLiteralDfa2_0(long old0, long active0)\r
+{\r
+ if (((active0 &= old0)) == 0L)\r
+ return jjStartNfa_0(0, old0);\r
+ try { curChar = input_stream.readChar(); }\r
+ catch(java.io.IOException e) {\r
+ jjStopStringLiteralDfa_0(1, active0);\r
+ return 2;\r
+ }\r
+ switch(curChar)\r
+ {\r
+ case 99:\r
+ return jjMoveStringLiteralDfa3_0(active0, 0x80000000000L);\r
+ case 100:\r
+ if ((active0 & 0x80000L) != 0L)\r
+ return jjStartNfaWithStates_0(2, 19, 7);\r
+ else if ((active0 & 0x20000000000L) != 0L)\r
+ return jjStartNfaWithStates_0(2, 41, 7);\r
+ return jjMoveStringLiteralDfa3_0(active0, 0x200000000000L);\r
+ case 101:\r
+ return jjMoveStringLiteralDfa3_0(active0, 0x8000L);\r
+ case 108:\r
+ return jjMoveStringLiteralDfa3_0(active0, 0x8000000000L);\r
+ case 110:\r
+ return jjMoveStringLiteralDfa3_0(active0, 0x140000000000L);\r
+ case 112:\r
+ return jjMoveStringLiteralDfa3_0(active0, 0x400000000000L);\r
+ case 115:\r
+ return jjMoveStringLiteralDfa3_0(active0, 0x30000L);\r
+ case 116:\r
+ if ((active0 & 0x100000L) != 0L)\r
+ return jjStartNfaWithStates_0(2, 20, 7);\r
+ break;\r
+ case 117:\r
+ return jjMoveStringLiteralDfa3_0(active0, 0x10000000000L);\r
+ default :\r
+ break;\r
+ }\r
+ return jjStartNfa_0(1, active0);\r
+}\r
+private int jjMoveStringLiteralDfa3_0(long old0, long active0)\r
+{\r
+ if (((active0 &= old0)) == 0L)\r
+ return jjStartNfa_0(1, old0);\r
+ try { curChar = input_stream.readChar(); }\r
+ catch(java.io.IOException e) {\r
+ jjStopStringLiteralDfa_0(2, active0);\r
+ return 3;\r
+ }\r
+ switch(curChar)\r
+ {\r
+ case 101:\r
+ if ((active0 & 0x10000L) != 0L)\r
+ {\r
+ jjmatchedKind = 16;\r
+ jjmatchedPos = 3;\r
+ }\r
+ else if ((active0 & 0x10000000000L) != 0L)\r
+ return jjStartNfaWithStates_0(3, 40, 7);\r
+ else if ((active0 & 0x100000000000L) != 0L)\r
+ return jjStartNfaWithStates_0(3, 44, 7);\r
+ return jjMoveStringLiteralDfa4_0(active0, 0x200000020000L);\r
+ case 104:\r
+ if ((active0 & 0x80000000000L) != 0L)\r
+ return jjStartNfaWithStates_0(3, 43, 7);\r
+ break;\r
+ case 108:\r
+ return jjMoveStringLiteralDfa4_0(active0, 0x400000000000L);\r
+ case 110:\r
+ if ((active0 & 0x8000L) != 0L)\r
+ return jjStartNfaWithStates_0(3, 15, 7);\r
+ break;\r
+ case 111:\r
+ return jjMoveStringLiteralDfa4_0(active0, 0x40000000000L);\r
+ case 115:\r
+ return jjMoveStringLiteralDfa4_0(active0, 0x8000000000L);\r
+ default :\r
+ break;\r
+ }\r
+ return jjStartNfa_0(2, active0);\r
+}\r
+private int jjMoveStringLiteralDfa4_0(long old0, long active0)\r
+{\r
+ if (((active0 &= old0)) == 0L)\r
+ return jjStartNfa_0(2, old0);\r
+ try { curChar = input_stream.readChar(); }\r
+ catch(java.io.IOException e) {\r
+ jjStopStringLiteralDfa_0(3, active0);\r
+ return 4;\r
+ }\r
+ switch(curChar)\r
+ {\r
+ case 97:\r
+ return jjMoveStringLiteralDfa5_0(active0, 0x400000000000L);\r
+ case 99:\r
+ return jjMoveStringLiteralDfa5_0(active0, 0x200000000000L);\r
+ case 101:\r
+ if ((active0 & 0x8000000000L) != 0L)\r
+ return jjStartNfaWithStates_0(4, 39, 7);\r
+ break;\r
+ case 105:\r
+ return jjMoveStringLiteralDfa5_0(active0, 0x20000L);\r
+ case 116:\r
+ return jjMoveStringLiteralDfa5_0(active0, 0x40000000000L);\r
+ default :\r
+ break;\r
+ }\r
+ return jjStartNfa_0(3, active0);\r
+}\r
+private int jjMoveStringLiteralDfa5_0(long old0, long active0)\r
+{\r
+ if (((active0 &= old0)) == 0L)\r
+ return jjStartNfa_0(3, old0);\r
+ try { curChar = input_stream.readChar(); }\r
+ catch(java.io.IOException e) {\r
+ jjStopStringLiteralDfa_0(4, active0);\r
+ return 5;\r
+ }\r
+ switch(curChar)\r
+ {\r
+ case 97:\r
+ return jjMoveStringLiteralDfa6_0(active0, 0x40000000000L);\r
+ case 99:\r
+ return jjMoveStringLiteralDfa6_0(active0, 0x400000000000L);\r
+ case 102:\r
+ if ((active0 & 0x20000L) != 0L)\r
+ return jjStartNfaWithStates_0(5, 17, 7);\r
+ break;\r
+ case 108:\r
+ return jjMoveStringLiteralDfa6_0(active0, 0x200000000000L);\r
+ default :\r
+ break;\r
+ }\r
+ return jjStartNfa_0(4, active0);\r
+}\r
+private int jjMoveStringLiteralDfa6_0(long old0, long active0)\r
+{\r
+ if (((active0 &= old0)) == 0L)\r
+ return jjStartNfa_0(4, old0);\r
+ try { curChar = input_stream.readChar(); }\r
+ catch(java.io.IOException e) {\r
+ jjStopStringLiteralDfa_0(5, active0);\r
+ return 6;\r
+ }\r
+ switch(curChar)\r
+ {\r
+ case 97:\r
+ return jjMoveStringLiteralDfa7_0(active0, 0x200000000000L);\r
+ case 101:\r
+ return jjMoveStringLiteralDfa7_0(active0, 0x400000000000L);\r
+ case 116:\r
+ return jjMoveStringLiteralDfa7_0(active0, 0x40000000000L);\r
+ default :\r
+ break;\r
+ }\r
+ return jjStartNfa_0(5, active0);\r
+}\r
+private int jjMoveStringLiteralDfa7_0(long old0, long active0)\r
+{\r
+ if (((active0 &= old0)) == 0L)\r
+ return jjStartNfa_0(5, old0);\r
+ try { curChar = input_stream.readChar(); }\r
+ catch(java.io.IOException e) {\r
+ jjStopStringLiteralDfa_0(6, active0);\r
+ return 7;\r
+ }\r
+ switch(curChar)\r
+ {\r
+ case 97:\r
+ return jjMoveStringLiteralDfa8_0(active0, 0x400000000000L);\r
+ case 105:\r
+ return jjMoveStringLiteralDfa8_0(active0, 0x40000000000L);\r
+ case 114:\r
+ return jjMoveStringLiteralDfa8_0(active0, 0x200000000000L);\r
+ default :\r
+ break;\r
+ }\r
+ return jjStartNfa_0(6, active0);\r
+}\r
+private int jjMoveStringLiteralDfa8_0(long old0, long active0)\r
+{\r
+ if (((active0 &= old0)) == 0L)\r
+ return jjStartNfa_0(6, old0);\r
+ try { curChar = input_stream.readChar(); }\r
+ catch(java.io.IOException e) {\r
+ jjStopStringLiteralDfa_0(7, active0);\r
+ return 8;\r
+ }\r
+ switch(curChar)\r
+ {\r
+ case 98:\r
+ return jjMoveStringLiteralDfa9_0(active0, 0x400000000000L);\r
+ case 101:\r
+ if ((active0 & 0x200000000000L) != 0L)\r
+ return jjStartNfaWithStates_0(8, 45, 7);\r
+ break;\r
+ case 111:\r
+ return jjMoveStringLiteralDfa9_0(active0, 0x40000000000L);\r
+ default :\r
+ break;\r
+ }\r
+ return jjStartNfa_0(7, active0);\r
+}\r
+private int jjMoveStringLiteralDfa9_0(long old0, long active0)\r
+{\r
+ if (((active0 &= old0)) == 0L)\r
+ return jjStartNfa_0(7, old0);\r
+ try { curChar = input_stream.readChar(); }\r
+ catch(java.io.IOException e) {\r
+ jjStopStringLiteralDfa_0(8, active0);\r
+ return 9;\r
+ }\r
+ switch(curChar)\r
+ {\r
+ case 108:\r
+ return jjMoveStringLiteralDfa10_0(active0, 0x400000000000L);\r
+ case 110:\r
+ if ((active0 & 0x40000000000L) != 0L)\r
+ return jjStartNfaWithStates_0(9, 42, 7);\r
+ break;\r
+ default :\r
+ break;\r
+ }\r
+ return jjStartNfa_0(8, active0);\r
+}\r
+private int jjMoveStringLiteralDfa10_0(long old0, long active0)\r
+{\r
+ if (((active0 &= old0)) == 0L)\r
+ return jjStartNfa_0(8, old0);\r
+ try { curChar = input_stream.readChar(); }\r
+ catch(java.io.IOException e) {\r
+ jjStopStringLiteralDfa_0(9, active0);\r
+ return 10;\r
+ }\r
+ switch(curChar)\r
+ {\r
+ case 101:\r
+ if ((active0 & 0x400000000000L) != 0L)\r
+ return jjStartNfaWithStates_0(10, 46, 7);\r
+ break;\r
+ default :\r
+ break;\r
+ }\r
+ return jjStartNfa_0(9, active0);\r
+}\r
+private int jjStartNfaWithStates_0(int pos, int kind, int state)\r
+{\r
+ jjmatchedKind = kind;\r
+ jjmatchedPos = pos;\r
+ try { curChar = input_stream.readChar(); }\r
+ catch(java.io.IOException e) { return pos + 1; }\r
+ return jjMoveNfa_0(state, pos + 1);\r
+}\r
+static final long[] jjbitVec0 = {
+ 0x0L, 0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL
+};\r
+private int jjMoveNfa_0(int startState, int curPos)\r
+{\r
+ int startsAt = 0;\r
+ jjnewStateCnt = 31;\r
+ int i = 1;\r
+ jjstateSet[0] = startState;\r
+ int kind = 0x7fffffff;\r
+ for (;;)\r
+ {\r
+ if (++jjround == 0x7fffffff)\r
+ ReInitRounds();\r
+ if (curChar < 64)\r
+ {\r
+ long l = 1L << curChar;\r
+ do\r
+ {\r
+ switch(jjstateSet[--i])\r
+ {\r
+ case 13:\r
+ if (curChar == 47)\r
+ {\r
+ if (kind > 3)\r
+ kind = 3;\r
+ jjCheckNAdd(20);\r
+ }\r
+ else if (curChar == 42)\r
+ jjCheckNAddStates(0, 2);\r
+ break;\r
+ case 0:\r
+ if ((0x3ff000000000000L & l) != 0L)\r
+ {\r
+ if (kind > 49)\r
+ kind = 49;\r
+ jjCheckNAddStates(3, 7);\r
+ }\r
+ else if ((0x100002600L & l) != 0L)\r
+ {\r
+ if (kind > 1)\r
+ kind = 1;\r
+ }\r
+ else if (curChar == 47)\r
+ jjAddStates(8, 9);\r
+ else if (curChar == 46)\r
+ jjCheckNAdd(9);\r
+ else if (curChar == 34)\r
+ jjCheckNAddStates(10, 12);\r
+ break;\r
+ case 1:\r
+ if (curChar == 34)\r
+ jjCheckNAddStates(10, 12);\r
+ break;\r
+ case 2:\r
+ if ((0xfffffffbfffffbffL & l) != 0L)\r
+ jjCheckNAddStates(10, 12);\r
+ break;\r
+ case 4:\r
+ if ((0xfffffffffffffbffL & l) != 0L)\r
+ jjCheckNAddStates(10, 12);\r
+ break;\r
+ case 5:\r
+ if (curChar == 34 && kind > 47)\r
+ kind = 47;\r
+ break;\r
+ case 7:\r
+ if ((0x3ff000000000000L & l) == 0L)\r
+ break;\r
+ if (kind > 48)\r
+ kind = 48;\r
+ jjstateSet[jjnewStateCnt++] = 7;\r
+ break;\r
+ case 8:\r
+ if (curChar == 46)\r
+ jjCheckNAdd(9);\r
+ break;\r
+ case 9:\r
+ if ((0x3ff000000000000L & l) == 0L)\r
+ break;\r
+ if (kind > 50)\r
+ kind = 50;\r
+ jjCheckNAddTwoStates(9, 10);\r
+ break;\r
+ case 11:\r
+ if ((0x3ff000000000000L & l) == 0L)\r
+ break;\r
+ if (kind > 50)\r
+ kind = 50;\r
+ jjstateSet[jjnewStateCnt++] = 11;\r
+ break;\r
+ case 12:\r
+ if (curChar == 47)\r
+ jjAddStates(8, 9);\r
+ break;\r
+ case 14:\r
+ if ((0xfffffbffffffffffL & l) != 0L)\r
+ jjCheckNAddStates(0, 2);\r
+ break;\r
+ case 15:\r
+ if (curChar == 42)\r
+ jjstateSet[jjnewStateCnt++] = 16;\r
+ break;\r
+ case 16:\r
+ if ((0xffff7fffffffffffL & l) != 0L)\r
+ jjCheckNAddStates(0, 2);\r
+ break;\r
+ case 17:\r
+ if (curChar == 47 && kind > 2)\r
+ kind = 2;\r
+ break;\r
+ case 18:\r
+ if (curChar == 42)\r
+ jjstateSet[jjnewStateCnt++] = 17;\r
+ break;\r
+ case 19:\r
+ if (curChar != 47)\r
+ break;\r
+ if (kind > 3)\r
+ kind = 3;\r
+ jjCheckNAdd(20);\r
+ break;\r
+ case 20:\r
+ if ((0xfffffffffffffbffL & l) == 0L)\r
+ break;\r
+ if (kind > 3)\r
+ kind = 3;\r
+ jjCheckNAdd(20);\r
+ break;\r
+ case 21:\r
+ if ((0x3ff000000000000L & l) == 0L)\r
+ break;\r
+ if (kind > 49)\r
+ kind = 49;\r
+ jjCheckNAddStates(3, 7);\r
+ break;\r
+ case 22:\r
+ if ((0x3ff000000000000L & l) == 0L)\r
+ break;\r
+ if (kind > 49)\r
+ kind = 49;\r
+ jjCheckNAdd(22);\r
+ break;\r
+ case 23:\r
+ if ((0x3ff000000000000L & l) != 0L)\r
+ jjCheckNAddTwoStates(23, 24);\r
+ break;\r
+ case 24:\r
+ if (curChar != 46)\r
+ break;\r
+ if (kind > 50)\r
+ kind = 50;\r
+ jjCheckNAddTwoStates(25, 26);\r
+ break;\r
+ case 25:\r
+ if ((0x3ff000000000000L & l) == 0L)\r
+ break;\r
+ if (kind > 50)\r
+ kind = 50;\r
+ jjCheckNAddTwoStates(25, 26);\r
+ break;\r
+ case 27:\r
+ if ((0x3ff000000000000L & l) == 0L)\r
+ break;\r
+ if (kind > 50)\r
+ kind = 50;\r
+ jjstateSet[jjnewStateCnt++] = 27;\r
+ break;\r
+ case 28:\r
+ if ((0x3ff000000000000L & l) != 0L)\r
+ jjCheckNAddTwoStates(28, 29);\r
+ break;\r
+ case 30:\r
+ if ((0x3ff000000000000L & l) == 0L)\r
+ break;\r
+ if (kind > 50)\r
+ kind = 50;\r
+ jjstateSet[jjnewStateCnt++] = 30;\r
+ break;\r
+ default : break;\r
+ }\r
+ } while(i != startsAt);\r
+ }\r
+ else if (curChar < 128)\r
+ {\r
+ long l = 1L << (curChar & 077);\r
+ do\r
+ {\r
+ switch(jjstateSet[--i])\r
+ {\r
+ case 0:\r
+ case 7:\r
+ if ((0x7fffffe87fffffeL & l) == 0L)\r
+ break;\r
+ if (kind > 48)\r
+ kind = 48;\r
+ jjCheckNAdd(7);\r
+ break;\r
+ case 2:\r
+ if ((0xffffffffefffffffL & l) != 0L)\r
+ jjCheckNAddStates(10, 12);\r
+ break;\r
+ case 3:\r
+ if (curChar == 92)\r
+ jjstateSet[jjnewStateCnt++] = 4;\r
+ break;\r
+ case 4:\r
+ jjCheckNAddStates(10, 12);\r
+ break;\r
+ case 10:\r
+ if ((0x2000000020L & l) != 0L)\r
+ jjstateSet[jjnewStateCnt++] = 11;\r
+ break;\r
+ case 14:\r
+ case 16:\r
+ jjCheckNAddStates(0, 2);\r
+ break;\r
+ case 20:\r
+ if (kind > 3)\r
+ kind = 3;\r
+ jjstateSet[jjnewStateCnt++] = 20;\r
+ break;\r
+ case 26:\r
+ if ((0x2000000020L & l) != 0L)\r
+ jjstateSet[jjnewStateCnt++] = 27;\r
+ break;\r
+ case 29:\r
+ if ((0x2000000020L & l) != 0L)\r
+ jjstateSet[jjnewStateCnt++] = 30;\r
+ break;\r
+ default : break;\r
+ }\r
+ } while(i != startsAt);\r
+ }\r
+ else\r
+ {\r
+ int i2 = (curChar & 0xff) >> 6;\r
+ long l2 = 1L << (curChar & 077);\r
+ do\r
+ {\r
+ switch(jjstateSet[--i])\r
+ {\r
+ case 2:\r
+ case 4:\r
+ if ((jjbitVec0[i2] & l2) != 0L)\r
+ jjCheckNAddStates(10, 12);\r
+ break;\r
+ case 14:\r
+ case 16:\r
+ if ((jjbitVec0[i2] & l2) != 0L)\r
+ jjCheckNAddStates(0, 2);\r
+ break;\r
+ case 20:\r
+ if ((jjbitVec0[i2] & l2) == 0L)\r
+ break;\r
+ if (kind > 3)\r
+ kind = 3;\r
+ jjstateSet[jjnewStateCnt++] = 20;\r
+ break;\r
+ default : break;\r
+ }\r
+ } while(i != startsAt);\r
+ }\r
+ if (kind != 0x7fffffff)\r
+ {\r
+ jjmatchedKind = kind;\r
+ jjmatchedPos = curPos;\r
+ kind = 0x7fffffff;\r
+ }\r
+ ++curPos;\r
+ if ((i = jjnewStateCnt) == (startsAt = 31 - (jjnewStateCnt = startsAt)))\r
+ return curPos;\r
+ try { curChar = input_stream.readChar(); }\r
+ catch(java.io.IOException e) { return curPos; }\r
+ }\r
+}\r
+static final int[] jjnextStates = {
+ 14, 15, 18, 22, 23, 24, 28, 29, 13, 19, 2, 3, 5,
+};\r
+\r
+/** Token literal values. */\r
+public static final String[] jjstrLiteralImages = {\r
+"", null, null, null, "\50", "\51", "\173", "\175", "\133", "\135", "\56", \r
+"\72", "\73", "\54", "\151\146", "\164\150\145\156", "\145\154\163\145", \r
+"\145\154\163\145\151\146", "\157\162", "\141\156\144", "\156\157\164", "\74", "\74\75", "\76", "\76\75", \r
+"\75\75", "\74\76", "\53", "\55", "\56\53", "\56\55", "\52", "\57", "\56\52", "\56\57", \r
+"\136", "\56\136", "\75", "\72\75", "\146\141\154\163\145", "\164\162\165\145", \r
+"\145\156\144", "\141\156\156\157\164\141\164\151\157\156", "\145\141\143\150", \r
+"\146\151\156\145", "\162\145\144\145\143\154\141\162\145", \r
+"\162\145\160\154\141\143\145\141\142\154\145", null, null, null, null, };\r
+\r
+/** Lexer state names. */\r
+public static final String[] lexStateNames = {\r
+ "DEFAULT",\r
+};\r
+static final long[] jjtoToken = {
+ 0x7fffffffffff1L,
+};\r
+static final long[] jjtoSkip = {
+ 0xeL,
+};\r
+protected SimpleCharStream input_stream;\r
+private final int[] jjrounds = new int[31];\r
+private final int[] jjstateSet = new int[62];\r
+private final StringBuilder jjimage = new StringBuilder();\r
+private StringBuilder image = jjimage;\r
+private int jjimageLen;\r
+private int lengthOfMatch;\r
+protected char curChar;\r
+/** Constructor. */\r
+public ExpressionParserTokenManager(SimpleCharStream stream){\r
+ if (SimpleCharStream.staticFlag)\r
+ throw new Error("ERROR: Cannot use a static CharStream class with a non-static lexical analyzer.");\r
+ input_stream = stream;\r
+}\r
+\r
+/** Constructor. */\r
+public ExpressionParserTokenManager(SimpleCharStream stream, int lexState){\r
+ this(stream);\r
+ SwitchTo(lexState);\r
+}\r
+\r
+/** Reinitialise parser. */\r
+public void ReInit(SimpleCharStream stream)\r
+{\r
+ jjmatchedPos = jjnewStateCnt = 0;\r
+ curLexState = defaultLexState;\r
+ input_stream = stream;\r
+ ReInitRounds();\r
+}\r
+private void ReInitRounds()\r
+{\r
+ int i;\r
+ jjround = 0x80000001;\r
+ for (i = 31; i-- > 0;)\r
+ jjrounds[i] = 0x80000000;\r
+}\r
+\r
+/** Reinitialise parser. */\r
+public void ReInit(SimpleCharStream stream, int lexState)\r
+{\r
+ ReInit(stream);\r
+ SwitchTo(lexState);\r
+}\r
+\r
+/** Switch to specified lex state. */\r
+public void SwitchTo(int lexState)\r
+{\r
+ if (lexState >= 1 || lexState < 0)\r
+ throw new TokenMgrError("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrError.INVALID_LEXICAL_STATE);\r
+ else\r
+ curLexState = lexState;\r
+}\r
+\r
+protected Token jjFillToken()\r
+{\r
+ final Token t;\r
+ final String curTokenImage;\r
+ final int beginLine;\r
+ final int endLine;\r
+ final int beginColumn;\r
+ final int endColumn;\r
+ String im = jjstrLiteralImages[jjmatchedKind];\r
+ curTokenImage = (im == null) ? input_stream.GetImage() : im;\r
+ beginLine = input_stream.getBeginLine();\r
+ beginColumn = input_stream.getBeginColumn();\r
+ endLine = input_stream.getEndLine();\r
+ endColumn = input_stream.getEndColumn();\r
+ t = Token.newToken(jjmatchedKind, curTokenImage);\r
+\r
+ t.beginLine = beginLine;\r
+ t.endLine = endLine;\r
+ t.beginColumn = beginColumn;\r
+ t.endColumn = endColumn;\r
+\r
+ return t;\r
+}\r
+\r
+int curLexState = 0;\r
+int defaultLexState = 0;\r
+int jjnewStateCnt;\r
+int jjround;\r
+int jjmatchedPos;\r
+int jjmatchedKind;\r
+\r
+/** Get the next Token. */\r
+public Token getNextToken() \r
+{\r
+ Token matchedToken;\r
+ int curPos = 0;\r
+\r
+ EOFLoop :
+ for (;;)\r
+ {\r
+ try\r
+ {\r
+ curChar = input_stream.BeginToken();\r
+ }\r
+ catch(java.io.IOException e)\r
+ {\r
+ jjmatchedKind = 0;\r
+ matchedToken = jjFillToken();\r
+ return matchedToken;\r
+ }\r
+ image = jjimage;\r
+ image.setLength(0);\r
+ jjimageLen = 0;\r
+\r
+ jjmatchedKind = 0x7fffffff;\r
+ jjmatchedPos = 0;\r
+ curPos = jjMoveStringLiteralDfa0_0();\r
+ if (jjmatchedKind != 0x7fffffff)\r
+ {\r
+ if (jjmatchedPos + 1 < curPos)\r
+ input_stream.backup(curPos - jjmatchedPos - 1);\r
+ if ((jjtoToken[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L)\r
+ {\r
+ matchedToken = jjFillToken();\r
+ TokenLexicalActions(matchedToken);\r
+ return matchedToken;\r
+ }\r
+ else\r
+ {\r
+ continue EOFLoop;\r
+ }\r
+ }\r
+ int error_line = input_stream.getEndLine();\r
+ int error_column = input_stream.getEndColumn();\r
+ String error_after = null;\r
+ boolean EOFSeen = false;\r
+ try { input_stream.readChar(); input_stream.backup(1); }\r
+ catch (java.io.IOException e1) {\r
+ EOFSeen = true;\r
+ error_after = curPos <= 1 ? "" : input_stream.GetImage();\r
+ if (curChar == '\n' || curChar == '\r') {\r
+ error_line++;\r
+ error_column = 0;\r
+ }\r
+ else\r
+ error_column++;\r
+ }\r
+ if (!EOFSeen) {\r
+ input_stream.backup(1);\r
+ error_after = curPos <= 1 ? "" : input_stream.GetImage();\r
+ }\r
+ throw new TokenMgrError(EOFSeen, curLexState, error_line, error_column, error_after, curChar, TokenMgrError.LEXICAL_ERROR);\r
+ }\r
+}\r
+\r
+void TokenLexicalActions(Token matchedToken)\r
+{\r
+ switch(jjmatchedKind)\r
+ {\r
+ case 47 :\r
+ image.append(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1)));\r
+ matchedToken.image = matchedToken.image.substring(1,matchedToken.image.length()-1);\r
+ break;\r
+ default :\r
+ break;\r
+ }\r
+}\r
+private void jjCheckNAdd(int state)\r
+{\r
+ if (jjrounds[state] != jjround)\r
+ {\r
+ jjstateSet[jjnewStateCnt++] = state;\r
+ jjrounds[state] = jjround;\r
+ }\r
+}\r
+private void jjAddStates(int start, int end)\r
+{\r
+ do {\r
+ jjstateSet[jjnewStateCnt++] = jjnextStates[start];\r
+ } while (start++ != end);\r
+}\r
+private void jjCheckNAddTwoStates(int state1, int state2)\r
+{\r
+ jjCheckNAdd(state1);\r
+ jjCheckNAdd(state2);\r
+}\r
+\r
+private void jjCheckNAddStates(int start, int end)\r
+{\r
+ do {\r
+ jjCheckNAdd(jjnextStates[start]);\r
+ } while (start++ != end);\r
+}\r
+\r
+}\r
--- /dev/null
+/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 5.0 */\r
+/* JavaCCOptions:KEEP_LINE_COL=null */\r
+package org.simantics.sysdyn.expressionParser;\r
+\r
+/**\r
+ * This exception is thrown when parse errors are encountered.\r
+ * You can explicitly create objects of this exception type by\r
+ * calling the method generateParseException in the generated\r
+ * parser.\r
+ *\r
+ * You can modify this class to customize your error reporting\r
+ * mechanisms so long as you retain the public fields.\r
+ */\r
+public class ParseException extends Exception {\r
+\r
+ /**\r
+ * The version identifier for this Serializable class.\r
+ * Increment only if the <i>serialized</i> form of the\r
+ * class changes.\r
+ */\r
+ private static final long serialVersionUID = 1L;\r
+\r
+ /**\r
+ * This constructor is used by the method "generateParseException"\r
+ * in the generated parser. Calling this constructor generates\r
+ * a new object of this type with the fields "currentToken",\r
+ * "expectedTokenSequences", and "tokenImage" set.\r
+ */\r
+ public ParseException(Token currentTokenVal,\r
+ int[][] expectedTokenSequencesVal,\r
+ String[] tokenImageVal\r
+ )\r
+ {\r
+ super(initialise(currentTokenVal, expectedTokenSequencesVal, tokenImageVal));\r
+ currentToken = currentTokenVal;\r
+ expectedTokenSequences = expectedTokenSequencesVal;\r
+ tokenImage = tokenImageVal;\r
+ }\r
+\r
+ /**\r
+ * The following constructors are for use by you for whatever\r
+ * purpose you can think of. Constructing the exception in this\r
+ * manner makes the exception behave in the normal way - i.e., as\r
+ * documented in the class "Throwable". The fields "errorToken",\r
+ * "expectedTokenSequences", and "tokenImage" do not contain\r
+ * relevant information. The JavaCC generated code does not use\r
+ * these constructors.\r
+ */\r
+\r
+ public ParseException() {\r
+ super();\r
+ }\r
+\r
+ /** Constructor with message. */\r
+ public ParseException(String message) {\r
+ super(message);\r
+ }\r
+\r
+\r
+ /**\r
+ * This is the last token that has been consumed successfully. If\r
+ * this object has been created due to a parse error, the token\r
+ * followng this token will (therefore) be the first error token.\r
+ */\r
+ public Token currentToken;\r
+\r
+ /**\r
+ * Each entry in this array is an array of integers. Each array\r
+ * of integers represents a sequence of tokens (by their ordinal\r
+ * values) that is expected at this point of the parse.\r
+ */\r
+ public int[][] expectedTokenSequences;\r
+\r
+ /**\r
+ * This is a reference to the "tokenImage" array of the generated\r
+ * parser within which the parse error occurred. This array is\r
+ * defined in the generated ...Constants interface.\r
+ */\r
+ public String[] tokenImage;\r
+\r
+ /**\r
+ * It uses "currentToken" and "expectedTokenSequences" to generate a parse\r
+ * error message and returns it. If this object has been created\r
+ * due to a parse error, and you do not catch it (it gets thrown\r
+ * from the parser) the correct error message\r
+ * gets displayed.\r
+ */\r
+ private static String initialise(Token currentToken,\r
+ int[][] expectedTokenSequences,\r
+ String[] tokenImage) {\r
+ String eol = System.getProperty("line.separator", "\n");\r
+ StringBuffer expected = new StringBuffer();\r
+ int maxSize = 0;\r
+ for (int i = 0; i < expectedTokenSequences.length; i++) {\r
+ if (maxSize < expectedTokenSequences[i].length) {\r
+ maxSize = expectedTokenSequences[i].length;\r
+ }\r
+ for (int j = 0; j < expectedTokenSequences[i].length; j++) {\r
+ expected.append(tokenImage[expectedTokenSequences[i][j]]).append(' ');\r
+ }\r
+ if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1] != 0) {\r
+ expected.append("...");\r
+ }\r
+ expected.append(eol).append(" ");\r
+ }\r
+ String retval = "Encountered \"";\r
+ Token tok = currentToken.next;\r
+ for (int i = 0; i < maxSize; i++) {\r
+ if (i != 0) retval += " ";\r
+ if (tok.kind == 0) {\r
+ retval += tokenImage[0];\r
+ break;\r
+ }\r
+ retval += " " + tokenImage[tok.kind];\r
+ retval += " \"";\r
+ retval += add_escapes(tok.image);\r
+ retval += " \"";\r
+ tok = tok.next;\r
+ }\r
+ retval += "\" at line " + currentToken.next.beginLine + ", column " + currentToken.next.beginColumn;\r
+ retval += "." + eol;\r
+ if (expectedTokenSequences.length == 1) {\r
+ retval += "Was expecting:" + eol + " ";\r
+ } else {\r
+ retval += "Was expecting one of:" + eol + " ";\r
+ }\r
+ retval += expected.toString();\r
+ return retval;\r
+ }\r
+\r
+ /**\r
+ * The end of line string for this machine.\r
+ */\r
+ protected String eol = System.getProperty("line.separator", "\n");\r
+\r
+ /**\r
+ * Used to convert raw characters to their escaped version\r
+ * when these raw version cannot be used as part of an ASCII\r
+ * string literal.\r
+ */\r
+ static String add_escapes(String str) {\r
+ StringBuffer retval = new StringBuffer();\r
+ char ch;\r
+ for (int i = 0; i < str.length(); i++) {\r
+ switch (str.charAt(i))\r
+ {\r
+ case 0 :\r
+ continue;\r
+ case '\b':\r
+ retval.append("\\b");\r
+ continue;\r
+ case '\t':\r
+ retval.append("\\t");\r
+ continue;\r
+ case '\n':\r
+ retval.append("\\n");\r
+ continue;\r
+ case '\f':\r
+ retval.append("\\f");\r
+ continue;\r
+ case '\r':\r
+ retval.append("\\r");\r
+ continue;\r
+ case '\"':\r
+ retval.append("\\\"");\r
+ continue;\r
+ case '\'':\r
+ retval.append("\\\'");\r
+ continue;\r
+ case '\\':\r
+ retval.append("\\\\");\r
+ continue;\r
+ default:\r
+ if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) {\r
+ String s = "0000" + Integer.toString(ch, 16);\r
+ retval.append("\\u" + s.substring(s.length() - 4, s.length()));\r
+ } else {\r
+ retval.append(ch);\r
+ }\r
+ continue;\r
+ }\r
+ }\r
+ return retval.toString();\r
+ }\r
+\r
+}\r
+/* JavaCC - OriginalChecksum=65dcbd31a9e7a053287ebf70e24f8b8f (do not edit this line) */\r
--- /dev/null
+/* Generated By:JavaCC: Do not edit this line. SimpleCharStream.java Version 5.0 */\r
+/* JavaCCOptions:STATIC=false,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */\r
+package org.simantics.sysdyn.expressionParser;\r
+\r
+/**\r
+ * An implementation of interface CharStream, where the stream is assumed to\r
+ * contain only ASCII characters (without unicode processing).\r
+ */\r
+\r
+public class SimpleCharStream\r
+{\r
+/** Whether parser is static. */\r
+ public static final boolean staticFlag = false;\r
+ int bufsize;\r
+ int available;\r
+ int tokenBegin;\r
+/** Position in buffer. */\r
+ public int bufpos = -1;\r
+ protected int bufline[];\r
+ protected int bufcolumn[];\r
+\r
+ protected int column = 0;\r
+ protected int line = 1;\r
+\r
+ protected boolean prevCharIsCR = false;\r
+ protected boolean prevCharIsLF = false;\r
+\r
+ protected java.io.Reader inputStream;\r
+\r
+ protected char[] buffer;\r
+ protected int maxNextCharInd = 0;\r
+ protected int inBuf = 0;\r
+ protected int tabSize = 8;\r
+\r
+ protected void setTabSize(int i) { tabSize = i; }\r
+ protected int getTabSize(int i) { return tabSize; }\r
+\r
+\r
+ protected void ExpandBuff(boolean wrapAround)\r
+ {\r
+ char[] newbuffer = new char[bufsize + 2048];\r
+ int newbufline[] = new int[bufsize + 2048];\r
+ int newbufcolumn[] = new int[bufsize + 2048];\r
+\r
+ try\r
+ {\r
+ if (wrapAround)\r
+ {\r
+ System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin);\r
+ System.arraycopy(buffer, 0, newbuffer, bufsize - tokenBegin, bufpos);\r
+ buffer = newbuffer;\r
+\r
+ System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin);\r
+ System.arraycopy(bufline, 0, newbufline, bufsize - tokenBegin, bufpos);\r
+ bufline = newbufline;\r
+\r
+ System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin);\r
+ System.arraycopy(bufcolumn, 0, newbufcolumn, bufsize - tokenBegin, bufpos);\r
+ bufcolumn = newbufcolumn;\r
+\r
+ maxNextCharInd = (bufpos += (bufsize - tokenBegin));\r
+ }\r
+ else\r
+ {\r
+ System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin);\r
+ buffer = newbuffer;\r
+\r
+ System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin);\r
+ bufline = newbufline;\r
+\r
+ System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin);\r
+ bufcolumn = newbufcolumn;\r
+\r
+ maxNextCharInd = (bufpos -= tokenBegin);\r
+ }\r
+ }\r
+ catch (Throwable t)\r
+ {\r
+ throw new Error(t.getMessage());\r
+ }\r
+\r
+\r
+ bufsize += 2048;\r
+ available = bufsize;\r
+ tokenBegin = 0;\r
+ }\r
+\r
+ protected void FillBuff() throws java.io.IOException\r
+ {\r
+ if (maxNextCharInd == available)\r
+ {\r
+ if (available == bufsize)\r
+ {\r
+ if (tokenBegin > 2048)\r
+ {\r
+ bufpos = maxNextCharInd = 0;\r
+ available = tokenBegin;\r
+ }\r
+ else if (tokenBegin < 0)\r
+ bufpos = maxNextCharInd = 0;\r
+ else\r
+ ExpandBuff(false);\r
+ }\r
+ else if (available > tokenBegin)\r
+ available = bufsize;\r
+ else if ((tokenBegin - available) < 2048)\r
+ ExpandBuff(true);\r
+ else\r
+ available = tokenBegin;\r
+ }\r
+\r
+ int i;\r
+ try {\r
+ if ((i = inputStream.read(buffer, maxNextCharInd, available - maxNextCharInd)) == -1)\r
+ {\r
+ inputStream.close();\r
+ throw new java.io.IOException();\r
+ }\r
+ else\r
+ maxNextCharInd += i;\r
+ return;\r
+ }\r
+ catch(java.io.IOException e) {\r
+ --bufpos;\r
+ backup(0);\r
+ if (tokenBegin == -1)\r
+ tokenBegin = bufpos;\r
+ throw e;\r
+ }\r
+ }\r
+\r
+/** Start. */\r
+ public char BeginToken() throws java.io.IOException\r
+ {\r
+ tokenBegin = -1;\r
+ char c = readChar();\r
+ tokenBegin = bufpos;\r
+\r
+ return c;\r
+ }\r
+\r
+ protected void UpdateLineColumn(char c)\r
+ {\r
+ column++;\r
+\r
+ if (prevCharIsLF)\r
+ {\r
+ prevCharIsLF = false;\r
+ line += (column = 1);\r
+ }\r
+ else if (prevCharIsCR)\r
+ {\r
+ prevCharIsCR = false;\r
+ if (c == '\n')\r
+ {\r
+ prevCharIsLF = true;\r
+ }\r
+ else\r
+ line += (column = 1);\r
+ }\r
+\r
+ switch (c)\r
+ {\r
+ case '\r' :\r
+ prevCharIsCR = true;\r
+ break;\r
+ case '\n' :\r
+ prevCharIsLF = true;\r
+ break;\r
+ case '\t' :\r
+ column--;\r
+ column += (tabSize - (column % tabSize));\r
+ break;\r
+ default :\r
+ break;\r
+ }\r
+\r
+ bufline[bufpos] = line;\r
+ bufcolumn[bufpos] = column;\r
+ }\r
+\r
+/** Read a character. */\r
+ public char readChar() throws java.io.IOException\r
+ {\r
+ if (inBuf > 0)\r
+ {\r
+ --inBuf;\r
+\r
+ if (++bufpos == bufsize)\r
+ bufpos = 0;\r
+\r
+ return buffer[bufpos];\r
+ }\r
+\r
+ if (++bufpos >= maxNextCharInd)\r
+ FillBuff();\r
+\r
+ char c = buffer[bufpos];\r
+\r
+ UpdateLineColumn(c);\r
+ return c;\r
+ }\r
+\r
+ @Deprecated\r
+ /**\r
+ * @deprecated\r
+ * @see #getEndColumn\r
+ */\r
+\r
+ public int getColumn() {\r
+ return bufcolumn[bufpos];\r
+ }\r
+\r
+ @Deprecated\r
+ /**\r
+ * @deprecated\r
+ * @see #getEndLine\r
+ */\r
+\r
+ public int getLine() {\r
+ return bufline[bufpos];\r
+ }\r
+\r
+ /** Get token end column number. */\r
+ public int getEndColumn() {\r
+ return bufcolumn[bufpos];\r
+ }\r
+\r
+ /** Get token end line number. */\r
+ public int getEndLine() {\r
+ return bufline[bufpos];\r
+ }\r
+\r
+ /** Get token beginning column number. */\r
+ public int getBeginColumn() {\r
+ return bufcolumn[tokenBegin];\r
+ }\r
+\r
+ /** Get token beginning line number. */\r
+ public int getBeginLine() {\r
+ return bufline[tokenBegin];\r
+ }\r
+\r
+/** Backup a number of characters. */\r
+ public void backup(int amount) {\r
+\r
+ inBuf += amount;\r
+ if ((bufpos -= amount) < 0)\r
+ bufpos += bufsize;\r
+ }\r
+\r
+ /** Constructor. */\r
+ public SimpleCharStream(java.io.Reader dstream, int startline,\r
+ int startcolumn, int buffersize)\r
+ {\r
+ inputStream = dstream;\r
+ line = startline;\r
+ column = startcolumn - 1;\r
+\r
+ available = bufsize = buffersize;\r
+ buffer = new char[buffersize];\r
+ bufline = new int[buffersize];\r
+ bufcolumn = new int[buffersize];\r
+ }\r
+\r
+ /** Constructor. */\r
+ public SimpleCharStream(java.io.Reader dstream, int startline,\r
+ int startcolumn)\r
+ {\r
+ this(dstream, startline, startcolumn, 4096);\r
+ }\r
+\r
+ /** Constructor. */\r
+ public SimpleCharStream(java.io.Reader dstream)\r
+ {\r
+ this(dstream, 1, 1, 4096);\r
+ }\r
+\r
+ /** Reinitialise. */\r
+ public void ReInit(java.io.Reader dstream, int startline,\r
+ int startcolumn, int buffersize)\r
+ {\r
+ inputStream = dstream;\r
+ line = startline;\r
+ column = startcolumn - 1;\r
+\r
+ if (buffer == null || buffersize != buffer.length)\r
+ {\r
+ available = bufsize = buffersize;\r
+ buffer = new char[buffersize];\r
+ bufline = new int[buffersize];\r
+ bufcolumn = new int[buffersize];\r
+ }\r
+ prevCharIsLF = prevCharIsCR = false;\r
+ tokenBegin = inBuf = maxNextCharInd = 0;\r
+ bufpos = -1;\r
+ }\r
+\r
+ /** Reinitialise. */\r
+ public void ReInit(java.io.Reader dstream, int startline,\r
+ int startcolumn)\r
+ {\r
+ ReInit(dstream, startline, startcolumn, 4096);\r
+ }\r
+\r
+ /** Reinitialise. */\r
+ public void ReInit(java.io.Reader dstream)\r
+ {\r
+ ReInit(dstream, 1, 1, 4096);\r
+ }\r
+ /** Constructor. */\r
+ public SimpleCharStream(java.io.InputStream dstream, String encoding, int startline,\r
+ int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException\r
+ {\r
+ this(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize);\r
+ }\r
+\r
+ /** Constructor. */\r
+ public SimpleCharStream(java.io.InputStream dstream, int startline,\r
+ int startcolumn, int buffersize)\r
+ {\r
+ this(new java.io.InputStreamReader(dstream), startline, startcolumn, buffersize);\r
+ }\r
+\r
+ /** Constructor. */\r
+ public SimpleCharStream(java.io.InputStream dstream, String encoding, int startline,\r
+ int startcolumn) throws java.io.UnsupportedEncodingException\r
+ {\r
+ this(dstream, encoding, startline, startcolumn, 4096);\r
+ }\r
+\r
+ /** Constructor. */\r
+ public SimpleCharStream(java.io.InputStream dstream, int startline,\r
+ int startcolumn)\r
+ {\r
+ this(dstream, startline, startcolumn, 4096);\r
+ }\r
+\r
+ /** Constructor. */\r
+ public SimpleCharStream(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException\r
+ {\r
+ this(dstream, encoding, 1, 1, 4096);\r
+ }\r
+\r
+ /** Constructor. */\r
+ public SimpleCharStream(java.io.InputStream dstream)\r
+ {\r
+ this(dstream, 1, 1, 4096);\r
+ }\r
+\r
+ /** Reinitialise. */\r
+ public void ReInit(java.io.InputStream dstream, String encoding, int startline,\r
+ int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException\r
+ {\r
+ ReInit(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize);\r
+ }\r
+\r
+ /** Reinitialise. */\r
+ public void ReInit(java.io.InputStream dstream, int startline,\r
+ int startcolumn, int buffersize)\r
+ {\r
+ ReInit(new java.io.InputStreamReader(dstream), startline, startcolumn, buffersize);\r
+ }\r
+\r
+ /** Reinitialise. */\r
+ public void ReInit(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException\r
+ {\r
+ ReInit(dstream, encoding, 1, 1, 4096);\r
+ }\r
+\r
+ /** Reinitialise. */\r
+ public void ReInit(java.io.InputStream dstream)\r
+ {\r
+ ReInit(dstream, 1, 1, 4096);\r
+ }\r
+ /** Reinitialise. */\r
+ public void ReInit(java.io.InputStream dstream, String encoding, int startline,\r
+ int startcolumn) throws java.io.UnsupportedEncodingException\r
+ {\r
+ ReInit(dstream, encoding, startline, startcolumn, 4096);\r
+ }\r
+ /** Reinitialise. */\r
+ public void ReInit(java.io.InputStream dstream, int startline,\r
+ int startcolumn)\r
+ {\r
+ ReInit(dstream, startline, startcolumn, 4096);\r
+ }\r
+ /** Get token literal value. */\r
+ public String GetImage()\r
+ {\r
+ if (bufpos >= tokenBegin)\r
+ return new String(buffer, tokenBegin, bufpos - tokenBegin + 1);\r
+ else\r
+ return new String(buffer, tokenBegin, bufsize - tokenBegin) +\r
+ new String(buffer, 0, bufpos + 1);\r
+ }\r
+\r
+ /** Get the suffix. */\r
+ public char[] GetSuffix(int len)\r
+ {\r
+ char[] ret = new char[len];\r
+\r
+ if ((bufpos + 1) >= len)\r
+ System.arraycopy(buffer, bufpos - len + 1, ret, 0, len);\r
+ else\r
+ {\r
+ System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0,\r
+ len - bufpos - 1);\r
+ System.arraycopy(buffer, 0, ret, len - bufpos - 1, bufpos + 1);\r
+ }\r
+\r
+ return ret;\r
+ }\r
+\r
+ /** Reset buffer when finished. */\r
+ public void Done()\r
+ {\r
+ buffer = null;\r
+ bufline = null;\r
+ bufcolumn = null;\r
+ }\r
+\r
+ /**\r
+ * Method to adjust line and column numbers for the start of a token.\r
+ */\r
+ public void adjustBeginLineColumn(int newLine, int newCol)\r
+ {\r
+ int start = tokenBegin;\r
+ int len;\r
+\r
+ if (bufpos >= tokenBegin)\r
+ {\r
+ len = bufpos - tokenBegin + inBuf + 1;\r
+ }\r
+ else\r
+ {\r
+ len = bufsize - tokenBegin + bufpos + 1 + inBuf;\r
+ }\r
+\r
+ int i = 0, j = 0, k = 0;\r
+ int nextColDiff = 0, columnDiff = 0;\r
+\r
+ while (i < len && bufline[j = start % bufsize] == bufline[k = ++start % bufsize])\r
+ {\r
+ bufline[j] = newLine;\r
+ nextColDiff = columnDiff + bufcolumn[k] - bufcolumn[j];\r
+ bufcolumn[j] = newCol + columnDiff;\r
+ columnDiff = nextColDiff;\r
+ i++;\r
+ }\r
+\r
+ if (i < len)\r
+ {\r
+ bufline[j] = newLine++;\r
+ bufcolumn[j] = newCol + columnDiff;\r
+\r
+ while (i++ < len)\r
+ {\r
+ if (bufline[j = start % bufsize] != bufline[++start % bufsize])\r
+ bufline[j] = newLine++;\r
+ else\r
+ bufline[j] = newLine;\r
+ }\r
+ }\r
+\r
+ line = bufline[j];\r
+ column = bufcolumn[j];\r
+ }\r
+\r
+}\r
+/* JavaCC - OriginalChecksum=c766a5138ab7879b8b98d46681a242b8 (do not edit this line) */\r
--- /dev/null
+package org.simantics.sysdyn.expressionParser;\r
+\r
+import java.io.StringReader;\r
+\r
+public class TestExpressionParser {\r
+ \r
+ public static void parse(String string) {\r
+ ExpressionParser parser = new ExpressionParser(\r
+ new StringReader(string)\r
+ );\r
+ try {\r
+ parser.arithmetic_expression();\r
+ } catch (ParseException e) {\r
+ System.out.println("While parsing " + string + ":");\r
+ // TODO Auto-generated catch block\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+ \r
+ public static void main(String[] args) {\r
+ parse("1 + 2");\r
+ parse("1 + 2 + ");\r
+ parse("1 * 2");\r
+ }\r
+}\r
--- /dev/null
+/* Generated By:JavaCC: Do not edit this line. Token.java Version 5.0 */\r
+/* JavaCCOptions:TOKEN_EXTENDS=,KEEP_LINE_COL=null,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */\r
+package org.simantics.sysdyn.expressionParser;\r
+\r
+/**\r
+ * Describes the input token stream.\r
+ */\r
+\r
+public class Token implements java.io.Serializable {\r
+\r
+ /**\r
+ * The version identifier for this Serializable class.\r
+ * Increment only if the <i>serialized</i> form of the\r
+ * class changes.\r
+ */\r
+ private static final long serialVersionUID = 1L;\r
+\r
+ /**\r
+ * An integer that describes the kind of this token. This numbering\r
+ * system is determined by JavaCCParser, and a table of these numbers is\r
+ * stored in the file ...Constants.java.\r
+ */\r
+ public int kind;\r
+\r
+ /** The line number of the first character of this Token. */\r
+ public int beginLine;\r
+ /** The column number of the first character of this Token. */\r
+ public int beginColumn;\r
+ /** The line number of the last character of this Token. */\r
+ public int endLine;\r
+ /** The column number of the last character of this Token. */\r
+ public int endColumn;\r
+\r
+ /**\r
+ * The string image of the token.\r
+ */\r
+ public String image;\r
+\r
+ /**\r
+ * A reference to the next regular (non-special) token from the input\r
+ * stream. If this is the last token from the input stream, or if the\r
+ * token manager has not read tokens beyond this one, this field is\r
+ * set to null. This is true only if this token is also a regular\r
+ * token. Otherwise, see below for a description of the contents of\r
+ * this field.\r
+ */\r
+ public Token next;\r
+\r
+ /**\r
+ * This field is used to access special tokens that occur prior to this\r
+ * token, but after the immediately preceding regular (non-special) token.\r
+ * If there are no such special tokens, this field is set to null.\r
+ * When there are more than one such special token, this field refers\r
+ * to the last of these special tokens, which in turn refers to the next\r
+ * previous special token through its specialToken field, and so on\r
+ * until the first special token (whose specialToken field is null).\r
+ * The next fields of special tokens refer to other special tokens that\r
+ * immediately follow it (without an intervening regular token). If there\r
+ * is no such token, this field is null.\r
+ */\r
+ public Token specialToken;\r
+\r
+ /**\r
+ * An optional attribute value of the Token.\r
+ * Tokens which are not used as syntactic sugar will often contain\r
+ * meaningful values that will be used later on by the compiler or\r
+ * interpreter. This attribute value is often different from the image.\r
+ * Any subclass of Token that actually wants to return a non-null value can\r
+ * override this method as appropriate.\r
+ */\r
+ public Object getValue() {\r
+ return null;\r
+ }\r
+\r
+ /**\r
+ * No-argument constructor\r
+ */\r
+ public Token() {}\r
+\r
+ /**\r
+ * Constructs a new token for the specified Image.\r
+ */\r
+ public Token(int kind)\r
+ {\r
+ this(kind, null);\r
+ }\r
+\r
+ /**\r
+ * Constructs a new token for the specified Image and Kind.\r
+ */\r
+ public Token(int kind, String image)\r
+ {\r
+ this.kind = kind;\r
+ this.image = image;\r
+ }\r
+\r
+ /**\r
+ * Returns the image.\r
+ */\r
+ public String toString()\r
+ {\r
+ return image;\r
+ }\r
+\r
+ /**\r
+ * Returns a new Token object, by default. However, if you want, you\r
+ * can create and return subclass objects based on the value of ofKind.\r
+ * Simply add the cases to the switch for all those special cases.\r
+ * For example, if you have a subclass of Token called IDToken that\r
+ * you want to create if ofKind is ID, simply add something like :\r
+ *\r
+ * case MyParserConstants.ID : return new IDToken(ofKind, image);\r
+ *\r
+ * to the following switch statement. Then you can cast matchedToken\r
+ * variable to the appropriate type and use sit in your lexical actions.\r
+ */\r
+ public static Token newToken(int ofKind, String image)\r
+ {\r
+ switch(ofKind)\r
+ {\r
+ default : return new Token(ofKind, image);\r
+ }\r
+ }\r
+\r
+ public static Token newToken(int ofKind)\r
+ {\r
+ return newToken(ofKind, null);\r
+ }\r
+\r
+}\r
+/* JavaCC - OriginalChecksum=ed7a6d865f7fbc2c64e008e34bd824b0 (do not edit this line) */\r
--- /dev/null
+/* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 5.0 */\r
+/* JavaCCOptions: */\r
+package org.simantics.sysdyn.expressionParser;\r
+\r
+/** Token Manager Error. */\r
+public class TokenMgrError extends Error\r
+{\r
+\r
+ /**\r
+ * The version identifier for this Serializable class.\r
+ * Increment only if the <i>serialized</i> form of the\r
+ * class changes.\r
+ */\r
+ private static final long serialVersionUID = 1L;\r
+\r
+ /*\r
+ * Ordinals for various reasons why an Error of this type can be thrown.\r
+ */\r
+\r
+ /**\r
+ * Lexical error occurred.\r
+ */\r
+ static final int LEXICAL_ERROR = 0;\r
+\r
+ /**\r
+ * An attempt was made to create a second instance of a static token manager.\r
+ */\r
+ static final int STATIC_LEXER_ERROR = 1;\r
+\r
+ /**\r
+ * Tried to change to an invalid lexical state.\r
+ */\r
+ static final int INVALID_LEXICAL_STATE = 2;\r
+\r
+ /**\r
+ * Detected (and bailed out of) an infinite loop in the token manager.\r
+ */\r
+ static final int LOOP_DETECTED = 3;\r
+\r
+ /**\r
+ * Indicates the reason why the exception is thrown. It will have\r
+ * one of the above 4 values.\r
+ */\r
+ int errorCode;\r
+\r
+ /**\r
+ * Replaces unprintable characters by their escaped (or unicode escaped)\r
+ * equivalents in the given string\r
+ */\r
+ protected static final String addEscapes(String str) {\r
+ StringBuffer retval = new StringBuffer();\r
+ char ch;\r
+ for (int i = 0; i < str.length(); i++) {\r
+ switch (str.charAt(i))\r
+ {\r
+ case 0 :\r
+ continue;\r
+ case '\b':\r
+ retval.append("\\b");\r
+ continue;\r
+ case '\t':\r
+ retval.append("\\t");\r
+ continue;\r
+ case '\n':\r
+ retval.append("\\n");\r
+ continue;\r
+ case '\f':\r
+ retval.append("\\f");\r
+ continue;\r
+ case '\r':\r
+ retval.append("\\r");\r
+ continue;\r
+ case '\"':\r
+ retval.append("\\\"");\r
+ continue;\r
+ case '\'':\r
+ retval.append("\\\'");\r
+ continue;\r
+ case '\\':\r
+ retval.append("\\\\");\r
+ continue;\r
+ default:\r
+ if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) {\r
+ String s = "0000" + Integer.toString(ch, 16);\r
+ retval.append("\\u" + s.substring(s.length() - 4, s.length()));\r
+ } else {\r
+ retval.append(ch);\r
+ }\r
+ continue;\r
+ }\r
+ }\r
+ return retval.toString();\r
+ }\r
+\r
+ /**\r
+ * Returns a detailed message for the Error when it is thrown by the\r
+ * token manager to indicate a lexical error.\r
+ * Parameters :\r
+ * EOFSeen : indicates if EOF caused the lexical error\r
+ * curLexState : lexical state in which this error occurred\r
+ * errorLine : line number when the error occurred\r
+ * errorColumn : column number when the error occurred\r
+ * errorAfter : prefix that was seen before this error occurred\r
+ * curchar : the offending character\r
+ * Note: You can customize the lexical error message by modifying this method.\r
+ */\r
+ protected static String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) {\r
+ return("Lexical error at line " +\r
+ errorLine + ", column " +\r
+ errorColumn + ". Encountered: " +\r
+ (EOFSeen ? "<EOF> " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int)curChar + "), ") +\r
+ "after : \"" + addEscapes(errorAfter) + "\"");\r
+ }\r
+\r
+ /**\r
+ * You can also modify the body of this method to customize your error messages.\r
+ * For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not\r
+ * of end-users concern, so you can return something like :\r
+ *\r
+ * "Internal Error : Please file a bug report .... "\r
+ *\r
+ * from this method for such cases in the release version of your parser.\r
+ */\r
+ public String getMessage() {\r
+ return super.getMessage();\r
+ }\r
+\r
+ /*\r
+ * Constructors of various flavors follow.\r
+ */\r
+\r
+ /** No arg constructor. */\r
+ public TokenMgrError() {\r
+ }\r
+\r
+ /** Constructor with message and reason. */\r
+ public TokenMgrError(String message, int reason) {\r
+ super(message);\r
+ errorCode = reason;\r
+ }\r
+\r
+ /** Full Constructor. */\r
+ public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) {\r
+ this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason);\r
+ }\r
+}\r
+/* JavaCC - OriginalChecksum=24b6b4792f62099f85bde9ed73a49451 (do not edit this line) */\r