Skip to content

Commit

Permalink
Removed lookahead predicate from exprt (expression term).
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
joagr committed Oct 8, 2015
1 parent cdd3257 commit b7007cb
Show file tree
Hide file tree
Showing 7 changed files with 936 additions and 904 deletions.
4 changes: 2 additions & 2 deletions build.number
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#Build Number for ANT. Do not edit!
#Wed Oct 07 14:00:29 PDT 2015
build.number=1124
#Thu Oct 08 11:24:45 PDT 2015
build.number=1126
44 changes: 44 additions & 0 deletions data/bugsfixed/bug11.p
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
Test that long IF THEN ELSE IF THEN ELSE chains don't cause Proparse to hang.
In proparse.g, I had a lookahead predicate in exprt like this:
(exprt2)=> exprt2
I think I had added that lookahead predicate back in 2009:
"First steps toward support of static member references and namespace.class
names using reserved keywords"
That lookahead predicate resulted in the parser to hang on the following code.
I found at around 10 ELSE conditions, I could see Proparse taking a few seconds
to process this, then adding another ELSE seemed to increase the time, perhaps
exponentially. Something like that anyway.
So now (Oct 2015) I'm removing that lookahead predicate from proparse.g.
I suspect doing this will break something, but my regression tests seem OK.
(See newsyntax/102b/DisplayTest.p and Display.cls)
*/

DEFINE VARIABLE lv-i AS INTEGER NO-UNDO.
DEFINE VARIABLE lv-DescId AS CHARACTER NO-UNDO.

DO lv-i = 1 TO 17 BY 1:

ASSIGN
lv-DescId = (IF lv-i = 1 THEN "Include In Tender?"
ELSE IF lv-i = 2 THEN "Data Checked?"
ELSE IF lv-i = 3 THEN "Authority To Accept?"
ELSE IF lv-i = 4 THEN "Authority To Tender / Negotiate?"
ELSE IF lv-i = 5 THEN "Authority To Terminate?"
ELSE IF lv-i = 6 THEN "100Kw Site?"
ELSE IF lv-i = 7 THEN "Tendered?"
ELSE IF lv-i = 8 THEN "Interruptable"
ELSE IF lv-i = 9 THEN "Tender Issue Status"
ELSE IF lv-i = 10 THEN "Supplier Agreement Admin Problem?"
ELSE IF lv-i = 11 THEN "View Front End Specification Records"
ELSE IF lv-i = 12 THEN "Set Costing Parameters"
ELSE IF lv-i = 13 THEN "Swap Columns..."
ELSE IF lv-i = 14 THEN "Override Checks!"
ELSE IF lv-i = 15 THEN "Energy Trading Override!"
ELSE IF lv-i = 16 THEN "Add to Tender Basket"
ELSE "Approval to Tender").
END. /* DO lv-i = 1 TO 17: */

11 changes: 11 additions & 0 deletions data/newsyntax/102b/Display.cls
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* For testing keywords as class, property, method names */

class newsyntax.102b.Display:

def public static property Message as char init "hello" get. set.

method public static char For():
return "hi".
end method.

end class.
6 changes: 6 additions & 0 deletions data/newsyntax/102b/DisplayTest.p
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
using newsyntax.102b.*.

compile newsyntax/102b/Display.cls.

display Display:For().
display Display:Message.
Loading

0 comments on commit b7007cb

Please sign in to comment.