Main Documentation for XmlGenEx.grm

# Main Documentation for grammar XmlGenEx.grm

#### Description

This is a small grammar that we use as an example to illustrate JACC's XML serialization annotation mechanism. See also the annotated JACC grammar's hilited source code (i.e., an HTML-beautified rendering of the JACC source files where this comment came from. The file `test.exp` contains a set of expressions that can be parsed and serialized. The resulting XML serialization of the example expression in that file can be seen in the file `test.trace`. The "pure" XML serialization of the expressions in that file can be seen in the file `test.xml`. This declares the Java package for the parser generated from this grammar to be `hlt.xml`. Include the ancillary java code contained in file ParserCode.grm for setting the generated parser's parameters and showing XML serialization. This file contains ancillary code used by the Jacc grammar in `XmlGenEx.grm`, which illustrates how to use Jacc for XML generation from the syntax of a language - in this case, a language of simple expressions. Declare the grammar start symbol to be ``EXP``. This declares this application XML's namespace to be `http://www.hassan-ait-kaci.net/hex`. This is just a fake URI, of course, for the sake of this example ("`hex`" stands for "`hlt example xml`"). Define the XML tree root element to be a `hex:expressions`. Declare non-punctuation terminals ``NUMBER``, ``IDENT``, and ``VAR``. NB: ``VAR`` is an identifier starting with a `'?'` (i.e., the `'?'` is part of it, not a separate token). Declare operators from lowest to highest precedence. Annotate terminal symbol ``VAR`` for XML serialization. Annotate terminal symbol ``IDENT`` for XML serialization. Annotate terminal symbol ``STRING`` for XML serialization. Annotate terminal symbol ``NUMBER`` for XML serialization. Annotate terminal symbol ``PLUS`` for XML serialization. Annotate terminal symbol ``TIMES`` for XML serialization. Annotate terminal symbol ``SMALLER`` for XML serialization. Annotate terminal symbol ``GREATER`` for XML serialization. Annotate terminal symbol ``EQUAL`` for XML serialization. Annotate terminal symbol ``AND`` for XML serialization. Annotate terminal symbol ``OR`` for XML serialization. Author: Hassan Aït-Kaci, Hassan Aït-Kaci Copyright: © by the author, © by the author Version: Last modified on Tue Jan 29 07:24:09 2013 by hak, Last modified on Fri Oct 19 23:10:42 2012 by hak

Copyright © 2013 by Hassan Aït-Kaci; All Rights Reserved.