Package com.scriptbasic.lexer
Class BasicLexicalAnalyzer
java.lang.Object
com.scriptbasic.lexer.BasicLexicalAnalyzer
- All Implemented Interfaces:
LexicalAnalyzer,LineOrientedLexicalAnalyzer
- Direct Known Subclasses:
ScriptBasicLexicalAnalyzer
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionget()Get the next lexical element from the input stream.peek()Peek at the next lexical element and do not remove it from the input stream.voidRegister a lexical element analyzer.voidResets the state of the lexical analyzer so that the internal lexeme pointer is reset to the first lexeme of the actual line and the next call toLexicalAnalyzer.get()will return again the first lexeme of the line.
-
Constructor Details
-
BasicLexicalAnalyzer
-
-
Method Details
-
registerElementAnalyzer
Description copied from interface:LexicalAnalyzerRegister a lexical element analyzer. The lexical element analyzers are consulted in the order they are registered to match a lexeme.- Specified by:
registerElementAnalyzerin interfaceLexicalAnalyzer- Parameters:
lea- parameter
-
resetLine
public void resetLine()Description copied from interface:LineOrientedLexicalAnalyzerResets the state of the lexical analyzer so that the internal lexeme pointer is reset to the first lexeme of the actual line and the next call toLexicalAnalyzer.get()will return again the first lexeme of the line.- Specified by:
resetLinein interfaceLineOrientedLexicalAnalyzer
-
get
Description copied from interface:LexicalAnalyzerGet the next lexical element from the input stream. If there are no more lexical elements then returnnull- Specified by:
getin interfaceLexicalAnalyzer- 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 callingLexicalAnalyzer.get()will return the same lexical element. CallingLexicalAnalyzer.get()will return the same lexical element as the last call topeek().Just as
LexicalAnalyzer.get()this method may also returnnullif there are no more elements.- Specified by:
peekin interfaceLexicalAnalyzer- Returns:
- the next lexical element
- Throws:
AnalysisException- in case of exception
-