Hi,
Yet another question on PetitParser :) All the grammars that I find in PetitParser (e.g., PetitXML, PetitSmalltalk) are defined in a single class called PP...Grammar. However, the Java grammar has many rules and including all of them in a single class seems not the right approach. For example, now I have a class called PPJavaLexicon, in which I cover the rules for finding tokens and comments (i.e. the lexical structure [1]). Then, for example, I would continue working on types, values, and variables [2]. So, I would create another class that references PPJavaLexicon and uses the rules defined there to define the new ones. Something like:
PPJavaTypes>>typeVariable ^ppJavaLexicon identifier
Is this a good approach to split a grammar in more classes, or would you suggest something different?
Thank you, Alberto
[1] http://java.sun.com/docs/books/jls/third_edition/html/lexical.html [2] http://java.sun.com/docs/books/jls/third_edition/html/typesValues.html