|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object LL
Implements the LL(1)
top-down analysis.
Usage:
java LL "input" grammar
.
The normal execution shows the evolution of the stack ended by the
message "input accepted".
If the grammar is not LL(1)
, an error message
"The grammar is not LL(1)" is issued. The message also indicates
which rules generate the conflict. If the input is not correct, an
error message "Syntax error" or "Syntax error: end of input" is issued.
Field Summary | |
Alphabet |
alphabet
The input alphabet; |
char[] |
expression
The expression to analyze. |
Grammar |
G
The current context-free grammar. |
int |
position
The current index. |
java.util.Stack |
stack
The stack used to store the LR states. |
Constructor Summary | |
LL(java.lang.String exp,
Grammar grammar)
Creates the LLTable and initializes the stack. |
Method Summary | |
void |
advance()
Advance one character to the right on input. |
void |
cancel()
Cancels the current character with the top of stack. |
short |
current()
Returns the current token of the input. |
boolean |
endOfInput()
True if the input has been read completely. |
void |
lLParse()
Parses the input expression using the LL(1) analysis alpgorithm. |
int[][] |
LLTable()
The LL(1) table analysis. |
static void |
main(java.lang.String[] args)
|
void |
push(int n)
Pop the left side of production n and push the right side . |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public char[] expression
public int position
public java.util.Stack stack
public Grammar G
public Alphabet alphabet
Constructor Detail |
public LL(java.lang.String exp, Grammar grammar)
LLTable
and initializes the stack.
Method Detail |
public void advance()
public short current()
public void push(int n)
n
and push the right side .
public void cancel()
public boolean endOfInput()
public int[][] LLTable() throws java.lang.Exception
table[v][c]
is the rule to
apply if the variable v
is on the stack and
v
is the lookahead value.
java.lang.Exception
public void lLParse() throws java.lang.Exception
java.lang.Exception
public static void main(java.lang.String[] args) throws java.io.IOException
java.io.IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |