|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object | +--net.percederberg.grammatica.Grammar
A grammar definition object. This object supports parsing a grammar file and create a lexical analyzer (tokenizer) for the grammar.
| Field Summary | |
static java.lang.String |
AUTHOR_DECLARATION
The author grammar declaration constant. |
static java.lang.String |
COPYRIGHT_DECLARATION
The copyright grammar declaration constant. |
static java.lang.String |
DATE_DECLARATION
The date grammar declaration constant. |
static java.lang.String |
DESCRIPTION_DECLARATION
The description grammar declaration constant. |
static java.lang.String |
GRAMMAR_TYPE_DECLARATION
The grammar type grammar declaration constant. |
static java.lang.String |
LICENSE_DECLARATION
The license grammar declaration constant. |
static java.lang.String |
VERSION_DECLARATION
The version grammar declaration constant. |
| Constructor Summary | |
Grammar(java.io.File file)
Creates a new grammar from the specified file. |
|
| Method Summary | |
Parser |
createParser(Tokenizer tokenizer)
Creates a parser from this grammar. |
Tokenizer |
createTokenizer(java.io.Reader in)
Creates a tokenizer from this grammar. |
java.lang.String |
getDeclaration(java.lang.String name)
Returns the declaration value for the specified name. |
java.lang.String |
getFileName()
Returns the grammar file name and path. |
ProductionPattern |
getProductionPattern(int pos)
Returns a specific production pattern. |
ProductionPattern |
getProductionPattern(java.lang.String name)
Returns a specific production pattern. |
int |
getProductionPatternCount()
Returns the number of production patterns in the grammar. |
TokenPattern |
getTokenPattern(int pos)
Returns a specific token pattern. |
TokenPattern |
getTokenPattern(java.lang.String name)
Returns a specific token pattern. |
int |
getTokenPatternCount()
Returns the number of token patterns in the grammar. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final java.lang.String AUTHOR_DECLARATION
public static final java.lang.String COPYRIGHT_DECLARATION
public static final java.lang.String DATE_DECLARATION
public static final java.lang.String DESCRIPTION_DECLARATION
public static final java.lang.String GRAMMAR_TYPE_DECLARATION
public static final java.lang.String LICENSE_DECLARATION
public static final java.lang.String VERSION_DECLARATION
| Constructor Detail |
public Grammar(java.io.File file)
throws java.io.FileNotFoundException,
ParseException,
GrammarException
file - the grammar file to read
java.io.FileNotFoundException - if the grammar file could not be
found
ParseException - if the grammar file couldn't be parsed
correctly
GrammarException - if the grammar wasn't valid| Method Detail |
public Tokenizer createTokenizer(java.io.Reader in)
throws GrammarException
in - the input stream to use
GrammarException - if the tokenizer couldn't be created
or initialized correctly
public Parser createParser(Tokenizer tokenizer)
throws GrammarException
tokenizer - the tokenizer to use
GrammarException - if the parser couldn't be created or
initialized correctlypublic java.lang.String getFileName()
public java.lang.String getDeclaration(java.lang.String name)
name - the declaration name
public int getTokenPatternCount()
public TokenPattern getTokenPattern(int pos)
pos - the pattern position, 0 <= pos < count
public TokenPattern getTokenPattern(java.lang.String name)
name - the pattern name
public int getProductionPatternCount()
public ProductionPattern getProductionPattern(int pos)
pos - the pattern position, 0 <= pos < count
public ProductionPattern getProductionPattern(java.lang.String name)
name - the pattern name
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||