Package org.openjdk.asmtools.jcoder
Class Scanner
java.lang.Object
org.openjdk.asmtools.jcoder.Scanner
A Scanner for Jcoder 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 int
private int
A growable character buffer.private boolean
protected String
protected JcoderEnvironment
static final int
protected int
protected JcoderEnvironment.InputFile
protected int
protected int
static final int
protected ByteBuffer
protected long
protected String
private int
protected int
protected int
protected int
protected int
protected String
protected JcodTokens.Token
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Scanner
(JcoderEnvironment environment) protected
Scanner
(JcoderEnvironment environment, HashMap<String, String> macros) -
Method Summary
Modifier and TypeMethodDescription(package private) void
private String
protected void
match
(JcodTokens.Token open, JcodTokens.Token close) Scan to a matching '}', ']' or ')'.private void
putc
(int ch) (package private) void
readCh()
protected int
scan()
Scan the next token.private void
Scan a character array.private void
Scan a decimal numberprivate String
Scan a doc comment.private int
Scan an escape character.private void
Scan a hex number.private void
Scan an Identifier.protected int
Scan the next token.private void
Scan a string.(package private) void
setDebugCP
(boolean enable) (package private) void
private void
Scan a comment.protected void
skipTill
(int sym) protected int
xscan()
-
Field Details
-
EOF
public static final int EOF- See Also:
-
LBRACE
public static final int LBRACE- See Also:
-
environment
-
inputFile
-
ch
protected int ch -
prevCh
protected int prevCh -
macro
-
indexMacro
protected int indexMacro -
token
-
pos
protected int pos -
prevPos
protected int prevPos -
longValue
protected long longValue -
intValue
protected int intValue -
intSize
protected int intSize -
stringValue
-
longStringValue
-
sign
protected int sign -
docComment
-
macros
-
debugCP
private boolean debugCP -
numCPentrs
private int numCPentrs -
count
private int countA growable character buffer. -
buffer
private char[] buffer
-
-
Constructor Details
-
Scanner
- Throws:
IOException
-
Scanner
- Throws:
IOException
-
-
Method Details
-
setDebugCP
void setDebugCP(boolean enable) -
addConstDebug
-
setMacro
-
readCh
- Throws:
IOException
-
putc
private void putc(int ch) -
bufferString
-
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 (witout leading spaces and '*'s) in the string buffer.- Throws:
IOException
-
scanDecNumber
Scan a decimal number- Throws:
IOException
-
scanHexNumber
Scan a hex number.- Throws:
IOException
-
scanEscapeChar
Scan an escape character.- Returns:
- the character or -1 if it escaped an end-of-line.
- Throws:
IOException
-
scanString
Scan a string. The current character should be the opening " of the string.- Throws:
IOException
-
scanCharArray
Scan a character array. The current character should be the opening ' of the array.- Throws:
IOException
-
scanIdentifier
Scan an Identifier. The current character should be the first character of the identifier.- Throws:
IOException
-
skipTill
- Throws:
IOException
-
xscan
- Throws:
IOException
-
match
Scan to a matching '}', ']' or ')'. The current token must be a '{', '[' or '(';- Throws:
IOException
-
scan
Scan the next token.- Returns:
- the position of the previous token.
- Throws:
IOException
-
scanMacro
Scan the next token.- Returns:
- the position of the previous token.
- Throws:
IOException
-