List Info

Thread: RE: newbie question regarding lookahead and conflicts (RESENT, this time including the miss




RE: newbie question regarding lookahead and conflicts (RESENT, this time including the miss
user name
2007-08-07 05:52:02
Hi,

Jerry, that is fine. What I read in the spect that if the
SQL
implementation supports a SQL BOOLEAN, then it must
implement  IS [NOT]
TRUE to be conformant. This goes back to SQL92 as well. I
appreciate
your response though.

The real question here is about how to deal with ambiguity
in this
situation:

a->b->c->d(1)
   |
   +->d(0)

Where d(1) is the IS NOT NULL path, and d(0) is the IS NOT
TRUE path.

I've already descended into (c) to parse the ID (a column
reference),
but the 'IS' tokens get consumed in the rules of d(1), and I
cannot seem
to get the LOOKAHEAD to work in this one case, to stop
eating the IS
token in that situation. I'd like to have it return to (b)
and eat the
IS there instead. No amount of LOOKAHEAD helps in this
situation it
would appear. Being a newbie, I was wondering why.

If someone has some insight, I'd appreciate it. I can supply
the full
grammar and a test case if someone can help me out briefly.

-Bob

PS: I had hoped to use a SQL grammar off the web, but every
one I have
tried actually is implemented incorrectly with regards to
the spec.

> -----Original Message-----
> From: Jerry Schwarz [mailto:jerryschwarzgmail.com] On Behalf 
> Of Jerry Schwarz
> Sent: Tuesday, August 07, 2007 2:17 AM
> To: Buck, Robert
> Subject: Re: [JavaCC] newbie question regarding
lookahead and 
> conflicts (RESENT, this time including the missing
grammar)
> 
> 
> I confess I'm not familiar with SQL 2003.  In Oracle
SQL 
> (which is based on SQL 92 and which I'm very familiar
with) a 
> columnn reference cannot be a boolean. If this was
intended 
> as a question about a SQL
> 2003 grammar then I apologize for jumping in.
> 
> 
> On Aug 6, 2007, at 5:00 AM, Buck, Robert wrote:
> 
> > Then what might the meaning of Section 6.34 of the
2003 SQL 
> Standard 
> > mean by chance?
> >
> > Here is an excerpt:
> >
> > <boolean value expression> ::=
> > <boolean term>
> > | <boolean value expression> OR <boolean
term>
> > <boolean term> ::=
> > <boolean factor>
> > | <boolean term> AND <boolean factor>
> > <boolean factor> ::= [ NOT ] <boolean
test> <boolean test> ::= 
> > <boolean primary> [ IS [ NOT ] <truth
value> <truth value> ::= TRUE
> > | FALSE
> > | UNKNOWN
> > <boolean primary> ::=
> > <predicate>
> > | <boolean predicand>
> > <boolean predicand> ::=
> > <parenthesized boolean value expression>
> > | <nonparenthesized value expression
primary>
> > <parenthesized boolean value expression> ::=
<left paren> <boolean 
> > value expression> <right paren>
> >
> >
> > <nonparenthesized value expression primary> 
can be a  <column
> > reference> according to the standard (Section
6.3).
> >
> > -Bob
> >
> >> -----Original Message-----
> >> From: Jerry Schwarz [mailto:jerryschwarzgmail.com] On Behalf Of 
> >> Jerry Schwarz
> >> Sent: Monday, August 06, 2007 3:10 AM
> >> To: usersjavacc.dev.java.net
> >> Subject: Re: [JavaCC] newbie question
regarding lookahead and 
> >> conflicts (RESENT, this time including the
missing grammar)
> >>
> >>
> >> No comment on the javacc, but the phrase
"id is not true"  
> is not a 
> >> correct SQL condition.  It's not clear what
you think the 
> meaning of 
> >> "IS" is (sorry about that. I
couldn't resist
> >>  but it
doesn't connect a (column) identifier and a condition.
> >>
> >>
> >> On Aug 5, 2007, at 7:55 PM, Buck, Robert
wrote:
> >>
> >>
> >> 	Hi,
> >> 	
> >> 	In SQL there are two rules that conflict.
Given an input to the 
> >> SQLBooleanTest of "ID IS NOT TRUE".
I get the following error:
> >> 	
> >> 	Call:   SQLSearchCondition
> >> 	  Call:   SQLBooleanTerm
> >> 	    Call:   SQLBooleanFactor
> >> 	      Call:   SQLBooleanTest
> >> 	        Call:   SQLBooleanPrimary
> >> 	          Call:   SQLPredicate
> >> 	            Call:   SQLRowValueConstructor
> >> 	              Call:   SQLValueExpr
> >> 	                Call:   SQLNumericValueExpr
> >> 	                  Call:   SQLTerm
> >> 	                    Call:   SQLFactor
> >> 	                      Call:  
SQLValueExprPrimary
> >> 	                        Call:   SQLColumnRef
> >> 	                          Consumed token:
<<ID>: "ID"
> >> at line 1 column 1>
> >> 	 ID                         Return:
SQLColumnRef
> >> 	                      Return:
SQLValueExprPrimary
> >> 	                    Return: SQLFactor
> >> 	                  Return: SQLTerm
> >> 	                Return: SQLNumericValueExpr
> >> 	              Return: SQLValueExpr
> >> 	            Return: SQLRowValueConstructor
> >> 	            Call:   SQLNullPredicate
> >> 	              Consumed token:
<"is": "IS" at line 1 column 4>
> >> 	            Return: SQLNullPredicate
> >> 	          Return: SQLPredicate
> >> 	        Return: SQLBooleanPrimary
> >> 	      Return: SQLBooleanTest
> >> 	    Return: SQLBooleanFactor
> >> 	  Return: SQLBooleanTerm
> >> 	Return: SQLSearchCondition
> >> 	InvalidQueryException: ParseException: Parse
error at 
> line 1, column 
> >> 7.  Encountered: TRUE
> >> 	
> >> 	The following grammar is confusing ID IS NOT
NULL with 
> ID IS NOT 
> >> TRUE.
> >> 	
> >> 	I have tried using LOOKAHEAD(HUGENUMBER),
which does 
> not help (which 
> >> if it did would only mask the issue). Is there
a better 
> way to write 
> >> this segment of the grammar so that I have
LL(1) and that it works 
> >> for the input case cited?
> >> 	
> >> 	Thanks in advance,
> >> 	
> >> 	-Bob
> >> 	
> >> 	###################################
> >> 	
> >> 	void SQLBooleanTest() :
> >> 	{
> >> 	}
> >> 	{
> >> 	    SQLBooleanPrimary()
> >> 	    (
> >> 	        <IS>
> >> 	        (
> >> 	            <NOT> SQLTruthValue()
> >> 	            {
> >> 	            }
> >> 	            |
> >> 	            SQLTruthValue()
> >> 	            {
> >> 	            }
> >> 	        )
> >> 	    )?
> >> 	    {
> >> 	    }
> >> 	}
> >> 	
> >> 	void SQLBooleanPrimary() :
> >> 	{
> >> 	}
> >> 	{
> >> 	    (
> >> 	        <LPAREN> SQLSearchCondition()
<RPAREN>
> >> 	        {
> >> 	        }
> >> 	        |
> >> 	        SQLPredicate()
> >> 	        {
> >> 	        }
> >> 	    )
> >> 	    {
> >> 	    }
> >> 	}
> >> 	
> >> 	String SQLTruthValue() :
> >> 	{
> >> 	    Token t;
> >> 	    String u;
> >> 	}
> >> 	{
> >> 	    (
> >> 	        t = <TRUE>
> >> 	        {
> >> 	            u = t.image;
> >> 	        }
> >> 	        |
> >> 	        t = <FALSE>
> >> 	        {
> >> 	            u = t.image;
> >> 	        }
> >> 	        |
> >> 	        t = <UNKNOWN>
> >> 	        {
> >> 	            u = t.image;
> >> 	        }
> >> 	    )
> >> 	    {
> >> 	        return u;
> >> 	    }
> >> 	}
> >> 	
> >> 	void SQLPredicate() :
> >> 	{
> >> 	}
> >> 	{
> >> 	
> >> 	    SQLRowValueConstructor()
> >> 	    (
> >> 	        SQLNullPredicate()
> >> 	        {
> >> 	            /* this one is problematic for IS
NOT TRUE; 
> we end up 
> >> here and throw */
> >> 	        }
> >> 	        /* other rules in here, and ignored
for brevity */
> >> 	    )
> >> 	    {
> >> 	    }
> >> 	}
> >> 	void SQLNullPredicate() :
> >> 	{
> >> 	}
> >> 	{
> >> 	    (
> >> 	        <IS>
> >> 	        (
> >> 	            <NOT> <NULL>
> >> 	            {
> >> 	                System.out.print("IS NOT
NULL");
> >> 	            }
> >> 	            |
> >> 	            <NULL>
> >> 	            {
> >> 	                System.out.print("IS
NULL");
> >> 	            }
> >> 	        )
> >> 	    )
> >> 	    {
> >> 	    }
> >> 	}
> >>
> >>
> >>
> >
> > 
>
------------------------------------------------------------
---------
> > To unsubscribe, e-mail: users-unsubscribejavacc.dev.java.net
> > For additional commands, e-mail: users-helpjavacc.dev.java.net
> >
> 
> 

------------------------------------------------------------
---------
To unsubscribe, e-mail: users-unsubscribejavacc.dev.java.net
For additional commands, e-mail: users-helpjavacc.dev.java.net


Re: newbie question regarding lookahead and conflicts (RESENT, this time including the miss
user name
2007-08-07 08:40:13
Have you tried using semantic lookahead?

On 07/08/07, Buck, Robert <rbuckverisign.com> wrote:
> Hi,
>
> Jerry, that is fine. What I read in the spect that if
the SQL
> implementation supports a SQL BOOLEAN, then it must
implement  IS [NOT]
> TRUE to be conformant. This goes back to SQL92 as well.
I appreciate
> your response though.
>
> The real question here is about how to deal with
ambiguity in this
> situation:
>
> a->b->c->d(1)
>    |
>    +->d(0)
>
> Where d(1) is the IS NOT NULL path, and d(0) is the IS
NOT TRUE path.
>
> I've already descended into (c) to parse the ID (a
column reference),
> but the 'IS' tokens get consumed in the rules of d(1),
and I cannot seem
> to get the LOOKAHEAD to work in this one case, to stop
eating the IS
> token in that situation. I'd like to have it return to
(b) and eat the
> IS there instead. No amount of LOOKAHEAD helps in this
situation it
> would appear. Being a newbie, I was wondering why.
>
> If someone has some insight, I'd appreciate it. I can
supply the full
> grammar and a test case if someone can help me out
briefly.
>
> -Bob
>
> PS: I had hoped to use a SQL grammar off the web, but
every one I have
> tried actually is implemented incorrectly with regards
to the spec.
>
> > -----Original Message-----
> > From: Jerry Schwarz [mailto:jerryschwarzgmail.com] On Behalf
> > Of Jerry Schwarz
> > Sent: Tuesday, August 07, 2007 2:17 AM
> > To: Buck, Robert
> > Subject: Re: [JavaCC] newbie question regarding
lookahead and
> > conflicts (RESENT, this time including the missing
grammar)
> >
> >
> > I confess I'm not familiar with SQL 2003.  In
Oracle SQL
> > (which is based on SQL 92 and which I'm very
familiar with) a
> > columnn reference cannot be a boolean. If this was
intended
> > as a question about a SQL
> > 2003 grammar then I apologize for jumping in.
> >
> >
> > On Aug 6, 2007, at 5:00 AM, Buck, Robert wrote:
> >
> > > Then what might the meaning of Section 6.34
of the 2003 SQL
> > Standard
> > > mean by chance?
> > >
> > > Here is an excerpt:
> > >
> > > <boolean value expression> ::=
> > > <boolean term>
> > > | <boolean value expression> OR
<boolean term>
> > > <boolean term> ::=
> > > <boolean factor>
> > > | <boolean term> AND <boolean
factor>
> > > <boolean factor> ::= [ NOT ]
<boolean test> <boolean test> ::=
> > > <boolean primary> [ IS [ NOT ]
<truth value> <truth value> ::= TRUE
> > > | FALSE
> > > | UNKNOWN
> > > <boolean primary> ::=
> > > <predicate>
> > > | <boolean predicand>
> > > <boolean predicand> ::=
> > > <parenthesized boolean value
expression>
> > > | <nonparenthesized value expression
primary>
> > > <parenthesized boolean value
expression> ::= <left paren> <boolean
> > > value expression> <right paren>
> > >
> > >
> > > <nonparenthesized value expression
primary>  can be a  <column
> > > reference> according to the standard
(Section 6.3).
> > >
> > > -Bob
> > >
> > >> -----Original Message-----
> > >> From: Jerry Schwarz
[mailto:jerryschwarzgmail.com] On Behalf Of
> > >> Jerry Schwarz
> > >> Sent: Monday, August 06, 2007 3:10 AM
> > >> To: usersjavacc.dev.java.net
> > >> Subject: Re: [JavaCC] newbie question
regarding lookahead and
> > >> conflicts (RESENT, this time including
the missing grammar)
> > >>
> > >>
> > >> No comment on the javacc, but the phrase
"id is not true"
> > is not a
> > >> correct SQL condition.  It's not clear
what you think the
> > meaning of
> > >> "IS" is (sorry about that. I
couldn't resist
> > >>  but it
doesn't connect a (column) identifier and a condition.
> > >>
> > >>
> > >> On Aug 5, 2007, at 7:55 PM, Buck, Robert
wrote:
> > >>
> > >>
> > >>    Hi,
> > >>
> > >>    In SQL there are two rules that
conflict. Given an input to the
> > >> SQLBooleanTest of "ID IS NOT
TRUE". I get the following error:
> > >>
> > >>    Call:   SQLSearchCondition
> > >>      Call:   SQLBooleanTerm
> > >>        Call:   SQLBooleanFactor
> > >>          Call:   SQLBooleanTest
> > >>            Call:   SQLBooleanPrimary
> > >>              Call:   SQLPredicate
> > >>                Call:  
SQLRowValueConstructor
> > >>                  Call:   SQLValueExpr
> > >>                    Call:  
SQLNumericValueExpr
> > >>                      Call:   SQLTerm
> > >>                        Call:   SQLFactor
> > >>                          Call:  
SQLValueExprPrimary
> > >>                            Call:  
SQLColumnRef
> > >>                              Consumed
token: <<ID>: "ID"
> > >> at line 1 column 1>
> > >>     ID                         Return:
SQLColumnRef
> > >>                          Return:
SQLValueExprPrimary
> > >>                        Return: SQLFactor
> > >>                      Return: SQLTerm
> > >>                    Return:
SQLNumericValueExpr
> > >>                  Return: SQLValueExpr
> > >>                Return:
SQLRowValueConstructor
> > >>                Call:   SQLNullPredicate
> > >>                  Consumed token:
<"is": "IS" at line 1 column 4>
> > >>                Return: SQLNullPredicate
> > >>              Return: SQLPredicate
> > >>            Return: SQLBooleanPrimary
> > >>          Return: SQLBooleanTest
> > >>        Return: SQLBooleanFactor
> > >>      Return: SQLBooleanTerm
> > >>    Return: SQLSearchCondition
> > >>    InvalidQueryException: ParseException:
Parse error at
> > line 1, column
> > >> 7.  Encountered: TRUE
> > >>
> > >>    The following grammar is confusing ID
IS NOT NULL with
> > ID IS NOT
> > >> TRUE.
> > >>
> > >>    I have tried using
LOOKAHEAD(HUGENUMBER), which does
> > not help (which
> > >> if it did would only mask the issue). Is
there a better
> > way to write
> > >> this segment of the grammar so that I
have LL(1) and that it works
> > >> for the input case cited?
> > >>
> > >>    Thanks in advance,
> > >>
> > >>    -Bob
> > >>
> > >>    ###################################
> > >>
> > >>    void SQLBooleanTest() :
> > >>    {
> > >>    }
> > >>    {
> > >>        SQLBooleanPrimary()
> > >>        (
> > >>            <IS>
> > >>            (
> > >>                <NOT>
SQLTruthValue()
> > >>                {
> > >>                }
> > >>                |
> > >>                SQLTruthValue()
> > >>                {
> > >>                }
> > >>            )
> > >>        )?
> > >>        {
> > >>        }
> > >>    }
> > >>
> > >>    void SQLBooleanPrimary() :
> > >>    {
> > >>    }
> > >>    {
> > >>        (
> > >>            <LPAREN>
SQLSearchCondition() <RPAREN>
> > >>            {
> > >>            }
> > >>            |
> > >>            SQLPredicate()
> > >>            {
> > >>            }
> > >>        )
> > >>        {
> > >>        }
> > >>    }
> > >>
> > >>    String SQLTruthValue() :
> > >>    {
> > >>        Token t;
> > >>        String u;
> > >>    }
> > >>    {
> > >>        (
> > >>            t = <TRUE>
> > >>            {
> > >>                u = t.image;
> > >>            }
> > >>            |
> > >>            t = <FALSE>
> > >>            {
> > >>                u = t.image;
> > >>            }
> > >>            |
> > >>            t = <UNKNOWN>
> > >>            {
> > >>                u = t.image;
> > >>            }
> > >>        )
> > >>        {
> > >>            return u;
> > >>        }
> > >>    }
> > >>
> > >>    void SQLPredicate() :
> > >>    {
> > >>    }
> > >>    {
> > >>
> > >>        SQLRowValueConstructor()
> > >>        (
> > >>            SQLNullPredicate()
> > >>            {
> > >>                /* this one is problematic
for IS NOT TRUE;
> > we end up
> > >> here and throw */
> > >>            }
> > >>            /* other rules in here, and
ignored for brevity */
> > >>        )
> > >>        {
> > >>        }
> > >>    }
> > >>    void SQLNullPredicate() :
> > >>    {
> > >>    }
> > >>    {
> > >>        (
> > >>            <IS>
> > >>            (
> > >>                <NOT> <NULL>
> > >>                {
> > >>                   
System.out.print("IS NOT NULL");
> > >>                }
> > >>                |
> > >>                <NULL>
> > >>                {
> > >>                   
System.out.print("IS NULL");
> > >>                }
> > >>            )
> > >>        )
> > >>        {
> > >>        }
> > >>    }
> > >>
> > >>
> > >>
> > >
> > >
> >
------------------------------------------------------------
---------
> > > To unsubscribe, e-mail: users-unsubscribejavacc.dev.java.net
> > > For additional commands, e-mail:
users-helpjavacc.dev.java.net
> > >
> >
> >
>
>
------------------------------------------------------------
---------
> To unsubscribe, e-mail: users-unsubscribejavacc.dev.java.net
> For additional commands, e-mail: users-helpjavacc.dev.java.net
>
>


-- 
 - J.Chris Findlay
   (c:

------------------------------------------------------------
---------
To unsubscribe, e-mail: users-unsubscribejavacc.dev.java.net
For additional commands, e-mail: users-helpjavacc.dev.java.net


[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )