Skip to content

Commit b7007cb

Browse files
committed
Removed lookahead predicate from exprt (expression term).
I'm sure this will break something, but the predicate was causing Proparse to hang when processing very long IF THEN ELSE IF THEN ELSE chains. Please report any new issues! I think this might break some newer syntax where keywords are (now) allowed to be used as class, method, and property names.
1 parent cdd3257 commit b7007cb

File tree

7 files changed

+936
-904
lines changed

7 files changed

+936
-904
lines changed

build.number

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#Build Number for ANT. Do not edit!
2-
#Wed Oct 07 14:00:29 PDT 2015
3-
build.number=1124
2+
#Thu Oct 08 11:24:45 PDT 2015
3+
build.number=1126

data/bugsfixed/bug11.p

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
Test that long IF THEN ELSE IF THEN ELSE chains don't cause Proparse to hang.
3+
4+
In proparse.g, I had a lookahead predicate in exprt like this:
5+
(exprt2)=> exprt2
6+
I think I had added that lookahead predicate back in 2009:
7+
"First steps toward support of static member references and namespace.class
8+
names using reserved keywords"
9+
10+
That lookahead predicate resulted in the parser to hang on the following code.
11+
I found at around 10 ELSE conditions, I could see Proparse taking a few seconds
12+
to process this, then adding another ELSE seemed to increase the time, perhaps
13+
exponentially. Something like that anyway.
14+
15+
So now (Oct 2015) I'm removing that lookahead predicate from proparse.g.
16+
I suspect doing this will break something, but my regression tests seem OK.
17+
(See newsyntax/102b/DisplayTest.p and Display.cls)
18+
*/
19+
20+
DEFINE VARIABLE lv-i AS INTEGER NO-UNDO.
21+
DEFINE VARIABLE lv-DescId AS CHARACTER NO-UNDO.
22+
23+
DO lv-i = 1 TO 17 BY 1:
24+
25+
ASSIGN
26+
lv-DescId = (IF lv-i = 1 THEN "Include In Tender?"
27+
ELSE IF lv-i = 2 THEN "Data Checked?"
28+
ELSE IF lv-i = 3 THEN "Authority To Accept?"
29+
ELSE IF lv-i = 4 THEN "Authority To Tender / Negotiate?"
30+
ELSE IF lv-i = 5 THEN "Authority To Terminate?"
31+
ELSE IF lv-i = 6 THEN "100Kw Site?"
32+
ELSE IF lv-i = 7 THEN "Tendered?"
33+
ELSE IF lv-i = 8 THEN "Interruptable"
34+
ELSE IF lv-i = 9 THEN "Tender Issue Status"
35+
ELSE IF lv-i = 10 THEN "Supplier Agreement Admin Problem?"
36+
ELSE IF lv-i = 11 THEN "View Front End Specification Records"
37+
ELSE IF lv-i = 12 THEN "Set Costing Parameters"
38+
ELSE IF lv-i = 13 THEN "Swap Columns..."
39+
ELSE IF lv-i = 14 THEN "Override Checks!"
40+
ELSE IF lv-i = 15 THEN "Energy Trading Override!"
41+
ELSE IF lv-i = 16 THEN "Add to Tender Basket"
42+
ELSE "Approval to Tender").
43+
END. /* DO lv-i = 1 TO 17: */
44+

data/newsyntax/102b/Display.cls

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/* For testing keywords as class, property, method names */
2+
3+
class newsyntax.102b.Display:
4+
5+
def public static property Message as char init "hello" get. set.
6+
7+
method public static char For():
8+
return "hi".
9+
end method.
10+
11+
end class.

data/newsyntax/102b/DisplayTest.p

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
using newsyntax.102b.*.
2+
3+
compile newsyntax/102b/Display.cls.
4+
5+
display Display:For().
6+
display Display:Message.

0 commit comments

Comments
 (0)