Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: Re: [jdt-core-dev] Re: Was the Parser class generated?

It is the entire grammar to feed JikesPG (steps for generating should be
available on JikesPG Web site), you need to copy/paste it into a separate
file, then perform some copy/paste operations back to update the resulting
parser.

It contains annotations for inserting callbacks to Java parser in order to
build AST nodes upon reduction, or necessary updates.

Steps we follow to update the parser after having changed the grammar, and
run JikesPG.

Once the grammar has been modified and the data generated using the JikesPG
tool, here are the actions to perform in order to get the new resulting
parser :

1/=======
If the grammar hasn't been modified, except some semantic actions, the only
file content to copy is the one of JavaAction.java.
It contains the consumeRule(...) method definition that handles all
semantic actions dispatches.

2/=======
Otherwise the process is more heavy (but does not often occur since the
grammar is pretty stable now).

Execute in a scrapbook :

org.eclipse.jdtcore.internal.compiler.parser.Parser.buildFilesFromLPG
("DirectoryWhereToFindTheNextFile\\javadcl.java")

It generates the 5 ressources files the parser needs ("parser*.rsc").
You need to copy them in place of the current ones.

Copy the content of the file JavaAction.java.
It contains the method consumeRule(...) that handles all semantic actions
dispatches. This method is a method of the class Parser.

The definition of the Parser needs to be updated with two tables from
javadcl.java. Those are rhs[] and name[].
The entry $eof in name[] must be changed to UNEXPECTED_EOF and the $error
needs to be changed to "Invalid Character".
(The previous defintion of name[] will guide you)

The TerminalSymbols class needs to be updated with the contents of the file
javasym.java. The two last entries must be changed :
(the $ is not a valid identifier char in java)
//TokenName$eof = 184,
//TokenName$error = 276;
TokenNameERROR = 276,
TokenNameEOF = 184;

The class ParserBasicInformation needs to be updated with the content of
the file javadef.java



                                                                                                                                                  
                      "Scott Stanchfield"                                                                                                         
                      <scott@xxxxxxxxxxxx         To:      <jdt-core-dev@xxxxxxxxxxx>                                                             
                      >                           cc:                                                                                             
                      Sent by:                    Subject: RE: Re: [jdt-core-dev] Re: Was the Parser class generated?                             
                      jdt-core-dev-admin@                                                                                                         
                      eclipse.org                                                                                                                 
                                                                                                                                                  
                                                                                                                                                  
                      02/26/2002 04:04 PM                                                                                                         
                      Please respond to                                                                                                           
                      jdt-core-dev                                                                                                                
                                                                                                                                                  
                                                                                                                                                  



The Parser source actually has the grammar embedded in a comment in its
grammar() method. Don't know if this is the full grammar including actions,
or a stripped version after jikespg processing, though. Haven't looked at
it enough.

I still like ANTLR for parsing ;)
-- Scott


==============================================================
Scott Stanchfield         FGM, Inc.            scott@xxxxxxx

Home Page: http://javadude.com            scott@xxxxxxxxxxxx

Lead author of "Effective VisualAge for Java, Version 3"
                                      http://javadude.com/evaj

VisualAge for Java Tips and Tricks     http://javadude.com/vaj

AWT & Swing FAQ Manager, jGuru.com
Visit for Java Enlightenment!             http://www.jguru.com
==============================================================


 -----Original Message-----
 From: jdt-core-dev-admin@xxxxxxxxxxx
 [mailto:jdt-core-dev-admin@xxxxxxxxxxx]On Behalf Of Carlos Perez
 Sent: Tuesday, February 26, 2002 9:45 AM
 To: jdt-core-dev@xxxxxxxxxxx
 Subject: Re: Re: [jdt-core-dev] Re: Was the Parser class generated?



 Philippe,


 Well I was looking for something like the .jj file for JavaCC where the
 grammar was intermingled w/ code fragments.


 I'm not familiar w/ JikesPG (where's the documentation anyway?) but I
 assumed that it its similar to JavaCC (i.e. grammar intermingled w/ code
 fragments).  If I needed to add new productions in the grammar do I have
 to hack the java code or can I start from somewhere more convenient?


 I'm really looking for ways to modify the parser, can you give me pointers
 on how best to do this?


 Thanks,


 Carlos






 Do You Yahoo!?
 Yahoo! Sports - Coverage of the 2002 Olympic Games









Back to the top