use of org.drools.compiler.lang.api.ImportDescrBuilder in project drools by kiegroup.
the class DRL5Parser method importStatement.
/* ------------------------------------------------------------------------------------------------
* IMPORT STATEMENT
* ------------------------------------------------------------------------------------------------ */
/**
* importStatement := IMPORT (FUNCTION|STATIC)? qualifiedIdentifier (DOT STAR)?
*
* @return
* @throws RecognitionException
*/
public ImportDescr importStatement(PackageDescrBuilder pkg) throws RecognitionException {
ImportDescrBuilder imp = null;
try {
imp = helper.start(pkg, ImportDescrBuilder.class, null);
// import
match(input, DRL5Lexer.ID, DroolsSoftKeywords.IMPORT, null, DroolsEditorType.KEYWORD);
if (state.failed)
return null;
String kwd;
if (helper.validateIdentifierKey(kwd = DroolsSoftKeywords.FUNCTION) || helper.validateIdentifierKey(kwd = DroolsSoftKeywords.STATIC)) {
// function
match(input, DRL5Lexer.ID, kwd, null, DroolsEditorType.KEYWORD);
if (state.failed)
return null;
}
// qualifiedIdentifier
String target = qualifiedIdentifier();
if (state.failed)
return null;
if (input.LA(1) == DRL5Lexer.DOT && input.LA(2) == DRL5Lexer.STAR) {
// .*
match(input, DRL5Lexer.DOT, null, null, DroolsEditorType.IDENTIFIER);
if (state.failed)
return null;
match(input, DRL5Lexer.STAR, null, null, DroolsEditorType.IDENTIFIER);
if (state.failed)
return null;
target += ".*";
}
if (state.backtracking == 0)
imp.target(target);
} catch (RecognitionException re) {
reportError(re);
} finally {
helper.end(ImportDescrBuilder.class, imp);
}
return (imp != null) ? imp.getDescr() : null;
}
Aggregations