|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.upb.swt.mcie.parser.Scanner
public class Scanner
This class implements the scanner. The patterns for the different tokens are partly defined as regular expressions in order to make changes as easy as possible. Only tokens consisting of characters that are no letters or digits are explicitly checked in the code.
The symbol # indicates a line comment, which extends to the end of this line. The text starting at # up to the end of the line will be ignored by the scanner.
Field Summary | |
---|---|
private static java.util.regex.Pattern |
AF
The Pattern for the AF operator. |
private static java.util.regex.Pattern |
AG
The Pattern for the AG operator. |
private static java.util.regex.Pattern |
AND
The Pattern for the AND operation. |
private static java.util.regex.Pattern |
AR
The Pattern for the AR operator. |
private static java.util.regex.Pattern |
AU
The Pattern for the AU operator. |
private static java.util.regex.Pattern |
AX
The Pattern for the AX operator. |
private int |
column
The column number of the current position in the reader. |
private Token |
current
The current token. |
private char |
currentChar
The character at the current position in the reader. |
private static java.util.regex.Pattern |
EF
The Pattern for the EF operator. |
private static java.util.regex.Pattern |
EG
The Pattern for the EG operator. |
private static java.util.regex.Pattern |
ER
The Pattern for the ER operator. |
private static java.util.regex.Pattern |
EU
The Pattern for the EU operator. |
private static java.util.regex.Pattern |
EX
The Pattern for the EX operator. |
private static java.util.regex.Pattern |
FALSE
The Pattern for the constant false. |
private int |
line
The line number of the current position in the reader. |
private static char |
LINE_SEPARATOR
Defines the character that is used for separating lines. |
private static java.util.regex.Pattern |
NOT
The Pattern for the NOT operation. |
private static java.util.regex.Pattern |
OR
The Pattern for the OR operation. |
private Token |
previous
The previous token. |
private java.io.Reader |
reader
The reader with the text on which the scanner works. |
private static java.util.regex.Pattern |
TRUE
The Pattern for the constant true. |
Constructor Summary | |
---|---|
Scanner(java.io.Reader reader)
Constructs a scanner for the given Reader . |
Method Summary | |
---|---|
private char |
getNextChar()
Returns the next character of the character sequence and increments the position. |
Token |
getNextToken()
Returns the next token. |
private char |
getNextTrueChar()
Returns the first character of the text in the reader that is not a white space. |
void |
revert()
Reverts to the previously read token. |
private char |
skipLineComment()
Moves on to the next non-white space character after a line comment. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final char LINE_SEPARATOR
private static final java.util.regex.Pattern NOT
Pattern
for the NOT operation.
Note that this defines the pattern for the textual representation
of the not operation only. In addition the scanner accepts ! as
the symbol for not.
private static final java.util.regex.Pattern AND
Pattern
for the AND operation.
Note that this defines the pattern for the textual representation
of the and operation only. In addition the scanner accepts & as
the symbol for and.
private static final java.util.regex.Pattern OR
Pattern
for the OR operation.
Note that this defines the pattern for the textual representation
of the or operation only. In addition the scanner accepts | as
the symbol for or.
private static final java.util.regex.Pattern EX
Pattern
for the EX operator.
private static final java.util.regex.Pattern AX
Pattern
for the AX operator.
private static final java.util.regex.Pattern EG
Pattern
for the EG operator.
private static final java.util.regex.Pattern AG
Pattern
for the AG operator.
private static final java.util.regex.Pattern EF
Pattern
for the EF operator.
private static final java.util.regex.Pattern AF
Pattern
for the AF operator.
private static final java.util.regex.Pattern EU
Pattern
for the EU operator.
private static final java.util.regex.Pattern AU
Pattern
for the AU operator.
private static final java.util.regex.Pattern ER
Pattern
for the ER operator.
private static final java.util.regex.Pattern AR
Pattern
for the AR operator.
private static final java.util.regex.Pattern TRUE
Pattern
for the constant true.
private static final java.util.regex.Pattern FALSE
Pattern
for the constant false.
private java.io.Reader reader
private char currentChar
private int line
private int column
private Token previous
private Token current
Constructor Detail |
---|
public Scanner(java.io.Reader reader) throws java.io.IOException
Reader
.
reader
- the reader with the text to be scanned
java.io.IOException
- if an IO problem occursMethod Detail |
---|
private char getNextChar() throws java.io.IOException
Character.MIN_VALUE
.
java.io.IOException
- if an IO problem occursprivate char getNextTrueChar() throws java.io.IOException
Character.MIN_VALUE
.
java.io.IOException
- if an IO problem occursprivate char skipLineComment() throws java.io.IOException
Character.MIN_VALUE
.
java.io.IOException
- if an IO problem occurspublic void revert()
public Token getNextToken() throws java.io.IOException
java.io.IOException
- if an IO problem occurs
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |