Attaching a patch that reduces the lookahead in ij.jj from 2 to 1, thereby enabling lookahead adequacy checking and silencing the warning. The following grammar changes were needed to make it work with lookahead 1:

1) Remove the duplicate reference to FirstStatement in the grammar

2) Refactor the ConnectStatement rule so that it doesn't branch until after the common prefix <CONNECT> has been seen

3) dynamicConnection/attributeList: Add a lookahead hint in attributeList to avoid ambiguity when the attribute list is empty and followed by AS (as in CONNECT '...' ATTRIBUTES AS C1, where a lookahead of 1 wouldn't be enough to determine whether AS was a property name or a keyword)

4) Merge the rules for qualified and unqualified table names in DescTableStatement

5) Factor out the common prefix <SHOW> in ShowStatement

6) Merge the rules IllegalStatementName and PrepareStatement into a single rule with the common prefix <PREPARE> factored out

7) Merge the three rules JBMSPreparedStatementExec, F2KExecuteProcedure and ExecuteStatement into a single rule, with the common prefix <EXECUTE> factored out

Knut Anders Hatlen
added a comment - 31/Oct/10 19:20 Attaching a patch that reduces the lookahead in ij.jj from 2 to 1, thereby enabling lookahead adequacy checking and silencing the warning. The following grammar changes were needed to make it work with lookahead 1:
1) Remove the duplicate reference to FirstStatement in the grammar
2) Refactor the ConnectStatement rule so that it doesn't branch until after the common prefix <CONNECT> has been seen
3) dynamicConnection/attributeList: Add a lookahead hint in attributeList to avoid ambiguity when the attribute list is empty and followed by AS (as in CONNECT '...' ATTRIBUTES AS C1, where a lookahead of 1 wouldn't be enough to determine whether AS was a property name or a keyword)
4) Merge the rules for qualified and unqualified table names in DescTableStatement
5) Factor out the common prefix <SHOW> in ShowStatement
6) Merge the rules IllegalStatementName and PrepareStatement into a single rule with the common prefix <PREPARE> factored out
7) Merge the three rules JBMSPreparedStatementExec, F2KExecuteProcedure and ExecuteStatement into a single rule, with the common prefix <EXECUTE> factored out

If we do as the warning says, and set FORCE_LA_CHECK to true, we get even more warnings, since it then warns us about everything that would have been a problem if LOOKAHEAD had been 1 (it is 2). But I think it should be fairly straightforward to massage the grammar into a shape in which it's safe to lower the lookahead to 1.

Getting rid of the warning isn't just about reducing noise in the build. If we'd had lookahead adequacy checking, which the warning says was disabled, we would for example have been warned about mistakes like this one in ij.jj -> ijStatement(), where FirstStatement appears twice in the grammar:

Knut Anders Hatlen
added a comment - 31/Oct/10 11:33 If we do as the warning says, and set FORCE_LA_CHECK to true, we get even more warnings, since it then warns us about everything that would have been a problem if LOOKAHEAD had been 1 (it is 2). But I think it should be fairly straightforward to massage the grammar into a shape in which it's safe to lower the lookahead to 1.
Getting rid of the warning isn't just about reducing noise in the build. If we'd had lookahead adequacy checking, which the warning says was disabled, we would for example have been warned about mistakes like this one in ij.jj -> ijStatement(), where FirstStatement appears twice in the grammar:
r=ExecuteStatement()
r=FirstStatement()
r=FirstStatement()
r=JBMSPreparedStatementExec()