|
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 | +--de.hunsicker.jalopy.language.JavaRecognizer
The Java-specific recognizer.
Inner classes inherited from class de.hunsicker.jalopy.language.Recognizer |
Recognizer.ParseException |
Field Summary | |
static int |
JDK_1_3
Indicates JDK version 1.3. |
static int |
JDK_1_4
Indicates JDK version 1.4. |
Fields inherited from class de.hunsicker.jalopy.language.Recognizer |
lexer, parser, UNKNOWN_FILE |
Constructor Summary | |
JavaRecognizer()
Creates a new JavaRecognizer object. |
Method Summary | |
void |
attachAnnotations(List annotations)
Attaches the given annotations to the current input source. |
List |
detachAnnotations()
Detaches all annotations. |
String |
getPackageName()
Returns the package name of the parsed source file. |
AST |
getParseTree()
Returns the root node of the generated parse tree. |
Position |
getPosition()
Returns the tracked position information. |
boolean |
hasAnnotations()
Indicates whether the current tree contains annotations. |
boolean |
hasPosition()
Determines whether the current tree contains a node that needs its position to be tracked. |
void |
parse(Reader in,
String filename)
{@inheritDoc} |
void |
setPosition(int line,
int column)
Sets a position in the given input source that should be tracked. |
Methods inherited from class de.hunsicker.jalopy.language.Recognizer |
getColumn, getFileFormat, getLexer, getLine, getParser, isFinished, isRunning, parse, parse, reset, setColumn, setLine |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int JDK_1_3
public static final int JDK_1_4
Constructor Detail |
public JavaRecognizer()
Method Detail |
public String getPackageName()
IllegalStateException
- if the parser is still running or wasn't started
yet.public AST getParseTree()
As we don't use checked exceptions to indicate runtime failures, one may check successful execution of the transformations prior to perform further processing:
if (myJalopyInstance.getState() == Jalopy.State.ERROR) { // transformation failed, errors were already issued; perform // any custom error handling code you need } else { // perform further logic }
getParseTree
in class Recognizer
<JavaNode>
).IllegalStateException
- if the parser is still running or wasn't started
yet.Jalopy.getState()
public void setPosition(int line, int column)
line
- a valid line number (>= 1
).column
- a valid column offset (>= 1
).IllegalArgumentException
- if either line or column
< 1
public Position getPosition()
null
if no position should have been
tracked.public void attachAnnotations(List annotations)
annotations
- list with annotations (of type <Annotation>
).Annotation
,
detachAnnotations()
public List detachAnnotations()
<Annotation>
). Returns an
empty list in case no annotations were attached for the input source.attachAnnotations(java.util.List)
public boolean hasAnnotations()
true
if the tree contains annotations.public boolean hasPosition()
true
if the tree contains a node that needs its position to
be tracked.public void parse(Reader in, String filename)
parse
in class Recognizer
de.hunsicker.jalopy.language.Recognizer
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.
|
Jalopy 1.0b10 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |