Framework for implementing lexical scanners and parsers.
checkErrors
public boolean checkErrors(PrintWriter out,
int max)
Returns true if any error were seen. Prints and clears the errors.
out
- where to write the error message tomax
- maximum number of messages to print (can be 0)
checkNext
public boolean checkNext(char ch)
throws java.io.IOException
Check if the next character matches a given character.
ch
- The character to match against.
- if the character read matches
On a match, the position is advanced following that character.
clearErrors
public void clearErrors()
close
public void close()
throws java.io.IOException
eofError
public void eofError(String message,
int startLine,
int startColumn)
throws SyntaxException
error
public void error(String message)
error
public void error(char severity,
String message)
error
public void error(char severity,
String filename,
int line,
int column,
String message)
getColumnNumber
public int getColumnNumber()
getLineNumber
public int getLineNumber()
getName
public String getName()
isInteractive
public boolean isInteractive()
mark
public void mark()
throws java.io.IOException
Start tentative parsing. Must be followed by a reset.
peek
public int peek()
throws java.io.IOException
popNesting
public void popNesting(char save)
Exit a nested expression, reversing pushNesting
save
- Saved values return by prior pushNesting
pushNesting
public char pushNesting(char promptChar)
Enter a nested expression.
This is used in interactive mode to control whether to continue
past end of line, depending on whether the expression is incomplete.
promptChar
- Used in prompt string to indicate type of nesting.
- The previous value of promptChar, to be passed to popNesting.
read
public int read()
throws java.io.IOException
read
public int read(char[] buf,
int offset,
int length)
throws java.io.IOException
readDigitsInBuffer
public static long readDigitsInBuffer(LineBufferedReader port,
int radix)
Read digits, up to the first non-digit or the buffer limit
- the digits seen as a non-negative long, or -1 on overflow
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.
reset
public void reset()
throws java.io.IOException
Stop tentative parsing. Return to position where we called mark.
seenErrors
public boolean seenErrors()
setInteractive
public void setInteractive(boolean v)
skip
public void skip()
throws java.io.IOException
skip_quick
protected void skip_quick()
throws java.io.IOException
tokenBufferAppend
public void tokenBufferAppend(int ch)
Append one character to tokenBuffer, resizing it if need be.
unread
protected void unread()
throws java.io.IOException
unread
public void unread(int ch)
throws java.io.IOException
unread_quick
protected void unread_quick()
throws java.io.IOException