From 8b33bd93a9e44b0446f315f897d1d9c880ebc8ec Mon Sep 17 00:00:00 2001 From: lempinen Date: Tue, 1 Mar 2011 14:05:29 +0000 Subject: [PATCH] git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@19860 ac1ea38d-2e2b-0410-8846-a27921b304fc --- .../expressionParser/ExpressionParser.java | 358 ++++++++++-------- 1 file changed, 190 insertions(+), 168 deletions(-) diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/expressionParser/ExpressionParser.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/expressionParser/ExpressionParser.java index b41672bc..cc764b6c 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/expressionParser/ExpressionParser.java +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/expressionParser/ExpressionParser.java @@ -10,7 +10,23 @@ import java.util.HashMap; public class ExpressionParser implements ExpressionParserConstants { + public class ForRange { + public Token start; + public Token end; + } + boolean forIndex = false; + Token firstToken; + + public Token getFirstToken() { + return firstToken; + } + + List forRanges = new ArrayList(); + + public List getForRanges() { + return forRanges; + } HashMap> references = new HashMap>(); @@ -45,7 +61,6 @@ public class ExpressionParser implements ExpressionParserConstants { // [ add_op ] -> ( add_op() )? // { add_op term } -> ( add_op() term() )* final public void expr() throws ParseException { - references = new HashMap>(); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 6: case 12: @@ -62,10 +77,12 @@ public class ExpressionParser implements ExpressionParserConstants { case STRING: case UNSIGNED_INTEGER: case UNSIGNED_NUMBER: + firstToken = token; simple_expression(); jj_consume_token(0); break; case 31: + firstToken = token; jj_consume_token(31); expression(); jj_consume_token(28); @@ -593,7 +610,12 @@ public class ExpressionParser implements ExpressionParserConstants { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 41: jj_consume_token(41); + ForRange forRange = new ForRange(); + forRange.start = token; expression(); + forRange.start = forRange.start.next; + forRange.end = token; + forRanges.add(forRange); break; default: jj_la1[29] = jj_gen; @@ -726,7 +748,7 @@ public class ExpressionParser implements ExpressionParserConstants { final public void subscript(List currentRange) throws ParseException { Token rangeToken = new Token(token.kind, ""); - rangeToken.beginColumn = token.beginColumn; + rangeToken.beginColumn = token.beginColumn + 1; rangeToken.beginLine = token.beginLine; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 69: @@ -789,165 +811,6 @@ public class ExpressionParser implements ExpressionParserConstants { finally { jj_save(1, xla); } } - private boolean jj_3R_45() { - if (jj_scan_token(87)) return true; - return false; - } - - private boolean jj_3R_53() { - if (jj_3R_13()) return true; - return false; - } - - private boolean jj_3R_49() { - if (jj_3R_13()) return true; - return false; - } - - private boolean jj_3R_44() { - if (jj_scan_token(64)) return true; - if (jj_3R_50()) return true; - return false; - } - - private boolean jj_3R_48() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_53()) jj_scanpos = xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3R_54()) { jj_scanpos = xsp; break; } - } - return false; - } - - private boolean jj_3R_43() { - if (jj_scan_token(66)) return true; - if (jj_3R_49()) return true; - return false; - } - - private boolean jj_3R_40() { - if (jj_3R_12()) return true; - if (jj_3R_46()) return true; - return false; - } - - private boolean jj_3R_42() { - if (jj_scan_token(62)) return true; - if (jj_3R_48()) return true; - if (jj_scan_token(63)) return true; - return false; - } - - private boolean jj_3R_38() { - Token xsp; - xsp = jj_scanpos; - if (jj_scan_token(86)) { - jj_scanpos = xsp; - if (jj_3R_45()) return true; - } - return false; - } - - private boolean jj_3R_41() { - if (jj_3R_47()) return true; - return false; - } - - private boolean jj_3R_37() { - Token xsp; - xsp = jj_scanpos; - if (jj_scan_token(93)) { - jj_scanpos = xsp; - if (jj_scan_token(92)) { - jj_scanpos = xsp; - if (jj_scan_token(91)) { - jj_scanpos = xsp; - if (jj_scan_token(6)) { - jj_scanpos = xsp; - if (jj_scan_token(33)) { - jj_scanpos = xsp; - if (jj_3R_40()) { - jj_scanpos = xsp; - if (jj_3R_41()) { - jj_scanpos = xsp; - if (jj_3R_42()) { - jj_scanpos = xsp; - if (jj_3R_43()) { - jj_scanpos = xsp; - if (jj_3R_44()) { - jj_scanpos = xsp; - if (jj_scan_token(35)) return true; - } - } - } - } - } - } - } - } - } - } - return false; - } - - private boolean jj_3R_58() { - if (jj_scan_token(IDENT)) return true; - return false; - } - - private boolean jj_3R_18() { - if (jj_scan_token(71)) return true; - return false; - } - - private boolean jj_3R_14() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_18()) { - jj_scanpos = xsp; - if (jj_3R_19()) return true; - } - return false; - } - - private boolean jj_3R_57() { - if (jj_3R_58()) return true; - return false; - } - - private boolean jj_3R_36() { - if (jj_3R_39()) return true; - return false; - } - - private boolean jj_3R_29() { - if (jj_3R_33()) return true; - return false; - } - - private boolean jj_3R_32() { - if (jj_3R_34()) return true; - return false; - } - - private boolean jj_3R_39() { - Token xsp; - xsp = jj_scanpos; - if (jj_scan_token(82)) { - jj_scanpos = xsp; - if (jj_scan_token(83)) { - jj_scanpos = xsp; - if (jj_scan_token(84)) { - jj_scanpos = xsp; - if (jj_scan_token(85)) return true; - } - } - } - return false; - } - private boolean jj_3R_35() { if (jj_3R_37()) return true; Token xsp; @@ -1124,6 +987,11 @@ public class ExpressionParser implements ExpressionParserConstants { return false; } + private boolean jj_3R_54() { + if (jj_scan_token(71)) return true; + return false; + } + private boolean jj_3R_13() { Token xsp; xsp = jj_scanpos; @@ -1139,14 +1007,14 @@ public class ExpressionParser implements ExpressionParserConstants { return false; } - private boolean jj_3R_15() { - if (jj_scan_token(68)) return true; - if (jj_3R_12()) return true; + private boolean jj_3R_56() { + if (jj_scan_token(66)) return true; return false; } - private boolean jj_3R_54() { - if (jj_scan_token(71)) return true; + private boolean jj_3R_15() { + if (jj_scan_token(68)) return true; + if (jj_3R_12()) return true; return false; } @@ -1165,8 +1033,24 @@ public class ExpressionParser implements ExpressionParserConstants { return false; } - private boolean jj_3R_56() { - if (jj_scan_token(66)) return true; + private boolean jj_3R_53() { + if (jj_3R_13()) return true; + return false; + } + + private boolean jj_3R_49() { + if (jj_3R_13()) return true; + return false; + } + + private boolean jj_3R_48() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_53()) jj_scanpos = xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_54()) { jj_scanpos = xsp; break; } + } return false; } @@ -1184,6 +1068,144 @@ public class ExpressionParser implements ExpressionParserConstants { return false; } + private boolean jj_3R_58() { + if (jj_scan_token(IDENT)) return true; + return false; + } + + private boolean jj_3R_45() { + if (jj_scan_token(87)) return true; + return false; + } + + private boolean jj_3R_57() { + if (jj_3R_58()) return true; + return false; + } + + private boolean jj_3R_44() { + if (jj_scan_token(64)) return true; + if (jj_3R_50()) return true; + return false; + } + + private boolean jj_3R_43() { + if (jj_scan_token(66)) return true; + if (jj_3R_49()) return true; + return false; + } + + private boolean jj_3R_40() { + if (jj_3R_12()) return true; + if (jj_3R_46()) return true; + return false; + } + + private boolean jj_3R_42() { + if (jj_scan_token(62)) return true; + if (jj_3R_48()) return true; + if (jj_scan_token(63)) return true; + return false; + } + + private boolean jj_3R_38() { + Token xsp; + xsp = jj_scanpos; + if (jj_scan_token(86)) { + jj_scanpos = xsp; + if (jj_3R_45()) return true; + } + return false; + } + + private boolean jj_3R_41() { + if (jj_3R_47()) return true; + return false; + } + + private boolean jj_3R_37() { + Token xsp; + xsp = jj_scanpos; + if (jj_scan_token(93)) { + jj_scanpos = xsp; + if (jj_scan_token(92)) { + jj_scanpos = xsp; + if (jj_scan_token(91)) { + jj_scanpos = xsp; + if (jj_scan_token(6)) { + jj_scanpos = xsp; + if (jj_scan_token(33)) { + jj_scanpos = xsp; + if (jj_3R_40()) { + jj_scanpos = xsp; + if (jj_3R_41()) { + jj_scanpos = xsp; + if (jj_3R_42()) { + jj_scanpos = xsp; + if (jj_3R_43()) { + jj_scanpos = xsp; + if (jj_3R_44()) { + jj_scanpos = xsp; + if (jj_scan_token(35)) return true; + } + } + } + } + } + } + } + } + } + } + return false; + } + + private boolean jj_3R_18() { + if (jj_scan_token(71)) return true; + return false; + } + + private boolean jj_3R_14() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_18()) { + jj_scanpos = xsp; + if (jj_3R_19()) return true; + } + return false; + } + + private boolean jj_3R_36() { + if (jj_3R_39()) return true; + return false; + } + + private boolean jj_3R_29() { + if (jj_3R_33()) return true; + return false; + } + + private boolean jj_3R_32() { + if (jj_3R_34()) return true; + return false; + } + + private boolean jj_3R_39() { + Token xsp; + xsp = jj_scanpos; + if (jj_scan_token(82)) { + jj_scanpos = xsp; + if (jj_scan_token(83)) { + jj_scanpos = xsp; + if (jj_scan_token(84)) { + jj_scanpos = xsp; + if (jj_scan_token(85)) return true; + } + } + } + return false; + } + /** Generated Token Manager. */ public ExpressionParserTokenManager token_source; SimpleCharStream jj_input_stream; -- 2.47.1