My company is trying to write some kind of Android software. We would like to work with Java, and there is a company software component that is C ++, and therefore it needs to be ported (or at least you need to transfer the requirements before trying the NDK stuff). This code was created using Accent , and it defines grammar grammar. As far as I can tell, the original author (now gone) wrote a grammar to indicate how to specify the grammar, and then compiled the compiler-compiler with that grammar and Accent. The compiler-compiler takes a grammar of the specified format and creates binary code to parse the strings corresponding to this grammar. Here is an example of a piece of grammar:
//include rules from from this file (such as <alpha>) include "alphabet.bnf" <<topSymbol>> = <alpha> <alpha> <alpha>? .//two letters with an optional third //square brackets enclose an XML statement clarifying semantics of the rule [ <topSymbol> <letter> <command val="doSomethingToLetter"/> </letter> <!--etc.--> </topSymbol> ]
My question is how to do this using Java using Antlr or some other tool. The compiler-compiler compiler seems pretty complicated to me. Alternatively, I would like to know how easy it is to compile / parse this type of grammar, which contains grammatical and semantic XML information.
source share