On 8/3/10 10:22 AM, Lukas Renggli wrote:
Hi Bijan,
Please ask further questions in the Moose mailing-list, other people
might be interested too.
Thanks for sharing it:
I would be definitively happy to read
any discussion related to PetitParser! :)
Btw, it seems that the Java grammar (i.e. PetitJava) is coming.
Just to share my experience, I first tried to implement it
following the Java Language Specification book, Chapter 18.
Even though such chapter should sum up the whole syntax, it is not
completely consistent with the rest of the book (which details
all the rules with explanations and examples), and presents some
errors. Thus, after a brief trial, I moved to implement
the grammar according to the more detailed version.
Alas, such chapters are not perfect, too!
I found out a "corrected" version in a web site [1].
When finally I managed to implement it, it turned out that such
specifications contain various cycles. I tried to fix them, but
that would have required much time.
So, I decided to take the ANTLR version of the java grammar
(which has been tested successfully over a comprehensive regression
test suite) that would contain no dangerous cycles (since it is LL(1))
for PetitParser [2].
Now that grammar is implemented, and it correctly parses the
compilation units I tried. It still needs work (first of all, more
tests. Then, a parser), but it's coming.
From this experience, I would say that the first translator from
grammar-in-another-specification to PetitParser, should be from
ANTLR grammars. The fact that they are LL(1) should avoid cycles
(please correct me, if I am wrong), and there is a very big number
of grammars written for ANTLR.
Ciao,
Alberto
[1]
http://www.cmis.brighton.ac.uk/staff/rnb/bosware/javaSyntax/Java1_6GrammarC…
[2]
http://openjdk.java.net/projects/compiler-grammar/antlrworks/Java.g