org.drools.lang
Class DRLParser

java.lang.Object
  extended by org.drools.lang.DRLParser

public class DRLParser
extends Object


Constructor Summary
DRLParser(org.antlr.runtime.TokenStream input)
           
 
Method Summary
 AttributeDescr attribute()
          attribute := salience | enabled | noLoop | autoFocus | lockOnActive | agendaGroup | activationGroup | ruleflowGroup | dateEffective | dateExpires | dialect | calendars | timer
 String chunk(int leftDelimiter, int rightDelimiter, int location)
          Matches a chunk started by the leftDelimiter and ended by the rightDelimiter.
 PackageDescr compilationUnit()
          Entry point method of a DRL compilation unit compilationUnit := package_statement?
 String conditionalExpression()
          Matches a conditional expression
 String conditionalOrExpression()
          Matches a conditional || expression
 TypeDeclarationDescr declare()
          declare := DECLARE type (EXTENDS type)?
 void disableEditorInterface()
           
 void enableEditorInterface()
           
 FunctionDescr function()
          function := FUNCTION type?
 LinkedList<DroolsSentence> getEditorInterface()
           
 List<String> getErrorMessages()
           
 List<DroolsParserException> getErrors()
           
 ParserHelper getHelper()
           
 GlobalDescr globalStatement()
          globalStatement := GLOBAL type ID SEMICOLON?
 boolean hasErrors()
           
 ImportDescr importStatement()
          importStatement := IMPORT FUNCTION?
 boolean mismatchIsMissingToken(org.antlr.runtime.TokenStream input, int[] follow)
           
 boolean mismatchIsUnwantedToken(org.antlr.runtime.TokenStream input, int ttype, String text)
           
 String packageStatement()
          Parses a package statement and returns the name of the package or null if none is defined.
 String qualifiedIdentifier()
          Matches a qualified identifier qualifiedIdentifier := ID ( DOT ID )*
 RuleDescr query()
          query := QUERY stringId arguments?
protected  org.antlr.runtime.Token recoverFromMismatchedToken(org.antlr.runtime.TokenStream input, int ttype, String text, int[] follow)
          Attempt to recover from a single missing or extra token.
 void reportError(Exception ex)
           
 void reportError(org.antlr.runtime.RecognitionException ex)
           
 RuleDescr rule()
          rule := RULE ruleId (EXTENDS ruleId)?
 BaseDescr statement()
          statement := importStatement | globalStatement | declare | rule | ruleAttribute | function | query ;
 String type()
          Matches a type name type := ID typeArguments?
 String typeArgument()
          Matches a type argument typeArguments := QUESTION (( EXTENDS | SUPER ) type )?
 String typeArguments()
          Matches type arguments typeArguments := LESS typeArgument (COMMA typeArgument)* GREATER
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DRLParser

public DRLParser(org.antlr.runtime.TokenStream input)
Method Detail

getHelper

public ParserHelper getHelper()

hasErrors

public boolean hasErrors()

getErrors

public List<DroolsParserException> getErrors()

getErrorMessages

public List<String> getErrorMessages()

enableEditorInterface

public void enableEditorInterface()

disableEditorInterface

public void disableEditorInterface()

getEditorInterface

public LinkedList<DroolsSentence> getEditorInterface()

reportError

public void reportError(org.antlr.runtime.RecognitionException ex)

reportError

public void reportError(Exception ex)

compilationUnit

public final PackageDescr compilationUnit()
                                   throws org.antlr.runtime.RecognitionException
Entry point method of a DRL compilation unit compilationUnit := package_statement? statement*

Returns:
a PackageDescr with the content of the whole compilation unit
Throws:
org.antlr.runtime.RecognitionException

packageStatement

public String packageStatement()
                        throws org.antlr.runtime.RecognitionException
Parses a package statement and returns the name of the package or null if none is defined. packageStatement := PACKAGE qualifiedIdentifier SEMICOLON?

Returns:
the name of the package or null if none is defined
Throws:
org.antlr.runtime.RecognitionException

statement

public BaseDescr statement()
                    throws org.antlr.runtime.RecognitionException
statement := importStatement | globalStatement | declare | rule | ruleAttribute | function | query ;

Throws:
org.antlr.runtime.RecognitionException

importStatement

public ImportDescr importStatement()
                            throws org.antlr.runtime.RecognitionException
importStatement := IMPORT FUNCTION? qualifiedIdentifier (DOT STAR)? SEMICOLON?

Returns:
Throws:
org.antlr.runtime.RecognitionException

globalStatement

public GlobalDescr globalStatement()
                            throws org.antlr.runtime.RecognitionException
globalStatement := GLOBAL type ID SEMICOLON?

