public class Scanner extends ParseBase
The scanner keeps track of the current token, the value of the current token (if any), and the start position of the current token.
The scan() method advances the scanner to the next token in the input.
The match() method is used to quickly match opening brackets (ie: '(', '{', or '[') with their closing counter part. This is useful during error recovery.
The compiler treats either "\n", "\r" or "\r\n" as the end of a line.
Modifier and Type | Class and Description |
---|---|
protected static class |
Scanner.SyntaxError
SyntaxError is the generic error thrown for parsing problems.
|
Modifier and Type | Field and Description |
---|---|
private char[] |
buffer |
protected int |
ch
The current character
|
protected char |
charValue |
private int |
count |
protected java.lang.String |
docComment |
protected double |
doubleValue |
private java.util.function.Predicate<java.lang.Integer> |
escapingAllowed |
protected float |
floatValue |
protected java.lang.String |
idValue |
protected Environment |
in
Input stream
|
protected boolean |
inBits |
protected int |
intValue |
protected long |
longValue |
private java.util.function.Predicate<java.lang.Integer> |
noFunc |
protected int |
pos
The position of the current token
|
protected int |
prevPos
The position of the previous token
|
protected int |
radix |
protected int |
sign |
protected java.lang.String |
stringValue |
protected JasmTokens.Token |
token
Current token
|
private java.util.function.Predicate<java.lang.Integer> |
yesAndProcessFunc |
Modifier | Constructor and Description |
---|---|
protected |
Scanner(Environment env)
main constructor.
|
Modifier and Type | Method and Description |
---|---|
private java.lang.String |
bufferString() |
protected void |
check(JasmTokens.Token t)
Checks a token, throws an exception if not the same
|
protected boolean |
checkTokenIdent()
Check the token may be identifier
|
protected void |
debugScan(java.lang.String dbstr) |
protected void |
expect(JasmTokens.Token t)
Expects a token, scans the next token or throws an exception.
|
static boolean |
isUCDigit(int ch)
Returns true if the character is a unicode digit.
|
static boolean |
isUCLetter(int ch)
Returns true if the character is a Unicode letter.
|
private void |
putCh(int ch) |
(package private) static java.lang.String |
readableConstant(int t) |
protected void |
scan()
scan
Scan the next token.
|
private void |
scanCPRef()
Scan a decimal at this point
|
private java.lang.String |
scanDocComment()
Scan a doc comment.
|
private int |
scanEscapeChar()
Scan an escape character.
|
private void |
scanIdentifier(char[] prefix)
Scan an Identifier.
|
protected void |
scanModuleStatement() |
private void |
scanNumber()
Scan a number.
|
private void |
scanReal()
Scan a float.
|
private void |
scanString()
Scan a string.
|
private void |
skipComment()
Scan a comment.
|
protected void |
xscan() |
debugStr, enableDebug, init
protected Environment in
protected int ch
protected JasmTokens.Token token
protected int pos
protected char charValue
protected int intValue
protected long longValue
protected float floatValue
protected double doubleValue
protected java.lang.String stringValue
protected java.lang.String idValue
protected int radix
protected java.lang.String docComment
private int count
private char[] buffer
private java.util.function.Predicate<java.lang.Integer> escapingAllowed
protected int prevPos
protected int sign
protected boolean inBits
private java.util.function.Predicate<java.lang.Integer> noFunc
private java.util.function.Predicate<java.lang.Integer> yesAndProcessFunc
protected Scanner(Environment env) throws java.io.IOException
java.io.IOException
protected void scanModuleStatement() throws java.io.IOException
java.io.IOException
protected void scan() throws java.io.IOException
java.io.IOException
protected final boolean checkTokenIdent()
static java.lang.String readableConstant(int t)
protected final void expect(JasmTokens.Token t) throws Scanner.SyntaxError, java.io.IOException
Scanner.SyntaxError
java.io.IOException
protected final void check(JasmTokens.Token t) throws Scanner.SyntaxError, java.io.IOException
Scanner.SyntaxError
java.io.IOException
private void putCh(int ch)
private java.lang.String bufferString()
public static boolean isUCDigit(int ch)
ch
- the character to be checkedpublic static boolean isUCLetter(int ch)
ch
- the character to be checkedprivate void skipComment() throws java.io.IOException
java.io.IOException
private java.lang.String scanDocComment() throws java.io.IOException
java.io.IOException
private void scanCPRef() throws java.io.IOException
java.io.IOException
private void scanNumber() throws java.io.IOException
java.io.IOException
private void scanReal() throws java.io.IOException
java.io.IOException
private int scanEscapeChar() throws java.io.IOException
java.io.IOException
private void scanString() throws java.io.IOException
java.io.IOException
private void scanIdentifier(char[] prefix) throws java.io.IOException
java.io.IOException
protected final void xscan() throws java.io.IOException
java.io.IOException