|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--jeops.compiler.parser.Scanner
Class used in the parsing of the rules file. It's the first step in the converting of the rules into Java classes.
Field Summary | |
private java.lang.StringBuffer |
buffer
The string buffer used in the scanning of the file. |
private int |
currentColumn
The current column from the file. |
private int |
currentLine
The current line from the file. |
private Token |
currentToken
The current token. |
private char |
lastChar
The last char read from the file. |
private Token |
lastNonWhiteSpaceToken
The last non-whitespace token. |
private java.io.BufferedReader |
reader
The reader used to get the characters from the rules file. |
private static java.lang.String[] |
reservedWords
The list of reserved words. |
private java.lang.String |
ruleFileName
The name of the rules file. |
private int |
tokenColumn
The column of the first character in the current token. |
private int |
tokenLine
The line of the first character in the current token. |
private static int[] |
typeReservedWords
The token types of the reserved words. |
Fields inherited from interface jeops.compiler.parser.TokenConstants |
ACTIONS,
ASTERISK,
CLOSE_CURLY_BRACKET,
COMMA,
COMMENT,
CONDITIONS,
DECLARATIONS,
DOT,
EOF,
EQUALS,
ERROR,
EXTENDS,
IDENT,
IMPLEMENTS,
IMPORT,
LOCALDECL,
NONE_ABOVE,
OPEN_CURLY_BRACKET,
PACKAGE,
PUBLIC,
RULE,
RULE_BASE,
SEMICOLON,
STRING,
WHITE_SPACE |
Constructor Summary | |
Scanner(java.lang.String ruleFileName)
Class constructor. |
Method Summary | |
private int |
checkReserved(java.lang.String id)
Checks whether a given identifier is a reserved word. |
int |
getCurrentColumn()
Returns the current column from the file. |
int |
getCurrentLine()
Returns the current line from the file. |
Token |
getLastNonWhiteSpaceToken()
Returns the last non-whitespace token. |
private Token |
idOrReserved(java.lang.String str)
Returns a token that can be an identifier or a reserved word. |
static void |
main(java.lang.String[] args)
Test method for this class. |
Token |
nextToken()
Returns the next token from the file. |
private void |
readNextChar()
Reads the next char in the file, storing it in "lastChar". |
Methods inherited from class java.lang.Object |
|
Field Detail |
private Token currentToken
private java.lang.String ruleFileName
private java.io.BufferedReader reader
private java.lang.StringBuffer buffer
private char lastChar
private int tokenLine
private int currentLine
private int tokenColumn
private int currentColumn
private Token lastNonWhiteSpaceToken
private static final java.lang.String[] reservedWords
private static final int[] typeReservedWords
Constructor Detail |
public Scanner(java.lang.String ruleFileName) throws java.io.IOException
ruleFileName
- the name of the rules file.Method Detail |
private int checkReserved(java.lang.String id)
id
- the identifier to be checked.-1
if it's not a reserved
word.public int getCurrentColumn()
public int getCurrentLine()
public Token getLastNonWhiteSpaceToken()
private Token idOrReserved(java.lang.String str)
str
- the string that represents either an identifier or a
reserved word.public static void main(java.lang.String[] args)
args
- command-line arguments. None is needed, but
one can pass the rule file name for the scanning.public Token nextToken() throws java.io.IOException
private void readNextChar() throws java.io.IOException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |