public abstract class AbstractLexer extends Object
AbstractLexer
supports lexical analysis of keyword tokens produced by
a keyword lexer to create syntactic tokens for an AbstractLexer
that
creates a corresponding CST, that may in turn be
exploited by an AbstractAnalyzer
to create an AST.
Derived classes should extend the abstract support for AST from CST from tokens from text
parsing and analysis to support the AST and CST classes appropriate to a particular language.Constructor and Description |
---|
AbstractLexer(BasicEnvironment environment) |
Modifier and Type | Method and Description |
---|---|
BasicEnvironment |
getEnvironment() |
abstract DerivedLexStream |
getILexStream() |
static char[] |
getInputChars(Reader reader)
Read all input characters from a reader.
|
abstract int[] |
getKeywordKinds()
Queries the token kinds, as defined by my keyword lexer, of tokens that
are keywords in by grammar.
|
abstract ILexStream |
getLexStream() |
abstract LexParser |
getParser() |
abstract ParseTable |
getParseTable() |
void |
initialize(char[] inputChars)
Deprecated.
clients should use
reset(char[], String) |
void |
initialize(Reader reader)
Deprecated.
clients should invoke
reset(Reader, String) |
abstract void |
lexer(DerivedPrsStream prsStream)
Runs the lexer's with the provided
parseStream |
abstract void |
lexer(DerivedPrsStream prsStream,
int start_offset,
int end_offset)
Runs the lexer's with the provided
parseStream
in specific offset of the input |
abstract void |
lexer(Monitor monitor,
DerivedPrsStream prsStream)
Runs the lexer's with the provided
parseStream and
the given monitor. |
abstract void |
lexer(Monitor monitor,
DerivedPrsStream prsStream,
int start_offset,
int end_offset)
Runs the lexer's with the provided
parseStream
in specific offset of the input |
void |
lexToTokens(AbstractParser parser)
Deprecated.
clients should invoke
lexer(DerivedPrsStream) |
void |
lexToTokens(Monitor monitor,
AbstractParser parser)
Deprecated.
clients should invoke
lexer(Monitor, DerivedPrsStream) |
abstract void |
reportLexicalError(int startLoc,
int endLoc)
Report a lexical error in the given localization (start and end offset)
|
abstract void |
reset(char[] input_chars,
String filename)
Resets the lexer's input with the given char's array.
|
abstract void |
reset(char[] input_chars,
String filename,
int tab)
Resets the lexer's input with the given char's array.
|
abstract void |
reset(Reader reader,
String filename)
Resets the lexer's input with the given Reader
|
abstract void |
resetKeywordLexer()
Rsets the lexer's keywordLexer
|
public AbstractLexer(BasicEnvironment environment)
public static char[] getInputChars(Reader reader) throws IOException
reader
- providing the source textIOException
- if reading failspublic BasicEnvironment getEnvironment()
@Deprecated public void initialize(char[] inputChars)
reset(char[], String)
inputChars
- the characters@Deprecated public void initialize(Reader reader) throws IOException
reset(Reader, String)
reader
- providing the source textIOException
- if reading fails@Deprecated public void lexToTokens(AbstractParser parser)
lexer(DerivedPrsStream)
parser
- the AbstractParser
instance@Deprecated public void lexToTokens(Monitor monitor, AbstractParser parser)
lexer(Monitor, DerivedPrsStream)
parser
- the AbstractParser
instancepublic abstract int[] getKeywordKinds()
public abstract DerivedLexStream getILexStream()
lexStream
public abstract void reset(char[] input_chars, String filename)
input_chars
- the new lexer's inputfilename
- a file name used for logging when encountering errors/warningspublic abstract void reset(char[] input_chars, String filename, int tab)
input_chars
- the new lexer's inputfilename
- a file name used for logging when encountering errors/warningstab
- lexer's tab length.public abstract void reset(Reader reader, String filename) throws IOException
reader
- the new lexer's inputfilename
- a file name used for logging when encountering errors/warningsIOException
public abstract void lexer(DerivedPrsStream prsStream)
parseStream
prsStream
- the associated parseStream
public abstract void lexer(Monitor monitor, DerivedPrsStream prsStream)
parseStream
and
the given monitor.monitor
- the Monitor
prsStream
- the associated parseStream
public abstract void lexer(DerivedPrsStream prsStream, int start_offset, int end_offset)
parseStream
in specific offset of the inputprsStream
- the associated parseStream
start_offset
- the start offsetend_offset
- the end offsetpublic abstract void lexer(Monitor monitor, DerivedPrsStream prsStream, int start_offset, int end_offset)
parseStream
in specific offset of the inputprsStream
- the associated parseStream
start_offset
- the start offsetend_offset
- the end offsetpublic abstract ParseTable getParseTable()
ParseTable
public abstract LexParser getParser()
LexParser
public abstract void resetKeywordLexer()
public abstract ILexStream getLexStream()
lexStream
public abstract void reportLexicalError(int startLoc, int endLoc)
startLoc
- the offset the error startsendLoc
- the offset the error ends.Copyright © 2005, 2018 IBM Corporation and others. All Rights Reserved.