Package org.openjdk.asmtools.jasm
Class Scanner
java.lang.Object
org.openjdk.asmtools.jasm.ParseBase
org.openjdk.asmtools.jasm.Scanner
A Scanner for Jasm tokens. Errors are reported to the environment object.
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classSyntaxError is the generic error thrown for parsing problems. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intThe current characterprotected charprotected Stringprotected doubleprotected floatprotected Stringprotected EnvironmentInput streamprotected booleanprotected intprotected longprotected intThe position of the current tokenprotected intThe position of the previous tokenprotected intprotected intprotected Stringprotected JasmTokens.TokenCurrent token -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected final voidChecks a token, throws an exception if not the sameprotected final booleanCheck the token may be identifierprotected voidprotected final voidExpects a token, scans the next token or throws an exception.static booleanisUCDigit(int ch) Returns true if the character is a unicode digit.static booleanisUCLetter(int ch) Returns true if the character is a Unicode letter.protected voidscan()scan Scan the next token.protected voidprotected final voidxscan()Methods inherited from class org.openjdk.asmtools.jasm.ParseBase
debugStr, enableDebug, init
-
Field Details
-
in
Input stream -
ch
protected int chThe current character -
token
Current token -
pos
protected int posThe position of the current token -
charValue
protected char charValue -
intValue
protected int intValue -
longValue
protected long longValue -
floatValue
protected float floatValue -
doubleValue
protected double doubleValue -
stringValue
-
idValue
-
radix
protected int radix -
docComment
-
prevPos
protected int prevPosThe position of the previous token -
sign
protected int sign -
inBits
protected boolean inBits
-
-
Constructor Details
-
Scanner
main constructor. Create a scanner to scan an input stream.- Throws:
IOException
-
-
Method Details
-
scanModuleStatement
- Throws:
IOException
-
scan
scan Scan the next token.- Throws:
IOException
-
checkTokenIdent
protected final boolean checkTokenIdent()Check the token may be identifier -
expect
Expects a token, scans the next token or throws an exception.- Throws:
Scanner.SyntaxErrorIOException
-
check
Checks a token, throws an exception if not the same- Throws:
Scanner.SyntaxErrorIOException
-
isUCDigit
public static boolean isUCDigit(int ch) Returns true if the character is a unicode digit.- Parameters:
ch- the character to be checked
-
isUCLetter
public static boolean isUCLetter(int ch) Returns true if the character is a Unicode letter.- Parameters:
ch- the character to be checked
-
xscan
- Throws:
IOException
-
debugScan
-