public class Lexer
extends java.io.Reader
Modifier and Type | Field and Description |
---|---|
protected int |
nesting |
protected gnu.kawa.io.InPort |
port |
protected boolean |
tentative |
char[] |
tokenBuffer
For building tokens of various kinds.
|
int |
tokenBufferLength
The number of chars of tokenBuffer that are used.
|
Constructor and Description |
---|
Lexer(gnu.kawa.io.InPort port) |
Lexer(gnu.kawa.io.InPort port,
SourceMessages messages) |
Modifier and Type | Method and Description |
---|---|
boolean |
checkErrors(java.io.PrintWriter out,
int max)
Returns true if any error were seen.
|
boolean |
checkNext(char ch)
Check if the next character matches a given character.
|
void |
clearErrors() |
void |
close() |
void |
eofError(java.lang.String msg) |
void |
eofError(java.lang.String message,
int startLine,
int startColumn) |
void |
error(char severity,
java.lang.String message) |
void |
error(char severity,
java.lang.String filename,
int line,
int column,
java.lang.String message) |
void |
error(java.lang.String message) |
void |
fatal(java.lang.String message) |
int |
getColumnNumber()
Return the current (zero-based) column number.
|
SourceError |
getErrors() |
int |
getLineNumber()
Get the current line number.
|
SourceMessages |
getMessages() |
java.lang.String |
getName() |
gnu.kawa.io.InPort |
getPort() |
boolean |
isInteractive() |
boolean |
isTentative()
True if input may be incomplete or actively edited.
|
void |
mark()
Start tentative parsing.
|
int |
peek() |
void |
popNesting(char save)
Exit a nested expression, reversing pushNesting
|
char |
pushNesting(char promptChar)
Enter a nested expression.
|
int |
read() |
int |
read(char[] buf,
int offset,
int length) |
int |
readCodePoint()
Read a Unicode character (codepoint) by checking for surrogates.
|
boolean |
readDelimited(java.lang.String delimiter)
Scan until a given delimiter.
|
static long |
readDigits(gnu.kawa.io.InPort port,
int radix) |
static long |
readDigitsInBuffer(gnu.kawa.io.InPort port,
long ival,
int radix)
Read digits, up to the first non-digit or the buffer limit
|
int |
readIntDigits() |
int |
readOptionalExponent()
Read an optional signed integer.
|
int |
readUnicodeChar()
Deprecated.
Use
readCodePoint() . |
void |
reset()
Stop tentative parsing.
|
boolean |
seenErrors() |
void |
setInteractive(boolean v) |
void |
setMessages(SourceMessages messages) |
void |
setTentative(boolean v) |
protected void |
skip_quick() |
void |
skip() |
void |
tokenBufferAppend(int ch)
Append one character to tokenBuffer, resizing it if need be.
|
java.lang.String |
tokenBufferString() |
protected void |
unread_quick() |
protected void |
unread() |
void |
unread(int ch) |
protected gnu.kawa.io.InPort port
protected boolean tentative
protected int nesting
public char[] tokenBuffer
public int tokenBufferLength
public Lexer(gnu.kawa.io.InPort port)
public Lexer(gnu.kawa.io.InPort port, SourceMessages messages)
public char pushNesting(char promptChar)
promptChar
- Used in prompt string to indicate type of nesting.public void popNesting(char save)
save
- Saved values return by prior pushNestingpublic final gnu.kawa.io.InPort getPort()
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in class java.io.Reader
java.io.IOException
public int read() throws java.io.IOException
read
in class java.io.Reader
java.io.IOException
@Deprecated public int readUnicodeChar() throws java.io.IOException
readCodePoint()
.java.io.IOException
public int readCodePoint() throws java.io.IOException
java.io.IOException
public int read(char[] buf, int offset, int length) throws java.io.IOException
read
in class java.io.Reader
java.io.IOException
public void unread(int ch) throws java.io.IOException
java.io.IOException
public int peek() throws java.io.IOException
java.io.IOException
public void skip() throws java.io.IOException
java.io.IOException
protected void unread() throws java.io.IOException
java.io.IOException
protected void unread_quick() throws java.io.IOException
java.io.IOException
public boolean checkNext(char ch) throws java.io.IOException
ch
- The character to match against.java.io.IOException
protected void skip_quick() throws java.io.IOException
java.io.IOException
public SourceMessages getMessages()
public void setMessages(SourceMessages messages)
public boolean checkErrors(java.io.PrintWriter out, int max)
out
- where to write the error message tomax
- maximum number of messages to print (can be 0)public SourceError getErrors()
public boolean seenErrors()
public void clearErrors()
public void error(char severity, java.lang.String filename, int line, int column, java.lang.String message)
public void error(char severity, java.lang.String message)
public void error(java.lang.String message)
public void fatal(java.lang.String message) throws SyntaxException
SyntaxException
public void eofError(java.lang.String msg) throws SyntaxException
SyntaxException
public void eofError(java.lang.String message, int startLine, int startColumn) throws SyntaxException
SyntaxException
public int readOptionalExponent() throws java.io.IOException
java.io.IOException
public boolean readDelimited(java.lang.String delimiter) throws java.io.IOException, SyntaxException
java.io.IOException
SyntaxException
public static long readDigitsInBuffer(gnu.kawa.io.InPort port, long ival, int radix)
ival
- previously-seen digits or -2 if no digits seenpublic static long readDigits(gnu.kawa.io.InPort port, int radix) throws java.io.IOException
java.io.IOException
public int readIntDigits() throws java.io.IOException
java.io.IOException
public java.lang.String getName()
public int getLineNumber()
public int getColumnNumber()
public boolean isInteractive()
public void setInteractive(boolean v)
public boolean isTentative()
public void setTentative(boolean v)
public void tokenBufferAppend(int ch)
public java.lang.String tokenBufferString()
public void mark() throws java.io.IOException
java.io.IOException
public void reset() throws java.io.IOException
reset
in class java.io.Reader
java.io.IOException