Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Compiler Tools JavaCC > Reserved keywor...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 2 Topic 480 of 549
Post > Topic >>

Reserved keywords: diagnostic

by Cesare Zecca <Cesare.Zecca.prof@[EMAIL PROTECTED] > Sep 26, 2007 at 03:17 PM

Hi all

I've found a number of discussions (almost all discussions) about non
reserved keywords (aka "soft" keywords)
http://groups.google.com/group/comp.compilers.tools.javacc/search?group=comp.compilers.tools.javacc&q=keywords&qt_g=Ricerca+in+questo+gruppo

I glanced to some JavaCC grammars in the the repository, as well, to
understand how to handle regular (reserved) keywords.
In the Gpl.jj file there is now the following token definition

TOKEN : // reserved words
{ < FALSE: "false" >
| < IF: "if" >
| < TRUE: "true" >
}

A short run on comman line of the grammar with the "a + if" input lead
to the following output and diagnostic

Call:   ExpressionList
Type in an expression followed by a ";" or ^D to quit:

a + if;
  Call:   Expression
    Call:   Term
      Call:   Factor
        Call:   Primary
          Consumed token: <<GROUP_ID>: "a" at line 1 column 1>
        Return: Primary
      Return: Factor
    Return: Term
    Consumed token: <"+" at line 1 column 3>
    Call:   Term
      Call:   Factor
      Return: Factor
    Return: Term
  Return: Expression
Return: ExpressionList
Exception in thread "main"
it.finmatica.gpj.ec.istruzioni.gpl.ParseException: Encountered "if" at
line 1, column 5.
Was expecting one of:
    <PAR_OPEN> ...
    <NUMBER_LITERAL> ...
    "-" ...
    <GROUP_ID> ...

        at
it.finmatica.gpj.ec.istruzioni.gpl.Gpl.generateParseException(Gpl.jav
a:471)
        at
it.finmatica.gpj.ec.istruzioni.gpl.Gpl.jj_consume_token(Gpl.java:406)
....

The "if" string literal now is correctly recognized as <IF> token that
is NOT  accepted by the the given definition of the Primary() /
Factor() productions.
Anyway, the diagnostic does not mention at all that... "if" is a
reserved keyword.
I have no idea if the diagnostic will be better (more clear) when the
definition of the IfStatement() production will be ready.

Any suggestion?

ciao
Cesare
 




 2 Posts in Topic:
Reserved keywords: diagnostic
Cesare Zecca <Cesare.Z  2007-09-26 15:17:30 
Identifying unparsed keyword token kinds in ParseException (was:
AC <user@[EMAIL PROTEC  2007-09-27 07:21:20 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Jul 25 2:46:28 CDT 2008.