pldi3
Interface Lexical


public abstract interface Lexical

Abstract interface to a lexical analyser for use in recursive descent parsers.


Method Summary
 boolean have(int token)
          The function returns true if the current symbol is one of the lexical tokens indicated by the integer parameter.
 boolean have(java.lang.String token)
          The function returns true if the current symbol is the same as the string.
 void mustbe(int token)
          This throws an exception if the current symbol is not the token.
 void mustbe(java.lang.String token)
          Equivalent to mustbe(tokenise(token))
 void nextSymbol()
          Advance to the next symbol
 int tokenise(java.lang.String token)
          Convert a string to the equivalent integer token
 

Method Detail

have

public boolean have(java.lang.String token)
The function returns true if the current symbol is the same as the string. Semantically equivalent to a call of have(tokenise(token)).

have

public boolean have(int token)
The function returns true if the current symbol is one of the lexical tokens indicated by the integer parameter. This form is useful if one wishes to provide an interface to match variables or numbers. For that purpose any class implementing the interface should define a set of public static integer fields that correspond to classes of lexical tokens. Semantically equivalent to if (currentSymbol == token ){ nextSymbol(); return true; } else return false;

tokenise

public int tokenise(java.lang.String token)
Convert a string to the equivalent integer token

mustbe

public void mustbe(int token)
            throws java.lang.Exception
This throws an exception if the current symbol is not the token. Semantically equivalent to throw exception if not have(token)

mustbe

public void mustbe(java.lang.String token)
            throws java.lang.Exception
Equivalent to mustbe(tokenise(token))

nextSymbol

public void nextSymbol()
Advance to the next symbol



View My Stats