unm.cs351.f11.tdrl.p1
Interface LexicalAnalyzer<T extends Enum<T> & HasPattern>


public interface LexicalAnalyzer<T extends Enum<T> & HasPattern>

A general interface for a very basic, regular expression-driven lexical analyzer (lexer). This is a generic type that accepts, as a type parameter, an enum type defining the tokens. That is, the type T for this interface allows the client code to specify its own set of tokens, as an enum. That enum type has to meet the HasPattern interface, which says that each token will provide a string regex pattern that defines the category of strings that it will match.

Concrete types implementing this interface MUST provide a constructor that allows clients to specify the identity of the "end of file" token (EOF). This is the token that will be returned by nextTok() when it reaches the end of file.

Note: This type does not currently support pushback of tokens, though subclasses may provide that functionality if they wish.

Version:
1.0
Author:
terran

Method Summary
 Token<T> nextTok()
          Return the next token available from the input sequence.
 

Method Detail

nextTok

Token<T> nextTok()
                                             throws ParseException
Return the next token available from the input sequence. Returns the user-defined "EOF" token when the end of input is reached.

Returns:
Next token.
Throws:
ParseException - If there is a lexical failure (such as if no token type matches the next sequence of characters.)