public class Recognizer
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
Recognizer.ParseException
Indicates an unexpected error during the parsing of an input file or stream.
|
Modifier and Type | Field and Description |
---|---|
protected Lexer |
lexer
The used lexer.
|
protected Parser |
parser
The used parser.
|
static java.lang.String |
UNKNOWN_FILE
Represents an unknown filename that may be used for the filename argument
with
parse(Reader, String) or parse(String, String) . |
Modifier | Constructor and Description |
---|---|
protected |
Recognizer()
Creates a new Recognizer object.
|
|
Recognizer(Parser parser,
Lexer lexer)
Creates a new Recognizer object.
|
Modifier and Type | Method and Description |
---|---|
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.
|
de.hunsicker.antlr.collections.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(java.io.File file)
Parses the given file.
|
void |
parse(java.io.Reader in,
java.lang.String filename)
Parses the given stream.
|
void |
parse(java.lang.String str,
java.lang.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.
|
public static final java.lang.String UNKNOWN_FILE
parse(Reader, String)
or parse(String, String)
.protected Lexer lexer
protected Parser parser
public Recognizer(Parser parser, Lexer lexer)
parser
- the parser to use.lexer
- the lexer to use.protected Recognizer()
public void setColumn(int column)
column
- current column information.public int getColumn()
public FileFormat getFileFormat()
java.lang.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 de.hunsicker.antlr.collections.AST getParseTree()
public Parser getParser()
public boolean isRunning()
true
if the recognizer is currently running.public void parse(java.io.Reader in, java.lang.String filename)
in
- stream we read from.filename
- name of the file we parse.java.lang.IllegalStateException
- if the parser is currently running.Recognizer.ParseException
- if an unexpected error occured.public void parse(java.io.File file)
file
- file to parse.public void parse(java.lang.String str, java.lang.String filename) throws java.io.IOException
str
- to parse.filename
- name of the file we parse.java.io.IOException
- if an I/O error occured.public void reset()
Parser.reset()
,
Lexer.reset()
Submit a bug or feature.
For further information and documentation, visit the official Jalopy website.
This page generated: March 30 2013