public class Scanner
extends java.lang.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.
Modifier and Type | Field and Description |
---|---|
private char[] |
buffer |
protected int |
ch
The current character
|
private int |
count
A growable character buffer.
|
private boolean |
debugCP |
protected java.lang.String |
docComment |
protected SourceFile |
env
Where errors are reported
|
static int |
EOF
End of input
|
protected SourceFile |
in
Input stream
|
protected int |
indexMacro |
protected int |
intSize |
protected int |
intValue |
static int |
LBRACE |
protected ByteBuffer |
longStringValue |
protected long |
longValue |
protected java.lang.String |
macro |
(package private) java.util.HashMap<java.lang.String,java.lang.String> |
macros |
private int |
numCPentrs |
protected int |
pos
The position of the current token
|
protected int |
prevCh
The current character
|
protected int |
prevPos
The position of the previous token
|
protected int |
sign |
protected java.lang.String |
stringValue |
protected JcodTokens.Token |
token
Current token
|
Modifier | Constructor and Description |
---|---|
protected |
Scanner(SourceFile sf)
for use in jcfront.
|
protected |
Scanner(SourceFile sf,
java.util.HashMap<java.lang.String,java.lang.String> macros)
Create a scanner to scan an input stream.
|
Modifier and Type | Method and Description |
---|---|
(package private) void |
addConstDebug(JcodTokens.ConstType ct) |
private java.lang.String |
bufferString() |
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 |
scanCharArray()
Scan a character array.
|
private void |
scanDecNumber()
Scan a decimal number
|
private java.lang.String |
scanDocComment()
Scan a doc comment.
|
private int |
scanEscapeChar()
Scan an escape character.
|
private void |
scanHexNumber()
Scan a hex number.
|
private void |
scanIdentifier()
Scan an Identifier.
|
protected int |
scanMacro()
Scan the next token.
|
private void |
scanString()
Scan a string.
|
(package private) void |
setDebugCP(boolean enable) |
(package private) void |
setMacro(java.lang.String macro) |
private void |
skipComment()
Scan a comment.
|
protected void |
skipTill(int sym) |
protected int |
xscan() |
public static final int EOF
public static final int LBRACE
private boolean debugCP
private int numCPentrs
protected SourceFile env
protected SourceFile in
java.util.HashMap<java.lang.String,java.lang.String> macros
protected int ch
protected int prevCh
protected java.lang.String macro
protected int indexMacro
protected JcodTokens.Token token
protected int pos
protected int prevPos
protected long longValue
protected int intValue
protected int intSize
protected java.lang.String stringValue
protected ByteBuffer longStringValue
protected int sign
protected java.lang.String docComment
private int count
private char[] buffer
protected Scanner(SourceFile sf, java.util.HashMap<java.lang.String,java.lang.String> macros) throws java.io.IOException
java.io.IOException
protected Scanner(SourceFile sf) throws java.io.IOException
java.io.IOException
void setDebugCP(boolean enable)
void addConstDebug(JcodTokens.ConstType ct)
void setMacro(java.lang.String macro)
void readCh() throws java.io.IOException
java.io.IOException
private void putc(int ch)
private java.lang.String bufferString()
private void skipComment() throws java.io.IOException
java.io.IOException
private java.lang.String scanDocComment() throws java.io.IOException
java.io.IOException
private void scanDecNumber() throws java.io.IOException
java.io.IOException
private void scanHexNumber() throws java.io.IOException
java.io.IOException
private int scanEscapeChar() throws java.io.IOException
java.io.IOException
private void scanString() throws java.io.IOException
java.io.IOException
private void scanCharArray() throws java.io.IOException
java.io.IOException
private void scanIdentifier() throws java.io.IOException
java.io.IOException
protected void skipTill(int sym) throws java.io.IOException
java.io.IOException
protected int xscan() throws java.io.IOException
java.io.IOException
protected void match(JcodTokens.Token open, JcodTokens.Token close) throws java.io.IOException
java.io.IOException
protected int scan() throws java.io.IOException
java.io.IOException
protected int scanMacro() throws java.io.IOException
java.io.IOException