/* Documentation for MAD to UAP Translator created with the help of Terrence Parr's ANTLR */ Files in [cvs]/accelerator-ml/UAP/MAD MAD_C.g This is the grammar file constructed for ANTLR. ANTLR uses this file to create the classes described within: MADConverter, MADParser, and MADLexer in C++ (the language is specified in the "options" section). It inserts the text of the "header" section into each header file. Each class is then generated based on the grammar rules described in this file. See the ANTLR documentation for more on these rules, at www.antlr.org. MADConverter.hpp and MADConverter.cpp This is the Tree-walker that converts the AST generated by the parser into the UAP tree "S1" ("structure 1"), which is the AML standard structure before expressions are evaluated. MADParser.hpp and MADParser.cpp This class constructs the Abstract Syntax Tree representing the inputted MAD file from a token stream generated by the lexer. MADLexer.hpp and MADTokenTypes.cpp This class tokenizes the input file, passing the resulting token stream to the parser. MADTokenTypes.hpp and MADTokenTypes.txt Simply an enumeration of each TokenType defined in MAD_C.g, for use by the Lexer. MADStreamSelector.hpp and MADStreamSelector.cpp This class implements a multiplexor of TokenStream objects. Except for the constructor, which takes a MADLexer, its methods have the same signature as the TokenStreamSelector class. So it is actually a MADStreamSelector that is passed to the MADParser constructor, rather than the MADLexer directly. This allows the MADStreamSelector to switch to another MADLexer with another input file when the CALL command is used in a MAD file. MADTranslator.hpp and MADTranslator.cpp Dual-purpose class, inheriting from DialectTranslator. Constructor creates Translation tables for elements and attributes to convert MAD names to UAP names. Other methods will write a UAP tree to a file in MAD format. There is one such method for each syntactical category (quadrupole, beamline, etc.). Beamline either writes up to the opening parenthesis of its element list or writes a closing parenthesis, depending on its integer argument. SymbolException.hpp An exception with a message specified in the constructor. main.cpp Takes a filename on the command line. Creates a lexer and parser for cin, and creates an AST from the given MAD file. Prints LISP-format of AST or an error message.