net.sourceforge.nrl.parser
Class NRLParser

java.lang.Object
  extended by net.sourceforge.nrl.parser.NRLParser
All Implemented Interfaces:
INRLParser

public class NRLParser
extends Object
implements INRLParser

The main parser interface for creating an NRL AST. This supports both the action and constraint language, and is based on ANTLR.

See Also:
INRLParser

Constructor Summary
NRLParser()
           
 
Method Summary
 List<NRLError> getErrors()
          After any call to the parse or resolve methods, this method returns a list of errors, if any.
protected  String getStreamAsString(Reader reader)
          Uses a reader to read a stream and returns the content as a string.
 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 NRL file using a reader, and return an AST.
 void resolveModelReferences(IRuleFile ruleFile, IModelCollection models)
          Deprecated. 
 void resolveOperatorReferences(IRuleFile ruleFile, IOperators[] operators)
          Deprecated. 
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NRLParser

public NRLParser()
Method Detail

getErrors

public List<NRLError> getErrors()
After any call to the parse or resolve methods, this method returns a list of errors, if any.

Specified by:
getErrors in interface INRLParser
Returns:
the collection of errors, empty if no errors occurred

getStreamAsString

protected String getStreamAsString(Reader reader)
                            throws IOException
Uses a reader to read a stream and returns the content as a string.

Parameters:
reader - the reader
Returns:
the content
Throws:
IOException

parse

@Deprecated
public IRuleFile parse(InputStream stream)
                throws Exception
Deprecated. Use parse(URI, IResolverFactory)

Specified by:
parse in interface INRLParser
Throws:
Exception

parse

@Deprecated
public IRuleFile parse(Reader reader)
                throws Exception
Deprecated. Use parse(URI, IResolverFactory)

Specified by:
parse in interface INRLParser
Throws:
Exception

parse

public IRuleFile parse(URI uri,
                       IResolverFactory resolverFactory)
                throws IOException,
                       org.antlr.runtime.RecognitionException,
                       ModelLoadingException,
                       ResolverException,
                       OperatorLoadingException
Parse an NRL file using a reader, and return an AST. The AST will already be fully resolved and checked for basic semantic errors, as well as having model information attached.

IMPORTANT: Call getErrors() after calling this method to check if any syntax or semantic errors occurred.

Specified by:
parse in interface INRLParser
Parameters:
reader - the reader to use
resolverFactory - the resolver factory to use to load resources
Returns:
the rule file or null
Throws:
IOException
org.antlr.runtime.RecognitionException
ModelLoadingException
ResolverException
OperatorLoadingException
Since:
1.4.9

resolveModelReferences

@Deprecated
public void resolveModelReferences(IRuleFile ruleFile,
                                              IModelCollection models)
Deprecated. 

Attach model information to a parsed rule file AST. This traverses the AST and decorates any model references with actual elements from the model.

After calling this, you must call getErrors() to check if any errors occurred. If so, the AST may be unstable.

Specified by:
resolveModelReferences in interface INRLParser
Parameters:
ruleFile - the rule file to decorate
models - the models to use

resolveOperatorReferences

@Deprecated
public void resolveOperatorReferences(IRuleFile ruleFile,
                                                 IOperators[] operators)
Deprecated. 

Resolve reference to operator invocations given an operator collection. The operator collection has to be loaded separately from an XML descriptor file, if one is available.

Specified by:
resolveOperatorReferences in interface INRLParser
Parameters:
ruleFile - the file to resolve
operators - the collection of operator files
See Also:
XmlOperatorPersistence


Copyright © 2006-2013. All Rights Reserved.