[antlr-interest] Fortran grammars
Olivier Dragon
dragonoe at mcmaster.ca
Thu Jul 14 07:47:09 PDT 2005
Hi,
So I tried my best to translate the PCCTS grammar to ANTLR. I basically
removed all the action code, sanitized the rulenames, changed the syntax
a little (the {} optional in particular), and wrote a lexer. I removed
all the action code mostly because I didn't know how to translate it to
ANTLR but also because it seemed to me like the grammar should still
work without it.
But now I'm stuck with a broken parsing grammar and no idea where to go
next. The lexer seems to work fine. At least it returns tokens the way I
think it is supposed to.
The parser however is having trouble. With k=2 (k=3 or more doesn't
change anything) I still get quite a few ambiguities. The rule that is
causing me the most problems right now is subprogramBody. I tried
debugging the Parser code (generated) and it looks like it gets stuck on
the first variable declaration (wholeStatement rule) for a few loops and
then exits with an error on the second one (see sample code). I also
tried to debug the grammar with antlreclipse but I couldn't figure out
how it worked :(
Another problematic one is the if-family of rules that are all
alternatives of executableStatement. This means at k=2 there's
ambiguities with "if" '(' expr ')'... It seems to me like this is a big
problem and I'm not sure how the PCCTS grammar managed to work with it.
Finally, I left all the ^ and ! AST directives because I didn't think
they cause trouble for parsing, and didn't want to put them back in if
they proved useful.
I would really appreciate some help with this grammar. I'm attaching the
original PCCTS grammar (f77-pccts), the translated ANTLR grammar
(f77-pccts-antlr.g), my main Java program (Main.java) and my sample
Fortran code file (sspsv.f) which is from LAPACK.
Thank you for your time!
-Olivier
On Mon, Jun 13, 2005 at 11:36:57AM -0700, Terence Parr wrote:
> Hi. I *know* I have f77.g around...but I think it's PCCTS. OH, here
> it is in share area. Heh, even the antlr.org search found it! I
> gotta fix that thing soon to be better...
>
> http://www.antlr.org/share/1077305245771/fort.g
>
> Ter
--
__-/| ? ? |\-__
__--/ / \ (^^) / \ \--__
_-/ / / /\ / ( ) /\ \ \ \-_
/ / / / / ( ^^ ~ \ \ \ \ \
/ Oli Dragon ( dragonoe at mcmaster.ca \
/ B.Eng. Sfwr ( ) \ \ \ \
/ / / /__--_ ( ) __--__\ \ \ \
| / / _/ \_ \_ \_ \ \ |
\/ / _/ \_ \_ \_ \ \/
\_/ / -\_\ \ \_/
\/ ) \/
*~
___--<***************>--___
[http://dragon.homelinux.org]
~~~--<***************>--~~~
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20050714/a5308c52/attachment.bin
More information about the antlr-interest
mailing list