|
||||||||||
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)
Deprecated. Use parse(URI, IResolverFactory) |
IRuleFile |
parse(Reader reader)
Deprecated. Use parse(URI, IResolverFactory) |
IRuleFile |
parse(URI uri,
IResolverFactory resolverFactory)
Parse an input stream and construct an AST. |
void |
resolveModelReferences(IRuleFile ruleFile,
IModelCollection models)
Deprecated. Use parse(URI, IResolverFactory) |
void |
resolveOperatorReferences(IRuleFile ruleFile,
IOperators[] operators)
Deprecated. Use parse(URI, IResolverFactory) |
Method Detail |
---|
@Deprecated IRuleFile parse(InputStream stream) throws Exception
parse(URI, IResolverFactory)
Exception
@Deprecated IRuleFile parse(Reader reader) throws Exception
parse(URI, IResolverFactory)
Exception
IRuleFile parse(URI uri, IResolverFactory resolverFactory) throws IOException, org.antlr.runtime.RecognitionException, ResolverException, ModelLoadingException, OperatorLoadingException
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.
uri
- the NRL file URIresolverFactory
- the factory to use to load additional resources
IOException
org.antlr.runtime.RecognitionException
ResolverException
ModelLoadingException
OperatorLoadingException
@Deprecated void resolveModelReferences(IRuleFile ruleFile, IModelCollection models)
parse(URI, IResolverFactory)
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 at@Deprecated void resolveOperatorReferences(IRuleFile ruleFile, IOperators[] operators)
parse(URI, IResolverFactory)
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 |