Package com.scriptbasic.lexer
Class BasicLexicalAnalyzer
- java.lang.Object
-
- com.scriptbasic.lexer.BasicLexicalAnalyzer
-
- All Implemented Interfaces:
LexicalAnalyzer,LineOrientedLexicalAnalyzer
- Direct Known Subclasses:
ScriptBasicLexicalAnalyzer
public class BasicLexicalAnalyzer extends java.lang.Object implements LineOrientedLexicalAnalyzer
-
-
Constructor Summary
Constructors Constructor Description BasicLexicalAnalyzer(SourceReader reader)
-
Method Summary
All Methods Instance Methods Concrete Methods 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.voidresetLine()Resets 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 Detail
-
BasicLexicalAnalyzer
public BasicLexicalAnalyzer(SourceReader reader)
-
-
Method Detail
-
registerElementAnalyzer
public void registerElementAnalyzer(LexicalElementAnalyzer lea)
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
public LexicalElement get() throws AnalysisException
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
public LexicalElement peek() throws AnalysisException
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
-
-