|
Jalopy 1.0b10 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--de.hunsicker.jalopy.language.Recognizer
Recognizer acts as a helper class to bundle both an ANTLR parser and lexer for the task of language recognition.
Inner Class Summary | |
static class |
Recognizer.ParseException
Indicates an unexpected error during the parsing of an input file or stream. |
Field Summary | |
protected Lexer |
lexer
The used lexer. |
protected Parser |
parser
The used parser. |
static String |
UNKNOWN_FILE
Represents an unknown filename that may be used for the filename argument with parse(Reader, String) or parse(String, String) . |
Constructor Summary | |
protected |
Recognizer()
Creates a new Recognizer object. |
|
Recognizer(Parser parser,
Lexer lexer)
Creates a new Recognizer object. |
Method Summary | |
int |
getColumn()
Returns the current column of the lexer. |
FileFormat |
getFileFormat()
Gets the file format of the parsed file as reported by the lexer |
Lexer |
getLexer()
Returns the used lexer. |
int |
getLine()
Returns the current line of the lexer. |
Parser |
getParser()
Returns the used parser. |
AST |
getParseTree()
Returns the root node of the generated parse tree. |
boolean |
isFinished()
Indicates whether the recognizer is currently running. |
boolean |
isRunning()
Indicates whether the recognizer is currently running. |
void |
parse(File file)
Parses the given file. |
void |
parse(Reader in,
String filename)
Parses the given stream. |
void |
parse(String str,
String filename)
Parses the given string. |
void |
reset()
Resets both the parser and lexer. |
void |
setColumn(int column)
Sets the current column of the lexer. |
void |
setLine(int line)
Sets the current line of the lexer. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final String UNKNOWN_FILE
parse(Reader, String)
or parse(String, String)
.protected Lexer lexer
protected Parser parser
Constructor Detail |
public Recognizer(Parser parser, Lexer lexer)
parser
- the parser to use.lexer
- the lexer to use.protected Recognizer()
Method Detail |
public void setColumn(int column)
column
- current column information.public int getColumn()
public FileFormat getFileFormat()
IllegalStateException
- if nothing has been parsed yet.public boolean isFinished()
true
if the recognizer is currently running.public Lexer getLexer()
public void setLine(int line)
line
- current line information.public int getLine()
public AST getParseTree()
public Parser getParser()
public boolean isRunning()
true
if the recognizer is currently running.public void parse(Reader in, String filename)
in
- stream we read from.filename
- name of the file we parse.IllegalStateException
- if the parser is currently running.Recognizer.ParseException
- if an unexpected error occured.public void parse(File file)
file
- file to parse.public void parse(String str, String filename) throws IOException
str
- to parse.filename
- name of the file we parse.IOException
- if an I/O error occured.public void reset()
Parser.reset()
,
Lexer.reset()
|
Jalopy 1.0b10 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |