|
Generic Interpreter 1.3 Protected API |
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectgi.Lexicon
gi.Grammar
public class Grammar
This class implements a Grammar.
| Nested Class Summary | |
|---|---|
protected static class |
Grammar.ParseTree
This class implements a constructed by interpreting a source stream. |
protected static class |
Grammar.Semantics
This class implements embedded in productions and evaluated when interpreting. |
| Nested classes/interfaces inherited from class gi.Lexicon |
|---|
Lexicon.Alphabet, Lexicon.Concatenation, Lexicon.Exception, Lexicon.Expression, Lexicon.Match, Lexicon.NonMatch, Lexicon.PosixClass, Lexicon.Range, Lexicon.Repetition, Lexicon.Singleton, Lexicon.UnicodeCategory, Lexicon.Union |
| Field Summary | |
|---|---|
protected static int |
CONFLICT
switch constant enables printing parsing conflicts encountered during syntax analysis. |
protected static int |
FIRST_FOLLOW
switch constant enables printing first and follow sets precomputed during syntax analysis. |
protected static int |
PARSE_TREE
switch constant enables printing each ParseTree produced by syntax analysis. |
protected static int |
SYNTAX
switch constant enables printing parsing decisions made during syntax analysis. |
| Fields inherited from class gi.Lexicon |
|---|
$, debug, LEXICAL, TERMINALS, VERBOSE |
| Constructor Summary | |
|---|---|
protected |
Grammar()
Constructs an empty Grammar. |
| Method Summary | |
|---|---|
protected Object |
grab(LineNumberReader source)
Grabs a terminal from a source character stream using this Grammar. |
void |
interpret(String[] arguments)
Interprets by command-line arguments using this Grammar. |
protected void |
put(Object nonterminal,
Object[] phrase)
Puts a production into this Grammar. |
protected void |
put(Object nonterminal,
Object[][] phrases)
Puts productions into this Grammar. |
| Methods inherited from class gi.Lexicon |
|---|
expression, interpret, interpret, interpret, interpret, interpret, interpret, put, word |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final int FIRST_FOLLOW
switch constant enables printing first and follow sets precomputed during syntax analysis.debug
protected static final int SYNTAX
switch constant enables printing parsing decisions made during syntax analysis.debug
protected static final int CONFLICT
switch constant enables printing parsing conflicts encountered during syntax analysis.debug
protected static final int PARSE_TREE
switch constant enables printing each debugParseTree produced by syntax analysis.
| Constructor Detail |
|---|
protected Grammar()
Constructs an empty Grammar.
| Method Detail |
|---|
protected void put(Object nonterminal,
Object[] phrase)
Puts a production into this Grammar. The start symbol is the first nonterminal put in this Grammar.
nonterminal - the nonterminal added to this Grammar.phrase - the phrase produced by nonterminal. phrase may contain nonterminals, terminals, and Semantics.
protected void put(Object nonterminal,
Object[][] phrases)
Puts productions into this Grammar. The productions are successively added using .put(nonterminal, phrase)
nonterminal - the nonterminal on the left side of the productions.phrases - the phrases produced by nonterminal. Each phrase in phrases may contain nonterminals, terminals, and Semantics.
protected Object grab(LineNumberReader source)
throws Lexicon.Exception
Grabs a terminal from a source character stream using this Grammar. Invokes until it returns a terminal occurring in a phrase of this Lexicon.grab(source)Grammar or end of source. Blocks until a character is available, an I/O error occurs, or the end of the source stream is reached.
grab in class Lexiconsource - the source character stream.
Grammar.
Lexicon.Exception - if an I/O or lexical error occurs.public void interpret(String[] arguments)
Interprets by command-line arguments using this Grammar. When interpreting, the parser used will be (in order):
The first I/O, lexical, syntax or semantic error that occurs when interpreting is printed to the standard error stream.
- The parser most recently constructed by preceding command-line arguments.
- The parser originally around this
Grammar.- An LR(1) parser.
interpret in class Lexiconarguments - the command-line arguments controlling the interpreter.
The following arguments may appear zero or more times, are processed in order, and have the following effects:If no
-t,--terminals- Print the set of terminals in this
Grammarbefore subsequent syntax analyses.-l,--lexical- Print terminals in this
Grammargrabbed during subsequent syntax analyses.-f,--firstfollow- Print first and follow sets precomputed during subsequent syntax analyses.
-s,--syntax- Print parsing decisions made during subsequent syntax analyses.
-c,--conflict- Print parsing conflicts encountered during subsequent syntax analyses.
-p,--parsetree,--tree- Print each
ParseTreeproduced by subsequent syntax analyses.-v,--verbose- Print maximum debugging. Equivalent to
-tlfscp.--ll1- Construct an
LL(1) parseraround thisGrammar.--lr0- Construct an
LR(0) parseraround thisGrammar.--slr1- Construct an
SLR(1) parseraround thisGrammar.--lr1- Construct an
LR(1) parseraround thisGrammar.-- Interpret the standard input stream using this
Grammar.filename- Interpret source file
filenameusing thisGrammar.filenamearguments are given, the standard input stream is interpreted.
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||