[antlr-interest] same grammar? advanced tree manipulation?
Loring.G.Craymer at jpl.nasa.gov
Wed Jun 22 02:07:15 PDT 2005
Since everything in mpiJava is static (eww, gross---FORTRAN disguised as
Java), all of the MPI references will be through fully qualified
names-MPI.Init, etc. So you want to build a HashMap in which the keys are
the fully qualified method names-"MPI.Init", "Comm.Rank", and so forth.
Object values contain whatever information you find that you need to process
the specific MPI function identified by the key value.
It would probably also help to have a HashSet of the MPI class names-you can
check for membership in the HashSet as a first step in seeing if you have
found one of the MPI functions/constants.
[The easy way to generate the code for constructing the table is to write a
little translator to convert a text specification of the classes and their
methods/fields into code that builds the HashSet and HashMap that you
need-or you can extract the information from the .java mpiJava files with a
simple one-pass translator built from the Java parser/lexer grammar. You
should be able to do this in a day or so-this is probably a good first step
in understanding the java grammars, anyway.]
Once you have this bit of infrastructure, you annotate a tree grammar to
recognize fully qualified names in method calls (and access of constants,
but I don't think that you need that). Semantic predicates then can be used
to distinguish whether you want to replace a method call or can output it
I hope that this helps. As to your question as to whether this is a good
problem for ANTLR: this sort of translation is fairly easy to do with
ANTLR. The issue is really one of whether you have a sufficient volume of
MPI calls to process or not.
From: Eric Nelson [mailto:jeric10 at hotmail.com]
Sent: Tuesday, June 21, 2005 9:12 PM
To: Loring.G.Craymer at jpl.nasa.gov; antlr-interest at antlr.org
Subject: Re: [antlr-interest] same grammar? advanced tree manipulation?
So I do have to ask though, how would I follow your suggestion of building
the symbol table, etc? Thanks again,
>From: Loring Craymer <Loring.G.Craymer at jpl.nasa.gov>
>To: Eric Nelson <jeric10 at hotmail.com>, antlr-interest at antlr.org
>Subject: Re: [antlr-interest] same grammar? advanced tree manipulation?
>Date: Mon, 20 Jun 2005 15:14:00 -0700
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the antlr-interest