use of org.drools.drl.parser.lang.DRLParser in project drools by kiegroup.
the class DrlParser method parse.
public PackageDescr parse(final boolean isEditor, final Reader reader) throws DroolsParserException {
lexer = DRLFactory.buildLexer(reader, languageLevel);
DRLParser parser = DRLFactory.buildParser(lexer, languageLevel);
return compile(isEditor, parser);
}
use of org.drools.drl.parser.lang.DRLParser in project drools by kiegroup.
the class DrlParser method parse.
public PackageDescr parse(final boolean isEditor, final Resource resource, final InputStream is) throws DroolsParserException, IOException {
this.resource = resource;
String encoding = resource instanceof InternalResource ? ((InternalResource) resource).getEncoding() : null;
lexer = DRLFactory.buildLexer(is, encoding, languageLevel);
DRLParser parser = DRLFactory.buildParser(lexer, languageLevel);
return compile(isEditor, parser);
}
use of org.drools.drl.parser.lang.DRLParser in project drools by kiegroup.
the class DRLContextTest method testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT.
@Test(timeout = 10 * 1000)
public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT() {
String input = "rule MyRule \n" + " when \n" + " Class ( property > 0 ) from accumulate( \n" + " $cheese : Cheese( type == ";
DRLParser parser = getParser(input);
parser.enableEditorInterface();
try {
parser.compilationUnit();
} catch (Exception ex) {
}
assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT, getLastIntegerValue(parser.getEditorInterface().get(0).getContent()));
}
use of org.drools.drl.parser.lang.DRLParser in project drools by kiegroup.
the class DRLContextTest method testCheckRuleHeaderLocationDetermination2.
@Test(timeout = 10 * 1000)
public void testCheckRuleHeaderLocationDetermination2() {
String input = "rule MyRule \n" + " salience 12 activation-group \"my";
DRLParser parser = getParser(input);
parser.enableEditorInterface();
try {
parser.compilationUnit();
} catch (Exception ex) {
}
DroolsToken token = getLastTokenOnList(parser.getEditorInterface().get(0).getContent());
assertEquals("group", token.getText().toLowerCase());
assertEquals(DroolsEditorType.KEYWORD, token.getEditorType());
assertEquals(Location.LOCATION_RULE_HEADER_KEYWORD, getLastIntegerValue(parser.getEditorInterface().get(0).getContent()));
}
use of org.drools.drl.parser.lang.DRLParser in project drools by kiegroup.
the class DRLContextTest method testCheckLHSLocationDetermination_FROM6.
@Test(timeout = 10 * 1000)
public void testCheckLHSLocationDetermination_FROM6() {
String input = "rule MyRule \n" + " when \n" + " ArrayList(size > 50) from accumulate( Person( disabled == \"yes\", income > 100000 ) from ";
DRLParser parser = getParser(input);
parser.enableEditorInterface();
try {
parser.compilationUnit();
} catch (Exception ex) {
}
assertEquals(Location.LOCATION_LHS_FROM, getLastIntegerValue(parser.getEditorInterface().get(0).getContent()));
}
Aggregations