Package com.scriptbasic.interfaces
Interface LexicalAnalyzer
- All Known Subinterfaces:
LineOrientedLexicalAnalyzer
- All Known Implementing Classes:
BasicLexicalAnalyzer,ScriptBasicLexicalAnalyzer
public interface LexicalAnalyzer
A generic lexical analyzer that reads the characters from a reader and
returns the LexicalElements one after the other.
The actual implementation specifies what lexical elements that identifies and returns.
- Author:
- Peter Verhas
-
Method Summary
Modifier and Type Method Description LexicalElementget()Get the next lexical element from the input stream.LexicalElementpeek()Peek at the next lexical element and do not remove it from the input stream.voidregisterElementAnalyzer(LexicalElementAnalyzer lea)Register a lexical element analyzer.
-
Method Details
-
get
Get the next lexical element from the input stream. If there are no more lexical elements then returnnull- Returns:
- return the next lexical element
- Throws:
AnalysisException- in case there is an exception
-
peek
Peek at the next lexical element and do not remove it from the input stream. Consecutive calls topeek()without callingget()will return the same lexical element. Callingget()will return the same lexical element as the last call topeek().Just as
get()this method may also returnnullif there are no more elements.- Returns:
- the next lexical element
- Throws:
AnalysisException- in case of exception
-
registerElementAnalyzer
Register a lexical element analyzer. The lexical element analyzers are consulted in the order they are registered to match a lexeme.- Parameters:
lea- parameter
-