Absimpa v684

absimpa
Interface Lexer<N,TokenCode extends java.lang.Enum<TokenCode>>

Type Parameters:
TokenCode - is the type representing the characters of the language to be parsed
All Known Implementing Classes:
ExprLanguage.L, SimpleLexer

public interface Lexer<N,TokenCode extends java.lang.Enum<TokenCode>>

defines the interface to a lexical analyzer (lexer) needed by the Parser. This interface does not define the kind of input the lexer takes apart. It is only assumed that the lexer, as a result, can provide objects of an enumeration type.

The Lexer must maintain a current token code which is repeatedly queried by the parser. Only when next() is called, the parser should discard the current token, and chop the next token off its own input.


Method Summary
 TokenCode current()
           provides the current token code.
 N next()
           returns a node of type N for the current token while advancing the current token internally to the next one.
 ParseException parseException(java.util.Set<TokenCode> expectedTokens)
           creates a ParseException on request from the parser.
 

Method Detail

next

N next()
       throws ParseException

returns a node of type N for the current token while advancing the current token internally to the next one.

Throws:
ParseException

current

TokenCode current()

provides the current token code. This method must always return the same token code as long as next() is not called.


parseException

ParseException parseException(java.util.Set<TokenCode> expectedTokens)

creates a ParseException on request from the parser. This method is called by the parser if it finds a token code that does not fit its grammar. It is up to the Lexer implementation to provide as much information as possible in the exception about the current position of the input.

Parameters:
expectedTokens - a set of tokens that the parser would have expected at the current position.

Absimpa v684