Compiler Construction with ANTLR and Java

By Gary L. Schaps

Dr. Dobb's Journal March 1999

//  This is the start rule for the parser.
compilationUnit
    :   // A pattern file consists of language elements,
        //  possibly intermixed with import directives
        (( importDirective ) | ( languageElement ))*
        EOF
;

Example 1: An ANTLR start rule.

Back to Article


Copyright © 1999, Dr. Dobb's Journal