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 |
---|---|
protected int |
ch
The current character
|
protected char |
charValue |
protected String |
docComment |
protected double |
doubleValue |
protected float |
floatValue |
protected String |
idValue |
protected Environment |
in
Input stream
|
protected boolean |
inBits |
protected int |
intValue |
protected long |
longValue |
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 String |
stringValue |
protected JasmTokens.Token |
token
Current token
|
Modifier | Constructor and Description |
---|---|
protected |
Scanner(Environment env)
main constructor.
|
Modifier and Type | Method and Description |
---|---|
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(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.
|
protected void |
scan()
scan
Scan the next token.
|
protected void |
scanModuleStatement() |
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 String stringValue
protected String idValue
protected int radix
protected String docComment
protected int prevPos
protected int sign
protected boolean inBits
protected Scanner(Environment env) throws IOException
IOException
protected void scanModuleStatement() throws IOException
IOException
protected void scan() throws IOException
IOException
protected final boolean checkTokenIdent()
protected final void expect(JasmTokens.Token t) throws Scanner.SyntaxError, IOException
Scanner.SyntaxError
IOException
protected final void check(JasmTokens.Token t) throws Scanner.SyntaxError, IOException
Scanner.SyntaxError
IOException
public static boolean isUCDigit(int ch)
ch
- the character to be checkedpublic static boolean isUCLetter(int ch)
ch
- the character to be checkedprotected final void xscan() throws IOException
IOException
Copyright © 2021. All Rights Reserved.