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 TypeFieldDescriptionprotected intThe current characterprotected Stringprotected SourceFileWhere errors are reportedstatic final intEnd of inputprotected SourceFileInput streamprotected intprotected intprotected intstatic final intprotected org.openjdk.asmtools.jcoder.ByteBufferprotected longprotected Stringprotected intThe position of the current tokenprotected intThe current characterprotected intThe position of the previous tokenprotected intprotected Stringprotected JcodTokens.TokenCurrent token -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedScanner(SourceFile sf) for use in jcfront.protectedScanner(SourceFile sf, HashMap<String, String> macros) Create a scanner to scan an input stream. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidmatch(JcodTokens.Token open, JcodTokens.Token close) Scan to a matching '}', ']' or ')'.protected intscan()Scan the next token.protected intScan the next token.protected voidskipTill(int sym) protected intxscan()
-
Field Details
-
EOF
public static final int EOFEnd of input- See Also:
-
LBRACE
public static final int LBRACE- See Also:
-
env
Where errors are reported -
in
Input stream -
ch
protected int chThe current character -
prevCh
protected int prevChThe current character -
macro
-
indexMacro
protected int indexMacro -
token
Current token -
pos
protected int posThe position of the current token -
prevPos
protected int prevPosThe position of the previous token -
longValue
protected long longValue -
intValue
protected int intValue -
intSize
protected int intSize -
stringValue
-
longStringValue
protected org.openjdk.asmtools.jcoder.ByteBuffer longStringValue -
sign
protected int sign -
docComment
-
-
Constructor Details
-
Scanner
Create a scanner to scan an input stream.- Throws:
IOException
-
Scanner
for use in jcfront.- Throws:
IOException
-
-
Method Details
-
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
-