Class LL

java.lang.Object
  extended byLL

public class LL
extends java.lang.Object

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

expression

public char[] expression
The expression to analyze.


position

public int position
The current index.


stack

public java.util.Stack stack
The stack used to store the LR states.


G

public Grammar G
The current context-free grammar.


alphabet

public Alphabet alphabet
The input alphabet;

Constructor Detail

LL

public LL(java.lang.String exp,
          Grammar grammar)
Creates the LLTable and initializes the stack.

Method Detail

advance

public void advance()
Advance one character to the right on input.


current

public short current()
Returns the current token of the input. Discards possible space characters.


push

public void push(int n)
Pop the left side of production n and push the right side .


cancel

public void cancel()
Cancels the current character with the top of stack.


endOfInput

public boolean endOfInput()
True if the input has been read completely.


LLTable

public int[][] LLTable()
                throws java.lang.Exception
The LL(1) table analysis. The entry table[v][c] is the rule to apply if the variable v is on the stack and v is the lookahead value.

Returns:
the LL(1) table
Throws:
java.lang.Exception

lLParse

public void lLParse()
             throws java.lang.Exception
Parses the input expression using the LL(1) analysis alpgorithm.

Throws:
java.lang.Exception

main

public static void main(java.lang.String[] args)
                 throws java.io.IOException
Throws:
java.io.IOException