Parser
v2.1

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


Field Summary
static java.lang.Integer CHARACTERLIST
           
static java.lang.Integer CHARACTERLIST1
           
static java.lang.Integer CHARACTERLIST2
           
static java.lang.Integer EPSILON
           
static java.lang.Integer EQ
           
static java.lang.Integer ESCAPESEQUENCE
           
static java.lang.Integer EXPRESSION
           
static java.lang.Integer GROUP
           
static java.lang.Integer HEXCHARACTER
           
static java.lang.Integer LBRACKET
           
static java.lang.Integer LPAREN
           
static java.lang.Integer MINUS
           
static java.lang.Integer MODIFIER
           
static java.lang.Integer OR
           
static java.lang.String outputclass
           
static ProductionProcessor[] production
           
static int PRODUCTIONS
           
static java.lang.Integer RBRACKET
           
static java.lang.Integer RE
           
static java.lang.Integer RPAREN
           
static java.lang.Integer RULE
           
static java.lang.Integer SEQUENCE
           
static java.lang.Integer SEQUENCELHS
           
static java.lang.Integer SINGLEQUOTE
           
static java.lang.Integer STANDARDRE
           
static java.lang.Integer STANDARDRE1
           
static java.lang.Integer STANDARDRE2
           
static java.lang.Integer SYMBOL
           
static java.lang.Integer WHITESPACE
           
 
Constructor Summary
ParserGenerator()
           
 
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
 

Field Detail

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
Constructor Detail

ParserGenerator

public ParserGenerator()
Method Detail

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

Parser
v2.1