|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface INRLParser
An INRLParser is a parser that can return a fully-resolved NRL abstract syntax tree.
The way this is normally used is as follows:
parse(InputStream)
to read in an AST
getErrors()
, which may return a mixture of syntax and
semantic errors if any occurred. If so, the AST is unsafe and the errors need
to be displayed to a user (or some other processing).
resolveModelReferences(IRuleFile, IModelCollection)
to resolve
model references in the AST. Without this, no model information can be
accessed through the AST.
getErrors()
again to check if any errors occurred during
model processing. If so, the AST is unsafe and needs to be discarded.
The reason why parsing and resolving, and on the other hand resolving against a model are kept separate is that the basic AST can be validated even before a model is available, for example in an editor. For any sort of processing, a full resolution against the model should be performed.
Method Summary | |
---|---|
List<NRLError> |
getErrors()
Returns a collection of SyntaxError
and SemanticError objects. |
IRuleFile |
parse(InputStream stream)
Parse an input stream and construct an AST. |
IRuleFile |
parse(Reader reader)
Alternative method for readers instead of streams |
void |
resolveModelReferences(IRuleFile ruleFile,
IModelCollection models)
Resolve model reference in the AST by looking up model elements. |
void |
resolveOperatorReferences(IRuleFile ruleFile,
IOperators[] operators)
Resolve operator references in the AST by looking up operator definitions in a collection of operators. |
Method Detail |
---|
IRuleFile parse(InputStream stream) throws Exception
getErrors()
to get a list of
parsing errors
If no check on errors is made after parsing, the AST is unstable and will cause null pointer and other exceptions.
stream
- the stream to read from
Exception
- if a severe error occurred. The result is that even
getErrors()
will not return a meaningful result.IRuleFile parse(Reader reader) throws Exception
reader
- the reader to use for parsing
Exception
void resolveModelReferences(IRuleFile ruleFile, IModelCollection models)
parse(InputStream)
, if no errors occurred.
After a call to this method, getErrors()
may contain a number of
semantic errors where model references could not be looked up.
ruleFile
- the rule file to resolvemodels
- the models to look atvoid resolveOperatorReferences(IRuleFile ruleFile, IOperators[] operators)
parse(InputStream)
, and after
resolveModelReferences(IRuleFile, IModelCollection)
, if no errors
occurred.
This call is kept separate to enable callers to check operator references separately - because missing definitions may or may not be treated as errors depending on the state of the rule file.
After a call to this, getErrors()
will contain semantic error
objects if any operators could not be resolved properly.
ruleFile
- the file to resolveoperators
- the collection of operator filesList<NRLError> getErrors()
SyntaxError
and SemanticError
objects. This is
intended for use after parse(InputStream)
, and returns a
different result after every call to parse.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |