From 941f5f68ee3b5d3b3419d5653470001277e5d923 Mon Sep 17 00:00:00 2001 From: miettinen Date: Mon, 23 Jun 2014 07:12:01 +0000 Subject: [PATCH] E notation correction (accept numbers written in E notation with plus sign, like 1E+005) for Sysdyn internal solver (refs #4935). git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@29683 ac1ea38d-2e2b-0410-8846-a27921b304fc --- .../parser/ModelParserTokenManager.java | 197 ++++++++++-------- .../sysdyn/solver/parser/ModelicaParser.jj | 2 +- .../sysdyn/solver/parser/ModelicaParser.jjt | 2 +- 3 files changed, 111 insertions(+), 90 deletions(-) diff --git a/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/parser/ModelParserTokenManager.java b/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/parser/ModelParserTokenManager.java index 5aa460e2..dd082219 100644 --- a/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/parser/ModelParserTokenManager.java +++ b/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/parser/ModelParserTokenManager.java @@ -16,18 +16,18 @@ private final int jjStopStringLiteralDfa_0(int pos, long active0, long active1) { case 0: if ((active1 & 0x80000L) != 0L) - return 20; - if ((active0 & 0x377bdef7bdef7bf0L) != 0L || (active1 & 0x180000000L) != 0L) + return 22; + if ((active1 & 0xb30010L) != 0L) + return 10; + if ((active0 & 0x884210842108400L) != 0L) { jjmatchedKind = 90; - return 2; + return 48; } - if ((active1 & 0xb30010L) != 0L) - return 13; - if ((active0 & 0x884210842108400L) != 0L) + if ((active0 & 0x377bdef7bdef7bf0L) != 0L || (active1 & 0x180000000L) != 0L) { jjmatchedKind = 90; - return 44; + return 2; } return -1; case 1: @@ -190,7 +190,7 @@ private int jjMoveStringLiteralDfa0_0() jjmatchedKind = 68; return jjMoveStringLiteralDfa1_0(0x0L, 0xb30000L); case 47: - return jjStartNfaWithStates_0(0, 83, 20); + return jjStartNfaWithStates_0(0, 83, 22); case 58: jjmatchedKind = 69; return jjMoveStringLiteralDfa1_0(0x0L, 0x2000000L); @@ -941,7 +941,7 @@ static final long[] jjbitVec0 = { private int jjMoveNfa_0(int startState, int curPos) { int startsAt = 0; - jjnewStateCnt = 44; + jjnewStateCnt = 48; int i = 1; jjstateSet[0] = startState; int kind = 0x7fffffff; @@ -971,29 +971,34 @@ private int jjMoveNfa_0(int startState, int curPos) else if (curChar == 47) jjAddStates(7, 8); else if (curChar == 46) - jjCheckNAdd(13); + jjCheckNAdd(10); else if (curChar == 34) jjCheckNAddStates(9, 11); break; - case 44: + case 48: if ((0x3ff400000000000L & l) != 0L) { if (kind > 90) kind = 90; jjCheckNAdd(2); } + else if (curChar == 43) + { + if (kind > 92) + kind = 92; + } else if (curChar == 45) { if (kind > 92) kind = 92; } break; - case 20: + case 22: if (curChar == 47) { if (kind > 3) kind = 3; - jjCheckNAdd(27); + jjCheckNAdd(29); } else if (curChar == 42) jjCheckNAddStates(12, 14); @@ -1022,126 +1027,142 @@ private int jjMoveNfa_0(int startState, int curPos) kind = 91; break; case 9: - if (curChar == 45 && kind > 92) - kind = 92; - break; - case 12: if (curChar == 46) - jjCheckNAdd(13); + jjCheckNAdd(10); break; - case 13: + case 10: if ((0x3ff000000000000L & l) == 0L) break; if (kind > 94) kind = 94; jjCheckNAddStates(15, 18); break; - case 15: + case 12: if ((0x3ff000000000000L & l) == 0L) break; if (kind > 94) kind = 94; - jjCheckNAdd(15); + jjCheckNAdd(12); break; - case 16: + case 14: if (curChar == 45) - jjCheckNAdd(15); + jjCheckNAdd(12); + break; + case 15: + if (curChar == 43) + jjCheckNAdd(12); + break; + case 18: + if (curChar == 45 && kind > 92) + kind = 92; break; case 19: + if (curChar == 43 && kind > 92) + kind = 92; + break; + case 21: if (curChar == 47) jjAddStates(7, 8); break; - case 21: + case 23: if ((0xfffffbffffffffffL & l) != 0L) jjCheckNAddStates(12, 14); break; - case 22: + case 24: if (curChar == 42) - jjstateSet[jjnewStateCnt++] = 23; + jjstateSet[jjnewStateCnt++] = 25; break; - case 23: + case 25: if ((0xffff7fffffffffffL & l) != 0L) jjCheckNAddStates(12, 14); break; - case 24: + case 26: if (curChar == 47 && kind > 2) kind = 2; break; - case 25: + case 27: if (curChar == 42) - jjstateSet[jjnewStateCnt++] = 24; + jjstateSet[jjnewStateCnt++] = 26; break; - case 26: + case 28: if (curChar != 47) break; if (kind > 3) kind = 3; - jjCheckNAdd(27); + jjCheckNAdd(29); break; - case 27: + case 29: if ((0xfffffffffffffbffL & l) == 0L) break; if (kind > 3) kind = 3; - jjCheckNAdd(27); + jjCheckNAdd(29); break; - case 28: + case 30: if ((0x3ff000000000000L & l) == 0L) break; if (kind > 93) kind = 93; jjCheckNAddStates(0, 6); break; - case 29: + case 31: if ((0x3ff000000000000L & l) == 0L) break; if (kind > 93) kind = 93; - jjCheckNAdd(29); + jjCheckNAdd(31); break; - case 30: + case 32: if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(30, 31); + jjCheckNAddTwoStates(32, 33); break; - case 31: + case 33: if (curChar != 46) break; if (kind > 94) kind = 94; jjCheckNAddStates(19, 22); break; - case 32: + case 34: if ((0x3ff000000000000L & l) == 0L) break; if (kind > 94) kind = 94; jjCheckNAddStates(19, 22); break; - case 34: + case 36: if ((0x3ff000000000000L & l) == 0L) break; if (kind > 94) kind = 94; - jjCheckNAdd(34); + jjCheckNAdd(36); break; - case 35: + case 38: if (curChar == 45) - jjCheckNAdd(34); + jjCheckNAdd(36); break; - case 38: + case 39: + if (curChar == 43) + jjCheckNAdd(36); + break; + case 41: if ((0x3ff000000000000L & l) != 0L) jjCheckNAddStates(23, 26); break; - case 40: + case 43: if ((0x3ff000000000000L & l) == 0L) break; if (kind > 94) kind = 94; - jjCheckNAdd(40); + jjCheckNAdd(43); break; - case 41: + case 45: if (curChar == 45) - jjCheckNAdd(40); + jjCheckNAdd(43); + break; + case 46: + if (curChar == 43) + jjCheckNAdd(43); break; default : break; } @@ -1167,11 +1188,11 @@ private int jjMoveNfa_0(int startState, int curPos) kind = 92; } if (curChar == 69) - jjCheckNAdd(9); + jjCheckNAddTwoStates(18, 19); else if (curChar == 101) - jjCheckNAdd(9); + jjCheckNAddTwoStates(18, 19); break; - case 44: + case 48: case 2: if ((0x7fffffe87fffffeL & l) == 0L) break; @@ -1201,58 +1222,58 @@ private int jjMoveNfa_0(int startState, int curPos) if ((0x2000000020L & l) != 0L && kind > 92) kind = 92; break; - case 10: + case 11: + if ((0x2000000020L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 12; + break; + case 13: if (curChar == 101) - jjCheckNAdd(9); + jjCheckNAddTwoStates(14, 15); break; - case 11: + case 16: if (curChar == 69) - jjCheckNAdd(9); - break; - case 14: - if ((0x2000000020L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 15; + jjCheckNAddTwoStates(14, 15); break; case 17: if (curChar == 101) - jjCheckNAdd(16); + jjCheckNAddTwoStates(18, 19); break; - case 18: + case 20: if (curChar == 69) - jjCheckNAdd(16); + jjCheckNAddTwoStates(18, 19); break; - case 21: case 23: + case 25: jjCheckNAddStates(12, 14); break; - case 27: + case 29: if (kind > 3) kind = 3; - jjstateSet[jjnewStateCnt++] = 27; + jjstateSet[jjnewStateCnt++] = 29; break; - case 33: + case 35: if ((0x2000000020L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 34; + jjstateSet[jjnewStateCnt++] = 36; break; - case 36: + case 37: if (curChar == 101) - jjCheckNAdd(35); + jjCheckNAddTwoStates(38, 39); break; - case 37: + case 40: if (curChar == 69) - jjCheckNAdd(35); + jjCheckNAddTwoStates(38, 39); break; - case 39: + case 42: if ((0x2000000020L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 40; + jjstateSet[jjnewStateCnt++] = 43; break; - case 42: + case 44: if (curChar == 101) - jjCheckNAdd(41); + jjCheckNAddTwoStates(45, 46); break; - case 43: + case 47: if (curChar == 69) - jjCheckNAdd(41); + jjCheckNAddTwoStates(45, 46); break; default : break; } @@ -1271,17 +1292,17 @@ private int jjMoveNfa_0(int startState, int curPos) if ((jjbitVec0[i2] & l2) != 0L) jjCheckNAddStates(9, 11); break; - case 21: case 23: + case 25: if ((jjbitVec0[i2] & l2) != 0L) jjCheckNAddStates(12, 14); break; - case 27: + case 29: if ((jjbitVec0[i2] & l2) == 0L) break; if (kind > 3) kind = 3; - jjstateSet[jjnewStateCnt++] = 27; + jjstateSet[jjnewStateCnt++] = 29; break; default : break; } @@ -1294,15 +1315,15 @@ private int jjMoveNfa_0(int startState, int curPos) kind = 0x7fffffff; } ++curPos; - if ((i = jjnewStateCnt) == (startsAt = 44 - (jjnewStateCnt = startsAt))) + if ((i = jjnewStateCnt) == (startsAt = 48 - (jjnewStateCnt = startsAt))) return curPos; try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { return curPos; } } } static final int[] jjnextStates = { - 29, 30, 31, 38, 39, 42, 43, 20, 26, 4, 5, 7, 21, 22, 25, 13, - 14, 17, 18, 32, 33, 36, 37, 38, 39, 42, 43, + 31, 32, 33, 41, 42, 44, 47, 22, 28, 4, 5, 7, 23, 24, 27, 10, + 11, 13, 16, 34, 35, 37, 40, 41, 42, 44, 47, }; /** Token literal values. */ @@ -1341,8 +1362,8 @@ static final long[] jjtoSkip = { 0xeL, 0x0L, }; protected SimpleCharStream input_stream; -private final int[] jjrounds = new int[44]; -private final int[] jjstateSet = new int[88]; +private final int[] jjrounds = new int[48]; +private final int[] jjstateSet = new int[96]; private final StringBuilder jjimage = new StringBuilder(); private StringBuilder image = jjimage; private int jjimageLen; @@ -1373,7 +1394,7 @@ private void ReInitRounds() { int i; jjround = 0x80000001; - for (i = 44; i-- > 0;) + for (i = 48; i-- > 0;) jjrounds[i] = 0x80000000; } diff --git a/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/parser/ModelicaParser.jj b/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/parser/ModelicaParser.jj index 190ea2f8..839340c8 100644 --- a/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/parser/ModelicaParser.jj +++ b/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/parser/ModelicaParser.jj @@ -78,7 +78,7 @@ TOKEN: | | { matchedToken.image = matchedToken.image.substring(1,matchedToken.image.length()-1); } -| +| | | "." ()? ( )? diff --git a/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/parser/ModelicaParser.jjt b/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/parser/ModelicaParser.jjt index 2fc5f9ce..c65900fd 100644 --- a/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/parser/ModelicaParser.jjt +++ b/fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/parser/ModelicaParser.jjt @@ -74,7 +74,7 @@ TOKEN: | | { matchedToken.image = matchedToken.image.substring(1,matchedToken.image.length()-1); } -| +| | | "." ()? ( )? -- 2.47.1