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 class
SyntaxError is the generic error thrown for parsing problems. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate char[]
protected int
The current characterprotected char
private int
protected String
protected double
protected float
protected String
protected Environment
Input streamprotected boolean
protected int
protected long
protected int
The position of the current tokenprotected int
The position of the previous tokenprotected int
protected int
protected String
protected JasmTokens.Token
Current token -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate String
protected final void
Checks a token, throws an exception if not the sameprotected final boolean
Check the token may be identifierprotected void
protected final void
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 String
readableConstant
(int t) protected void
scan()
scan Scan the next token.private void
Scan a decimal at this pointprivate String
Scan a doc comment.private int
Scan an escape character.private void
scanIdentifier
(char[] prefix) Scan an Identifier.protected void
private void
Scan a number.private void
scanReal()
Scan a float.private void
Scan a string.private void
Scan a comment.protected final void
xscan()
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
-
count
private int count -
buffer
private char[] buffer -
escapingAllowed
-
prevPos
protected int prevPosThe position of the previous token -
sign
protected int sign -
inBits
protected boolean inBits -
noFunc
-
yesAndProcessFunc
-
-
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 -
readableConstant
-
expect
Expects a token, scans the next token or throws an exception.- Throws:
Scanner.SyntaxError
IOException
-
check
Checks a token, throws an exception if not the same- Throws:
Scanner.SyntaxError
IOException
-
putCh
private void putCh(int ch) -
bufferString
-
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
-
skipComment
Scan a comment. This method should be called once the initial /, * and the next character have been read.- Throws:
IOException
-
scanDocComment
Scan a doc comment. This method should be called once the initial /, * and * have been read. It gathers the content of the comment (without leading spaces and '*'s) in the string buffer.- Throws:
IOException
-
scanCPRef
Scan a decimal at this point- Throws:
IOException
-
scanNumber
Scan a number. The first digit of the number should be the current character. We may be scanning hex, decimal, or octal at this point- Throws:
IOException
-
scanReal
Scan a float. We are either looking at the decimal, or we have already seen it and put it into the buffer. We haven't seen an exponent. Scan a float. Should be called with the current character is either the 'e', 'E' or '.'- Throws:
IOException
-
scanEscapeChar
Scan an escape character.- Returns:
- the character or '\\'
- Throws:
IOException
-
scanString
Scan a string. The current character should be the opening " of the string.- Throws:
IOException
-
scanIdentifier
Scan an Identifier. The current character should be the first character of the identifier.- Throws:
IOException
-
xscan
- Throws:
IOException
-
debugScan
-