gnu.text
Class Lexer
java.lang.Object
|
+--java.io.Reader
|
+--gnu.text.Lexer
- Direct Known Subclasses:
- Lexer, LispReader
- public class Lexer
- extends java.io.Reader
Framework for implementing lexical scanners.
| Fields inherited from class java.io.Reader |
lock |
|
Method Summary |
boolean |
checkErrors(java.io.PrintWriter out,
int max)
Returns true if any error were seen. |
void |
clearErrors()
|
void |
close()
|
void |
eofError(java.lang.String msg)
|
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)
|
SourceError |
getErrors()
|
SourceMessages |
getMessages()
|
int |
peek()
|
int |
read()
|
int |
read(char[] buf,
int offset,
int length)
|
static long |
readDigitsInBuffer(LineBufferedReader port,
int radix)
Read digits, up to the first non-digit or the buffer limit |
int |
readOptionalExponent()
Read an optional signed integer. |
boolean |
seenErrors()
|
void |
setMessages(SourceMessages messages)
|
protected void |
skip_quick()
|
void |
skip()
|
protected void |
unread_quick()
|
protected void |
unread()
|
void |
unread(int ch)
|
| Methods inherited from class java.io.Reader |
mark,
markSupported,
read,
ready,
reset,
skip |
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
port
protected LineBufferedReader port
Lexer
public Lexer(LineBufferedReader port)
Lexer
public Lexer(LineBufferedReader port,
SourceMessages messages)
close
public void close()
throws java.io.IOException
- Overrides:
- close in class java.io.Reader
read
public int read()
throws java.io.IOException
- Overrides:
- read in class java.io.Reader
read
public int read(char[] buf,
int offset,
int length)
throws java.io.IOException
- Overrides:
- read in class java.io.Reader
unread
public void unread(int ch)
throws java.io.IOException
peek
public int peek()
throws java.io.IOException
skip
public void skip()
throws java.io.IOException
unread
protected void unread()
throws java.io.IOException
unread_quick
protected void unread_quick()
throws java.io.IOException
skip_quick
protected void skip_quick()
throws java.io.IOException
getMessages
public SourceMessages getMessages()
setMessages
public void setMessages(SourceMessages messages)
checkErrors
public boolean checkErrors(java.io.PrintWriter out,
int max)
- Returns true if any error were seen. Prints and clears the errors.
- Parameters:
out - where to write the error message tomax - maximum number of messages to print (can be 0)
getErrors
public SourceError getErrors()
seenErrors
public boolean seenErrors()
clearErrors
public void clearErrors()
error
public void error(char severity,
java.lang.String filename,
int line,
int column,
java.lang.String message)
error
public void error(char severity,
java.lang.String message)
error
public void error(java.lang.String message)
fatal
public void fatal(java.lang.String message)
throws SyntaxException
eofError
public void eofError(java.lang.String msg)
throws SyntaxException
readOptionalExponent
public int readOptionalExponent()
throws java.io.IOException
- Read an optional signed integer.
If there is no integer in the input stream, return 1.
For excessively large exponents, return Integer.MIN_VALUE
or Integer.MAX_VALUE.
readDigitsInBuffer
public static long readDigitsInBuffer(LineBufferedReader port,
int radix)
- Read digits, up to the first non-digit or the buffer limit
- Returns:
- the digits seen as a non-negative long, or -1 on overflow