use of org.drools.drl.ast.dsl.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;
}
use of org.drools.drl.ast.dsl.ImportDescrBuilder in project drools by kiegroup.
the class PackageDescrBuilderImpl method newFunctionImport.
public ImportDescrBuilder newFunctionImport() {
ImportDescrBuilder impl = new ImportDescrBuilderImpl(this, true);
descr.addFunctionImport((FunctionImportDescr) initDescr(impl));
return impl;
}
use of org.drools.drl.ast.dsl.ImportDescrBuilder in project drools by kiegroup.
the class DRL6Parser method importStatement.
/* ------------------------------------------------------------------------------------------------
* IMPORT STATEMENT
* ------------------------------------------------------------------------------------------------ */
/**
* importStatement := IMPORT ((FUNCTION|STATIC)? qualifiedIdentifier ((DOT STAR)?
* |(ACC|ACCUMULATE) qualifiedIdentifier ID)
*
* @return
* @throws org.antlr.runtime.RecognitionException
*/
public ImportDescr importStatement(PackageDescrBuilder pkg) throws RecognitionException {
try {
String kwd;
if (helper.validateLT(2, kwd = DroolsSoftKeywords.ACC) || helper.validateLT(2, kwd = DroolsSoftKeywords.ACCUMULATE)) {
AccumulateImportDescrBuilder imp = helper.start(pkg, AccumulateImportDescrBuilder.class, null);
try {
// import
match(input, DRL6Lexer.ID, DroolsSoftKeywords.IMPORT, null, DroolsEditorType.KEYWORD);
if (state.failed)
return null;
// import accumulate
match(input, DRL6Lexer.ID, kwd, null, DroolsEditorType.KEYWORD);
if (state.failed)
return null;
// qualifiedIdentifier
String target = qualifiedIdentifier();
if (state.failed)
return null;
// function name
Token id = match(input, DRL6Lexer.ID, null, null, DroolsEditorType.IDENTIFIER);
if (state.failed)
return null;
if (state.backtracking == 0) {
imp.target(target).functionName(id.getText());
}
return (imp != null) ? imp.getDescr() : null;
} finally {
helper.end(AccumulateImportDescrBuilder.class, imp);
}
} else {
ImportDescrBuilder imp = helper.start(pkg, ImportDescrBuilder.class, null);
try {
// import
match(input, DRL6Lexer.ID, DroolsSoftKeywords.IMPORT, null, DroolsEditorType.KEYWORD);
if (state.failed)
return null;
if (helper.validateIdentifierKey(kwd = DroolsSoftKeywords.FUNCTION) || helper.validateIdentifierKey(kwd = DroolsSoftKeywords.STATIC)) {
// function
match(input, DRL6Lexer.ID, kwd, null, DroolsEditorType.KEYWORD);
if (state.failed)
return null;
}
// qualifiedIdentifier
String target = qualifiedIdentifier();
if (state.failed)
return null;
if (input.LA(1) == DRL6Lexer.DOT && input.LA(2) == DRL6Lexer.STAR) {
// .*
match(input, DRL6Lexer.DOT, null, null, DroolsEditorType.IDENTIFIER);
if (state.failed)
return null;
match(input, DRL6Lexer.STAR, null, null, DroolsEditorType.IDENTIFIER);
if (state.failed)
return null;
target += ".*";
}
if (state.backtracking == 0)
imp.target(target);
return (imp != null) ? imp.getDescr() : null;
} finally {
helper.end(ImportDescrBuilder.class, imp);
}
}
} catch (RecognitionException re) {
reportError(re);
}
return null;
}
use of org.drools.drl.ast.dsl.ImportDescrBuilder in project drools by kiegroup.
the class DRL6StrictParser method importStatement.
/* ------------------------------------------------------------------------------------------------
* IMPORT STATEMENT
* ------------------------------------------------------------------------------------------------ */
/**
* importStatement := IMPORT ((FUNCTION|STATIC)? qualifiedIdentifier ((DOT STAR)?
* |(ACC|ACCUMULATE) qualifiedIdentifier ID)
*
* @return
* @throws org.antlr.runtime.RecognitionException
*/
public ImportDescr importStatement(PackageDescrBuilder pkg) throws RecognitionException {
try {
String kwd;
if (helper.validateLT(2, kwd = DroolsSoftKeywords.ACC) || helper.validateLT(2, kwd = DroolsSoftKeywords.ACCUMULATE)) {
AccumulateImportDescrBuilder imp = helper.start(pkg, AccumulateImportDescrBuilder.class, null);
try {
// import
match(input, DRL6Lexer.ID, DroolsSoftKeywords.IMPORT, null, DroolsEditorType.KEYWORD);
if (state.failed)
return null;
// import accumulate
match(input, DRL6Lexer.ID, kwd, null, DroolsEditorType.KEYWORD);
if (state.failed)
return null;
// qualifiedIdentifier
String target = qualifiedIdentifier();
if (state.failed)
return null;
// function name
Token id = match(input, DRL6Lexer.ID, null, null, DroolsEditorType.IDENTIFIER);
if (state.failed)
return null;
if (state.backtracking == 0) {
imp.target(target).functionName(id.getText());
}
return (imp != null) ? imp.getDescr() : null;
} finally {
helper.end(AccumulateImportDescrBuilder.class, imp);
}
} else {
ImportDescrBuilder imp = helper.start(pkg, ImportDescrBuilder.class, null);
try {
// import
match(input, DRL6Lexer.ID, DroolsSoftKeywords.IMPORT, null, DroolsEditorType.KEYWORD);
if (state.failed)
return null;
if (helper.validateIdentifierKey(kwd = DroolsSoftKeywords.FUNCTION) || helper.validateIdentifierKey(kwd = DroolsSoftKeywords.STATIC)) {
// function
match(input, DRL6Lexer.ID, kwd, null, DroolsEditorType.KEYWORD);
if (state.failed)
return null;
}
// qualifiedIdentifier
String target = qualifiedIdentifier();
if (state.failed)
return null;
if (input.LA(1) == DRL6Lexer.DOT && input.LA(2) == DRL6Lexer.STAR) {
// .*
match(input, DRL6Lexer.DOT, null, null, DroolsEditorType.IDENTIFIER);
if (state.failed)
return null;
match(input, DRL6Lexer.STAR, null, null, DroolsEditorType.IDENTIFIER);
if (state.failed)
return null;
target += ".*";
}
if (state.backtracking == 0)
imp.target(target);
return (imp != null) ? imp.getDescr() : null;
} finally {
helper.end(ImportDescrBuilder.class, imp);
}
}
} catch (RecognitionException re) {
reportError(re);
}
return null;
}
use of org.drools.drl.ast.dsl.ImportDescrBuilder in project drools by kiegroup.
the class PackageDescrBuilderImpl method newImport.
public ImportDescrBuilder newImport() {
ImportDescrBuilder impl = new ImportDescrBuilderImpl(this, false);
descr.addImport(initDescr(impl));
return impl;
}
Aggregations