Returns:
Throws:
org.antlr.runtime.RecognitionException

declare

public TypeDeclarationDescr declare()
                             throws org.antlr.runtime.RecognitionException
declare := DECLARE type (EXTENDS type)? annotation* field* END SEMICOLON?

Returns:
Throws:
org.antlr.runtime.RecognitionException

function

public FunctionDescr function()
                       throws org.antlr.runtime.RecognitionException
function := FUNCTION type? ID arguments curly_chunk

Returns:
Throws:
org.antlr.runtime.RecognitionException

query

public RuleDescr query()
                throws org.antlr.runtime.RecognitionException
query := QUERY stringId arguments? annotation* lhs END

Returns:
Throws:
org.antlr.runtime.RecognitionException

rule

public RuleDescr rule()
               throws org.antlr.runtime.RecognitionException
rule := RULE ruleId (EXTENDS ruleId)? annotation* attributes? lhs? rhs END

Returns:
Throws:
org.antlr.runtime.RecognitionException

attribute

public AttributeDescr attribute()
attribute := salience | enabled | noLoop | autoFocus | lockOnActive | agendaGroup | activationGroup | ruleflowGroup | dateEffective | dateExpires | dialect | calendars | timer

Returns:

type

public String type()
            throws org.antlr.runtime.RecognitionException
Matches a type name type := ID typeArguments? ( DOT ID typeArguments? )* (LEFT_SQUARE RIGHT_SQUARE)*

Parameters:
doQualify - set to true if qualification is acceptable
doGenPar - set to true if generic arguments and brackets are acceptable
Returns:
Throws:
org.antlr.runtime.RecognitionException

typeArguments

public String typeArguments()
                     throws org.antlr.runtime.RecognitionException
Matches type arguments typeArguments := LESS typeArgument (COMMA typeArgument)* GREATER

Returns:
Throws:
org.antlr.runtime.RecognitionException

typeArgument

public String typeArgument()
                    throws org.antlr.runtime.RecognitionException
Matches a type argument typeArguments := QUESTION (( EXTENDS | SUPER ) type )? | type ;

Returns:
Throws:
org.antlr.runtime.RecognitionException

qualifiedIdentifier

public String qualifiedIdentifier()
                           throws org.antlr.runtime.RecognitionException
Matches a qualified identifier qualifiedIdentifier := ID ( DOT ID )*

Returns:
Throws:
org.antlr.runtime.RecognitionException

conditionalExpression

public String conditionalExpression()
                             throws org.antlr.runtime.RecognitionException
Matches a conditional expression

Returns:
Throws:
org.antlr.runtime.RecognitionException

conditionalOrExpression

public String conditionalOrExpression()
                               throws org.antlr.runtime.RecognitionException
Matches a conditional || expression

Returns:
Throws:
org.antlr.runtime.RecognitionException

chunk

public String chunk(int leftDelimiter,
                    int rightDelimiter,
                    int location)
Matches a chunk started by the leftDelimiter and ended by the rightDelimiter.

Parameters:
leftDelimiter -
rightDelimiter -
location -
Returns:
the matched chunk without the delimiters

recoverFromMismatchedToken

protected org.antlr.runtime.Token recoverFromMismatchedToken(org.antlr.runtime.TokenStream input,
                                                             int ttype,
                                                             String text,
                                                             int[] follow)
                                                      throws org.antlr.runtime.RecognitionException
Attempt to recover from a single missing or extra token. EXTRA TOKEN LA(1) is not what we are looking for. If LA(2) has the right token, however, then assume LA(1) is some extra spurious token. Delete it and LA(2) as if we were doing a normal match(), which advances the input. MISSING TOKEN If current token is consistent with what could come after ttype then it is ok to "insert" the missing token, else throw exception For example, Input "i=(3;" is clearly missing the ')'. When the parser returns from the nested call to expr, it will have call chain: stat -> expr -> atom and it will be trying to match the ')' at this point in the derivation: => ID '=' '(' INT ')' ('+' atom)* ';' ^ match() will see that ';' doesn't match ')' and report a mismatched token error. To recover, it sees that LA(1)==';' is in the set of tokens that can follow the ')' token reference in rule atom. It can assume that you forgot the ')'.

Throws:
org.antlr.runtime.RecognitionException

mismatchIsUnwantedToken

public boolean mismatchIsUnwantedToken(org.antlr.runtime.TokenStream input,
                                       int ttype,
                                       String text)

mismatchIsMissingToken

public boolean mismatchIsMissingToken(org.antlr.runtime.TokenStream input,
                                      int[] follow)


Copyright © 2001-2011 JBoss Inc.. All Rights Reserved.