Parser
Class ParserGenerator
java.lang.Object
|
+--Parser.ParserGenerator
- public class ParserGenerator
- extends java.lang.Object
The ParserGenerator class is an application used to generate parsers based on
EBNF grammar files.
As of version 2.0, the ParserGenerator class also builds functions for
performing automatic code generation, much like with yacc. These functions
will be named like handleRULE, where RULE is the name of the rule to be
handled.
To begin calling these functions, after the code file has been read in, you
may use something such as this:
RETree syntaxTree = production[PROGRAM.intValue ()].beginningMatches (data);
if (syntaxTree != null) System.out.println (syntaxTree.generateCode (null, syntaxTree));
where PROGRAM is the name of the starting rule for your grammar.
Note: the error handling is still rather poor with this parser, so it should
should only be used to parse data that is known to be of good form, or to
check code for validity -- without reporting errors.
As of version 2.1, the Parser Generator class supports code sections within
the grammar files. Formatting for the grammar file looks like this:
Import Section Code
<%>
Global Variables Section Code
<%>
Rule Definitions
Method Summary |
static void |
main(java.lang.String[] args)
Generates a parser java file from a specified EBNF grammar file. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
PRODUCTIONS
public static int PRODUCTIONS
RULE
public static final java.lang.Integer RULE
WHITESPACE
public static final java.lang.Integer WHITESPACE
SYMBOL
public static final java.lang.Integer SYMBOL
RE
public static final java.lang.Integer RE
HEXCHARACTER
public static final java.lang.Integer HEXCHARACTER
CHARACTERLIST
public static final java.lang.Integer CHARACTERLIST
CHARACTERLIST1
public static final java.lang.Integer CHARACTERLIST1
CHARACTERLIST2
public static final java.lang.Integer CHARACTERLIST2
STANDARDRE
public static final java.lang.Integer STANDARDRE
STANDARDRE1
public static final java.lang.Integer STANDARDRE1
STANDARDRE2
public static final java.lang.Integer STANDARDRE2
ESCAPESEQUENCE
public static final java.lang.Integer ESCAPESEQUENCE
LBRACKET
public static final java.lang.Integer LBRACKET
RBRACKET
public static final java.lang.Integer RBRACKET
SINGLEQUOTE
public static final java.lang.Integer SINGLEQUOTE
EQ
public static final java.lang.Integer EQ
EXPRESSION
public static final java.lang.Integer EXPRESSION
GROUP
public static final java.lang.Integer GROUP
SEQUENCE
public static final java.lang.Integer SEQUENCE
SEQUENCELHS
public static final java.lang.Integer SEQUENCELHS
MODIFIER
public static final java.lang.Integer MODIFIER
LPAREN
public static final java.lang.Integer LPAREN
RPAREN
public static final java.lang.Integer RPAREN
MINUS
public static final java.lang.Integer MINUS
OR
public static final java.lang.Integer OR
EPSILON
public static final java.lang.Integer EPSILON
production
public static ProductionProcessor[] production
outputclass
public static java.lang.String outputclass
ParserGenerator
public ParserGenerator()
main
public static void main(java.lang.String[] args)
throws java.lang.Exception
- Generates a parser java file from a specified EBNF grammar file.
- Parameters:
args
- program parameters: input filename, output filename