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.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate char[]protected intprivate intprotected Stringprotected doubleprotected floatprotected Stringprotected booleanprotected intprotected longprotected longprotected longThe position of the previous tokenprotected intprotected intprotected Stringprotected JasmTokens.TokenFields inherited from class ParseBase
debugFlag, environment, parser, scanner -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate Stringprotected final voidChecks the token, throws an exception if differentprotected final booleanCheck the token may be identifierprotected voidprotected voidprotected final voidExpects the token, scans the next token or throws an exception.protected final voidExpects an identifier token with parsed content of the token, scans the next token or throws an exception.protected final voidexpectOneOf(List<String> identifiers, JasmTokens.Token... tokens) protected final booleanexpectOneOfIdent(String... identifiers) Expects one of Identifier in the list, scans the next token or throws an exception.protected final booleanexpectOneOfToken(JasmTokens.Token... tokens) Expects one of the token in the list, scans the next token or throws an exception.private voidputCh(int ch) protected voidscan()Scan the next token.private voidScan a decimal at this pointprivate StringScan a doc comment.private longScan an escape character.private voidscanIdentifier(char[] prefix) Scan an Identifier.protected voidprivate voidScan a number.private voidscanReal()Scan a float.private voidScan a string.private voidScan a comment.protected final voidxscan()Methods inherited from class ParseBase
init, init, init, setDebugFlag, traceMethodInfoLn, traceMethodInfoLn, traceMethodInfoLn
-
Field Details
-
ch
protected int ch -
token
-
pos
protected long pos -
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 long prevPosThe position of the previous token -
sign
protected int sign -
inBits
protected boolean inBits -
count
private int count -
buffer
private char[] buffer -
escapingAllowed
-
noFunc
-
yesAndProcessFunc
-
-
Constructor Details
-
Scanner
main constructor.Create a scanner to scan an input stream.
-
-
Method Details
-
scanModuleStatement
protected void scanModuleStatement() -
scan
protected void scan()Scan the next token. -
checkTokenIdent
protected final boolean checkTokenIdent()Check the token may be identifier -
expect
Expects the token, scans the next token or throws an exception.- Throws:
SyntaxError
-
expectIdentContent
Expects an identifier token with parsed content of the token, scans the next token or throws an exception.- Throws:
SyntaxError
-
expectOneOf
protected final void expectOneOf(List<String> identifiers, JasmTokens.Token... tokens) throws SyntaxError - Throws:
SyntaxError
-
expectOneOfToken
Expects one of the token in the list, scans the next token or throws an exception.- Throws:
SyntaxError
-
expectOneOfIdent
Expects one of Identifier in the list, scans the next token or throws an exception.- Throws:
SyntaxError
-
check
Checks the token, throws an exception if different- Throws:
SyntaxError
-
putCh
private void putCh(int ch) -
bufferString
-
skipComment
private void skipComment()Scan a comment. This method should be called once the initial /, * and the next character have been read. -
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. -
scanCPRef
private void scanCPRef()Scan a decimal at this point -
scanNumber
private void 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 -
scanReal
private void 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 '.' -
scanEscapeChar
private long scanEscapeChar()Scan an escape character.- Returns:
- the character or '\\'
-
scanString
private void scanString()Scan a string. The current character should be the opening " of the string. -
scanIdentifier
private void scanIdentifier(char[] prefix) Scan an Identifier. The current character should be the first character of the identifier. -
xscan
protected final void xscan() -
debugScan
-
debugScan
-