[rules-users] DrlParser problem with soundslike and matches

Bruno Freudensprung bruno.freudensprung at temis.com
Mon Oct 18 11:55:02 EDT 2010


Hi Wolfgang,

Many thanks for you answer! I finally decided to download Drools sources 
in order to debug my program.
Following your advice (starting from EvaluatorRegistry), I finally found 
that adding a simple "PackageBuilder builder = new PackageBuilder();" 
statement at the beginning of my program does the trick. For a reason 
that I don't understand (maybe a ClassLoader or static initialization 
side-effect), even though that "builder" variable is not used 
afterwards, it helps my DrlParser accepting the "matches" operator.
So the final code is (for those interested in):

        PackageBuilder builder = new PackageBuilder(); // not used
        Resource brlresource = 
ResourceFactory.newClassPathResource("com/sample/TestRule.brl");
        BusinessRuleProvider provider = 
BusinessRuleProviderFactory.getInstance().getProvider();
        Reader knowledge = provider.getKnowledgeReader(brlresource);
        DrlParser parser = new DrlParser();
        PackageDescr pkg = parser.parse(knowledge);

Cheers,

Bruno.


Wolfgang Laun a écrit :
> All the operators that are represented as Keywords must be made known
> to the parser;
> this includes all the predefined ones. This is done in class EvaluatorRegistry..
> See org/drools/base/evaluators/EvaluatorRegistry,java and
> org/drools/compiler/PackageBuilderConfiguration.java.
>
> Best
> -W
>
>
>
> On 18 October 2010 11:05, Bruno Freudensprung
> <bruno.freudensprung at temis.com> wrote:
>   
>> Hi,
>>
>> I am using Drools 5.1.1 (but also tried with 5.2.0.SNAPSHOT) to achieve
>> the following scenario:
>> 1 - use the Drools' Eclipse graphical rule editor to create a BRL file
>> 2 - convert the BRL to DRL using the
>> org.drools.ide.common.server.util.BRXMLPersistence and
>> org.drools.ide.common.server.util.BRDRLPersistence classes
>> 3 - parse the DRL with the org.drools.compiler.DrlParser class (in order
>> to do some things)
>>
>> I have a problem with DrlParser class that does not seem to accept the
>> "matches" and "soundslike" operators.
>> With the following rule... :
>>
>> rule "TestRule"
>>    dialect "mvel"
>>    when
>>        Document( text soundslike "drink" )
>>    then
>>        // some
>> end
>>
>> ... I get that error message from the DrlParser:
>>
>> src/main/resources/org/drools/lang/DescrBuilderTree.g: node from line
>> 0:0 mismatched tree node: <unexpected:
>> [@15,55:64='soundslike',<83>,4:17], resync=soundslike> expecting <UP>
>>
>> Does anyone has an idea of what's going on?
>> Many thanks,
>>
>> Bruno.
>> _______________________________________________
>> rules-users mailing list
>> rules-users at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
>>     
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>   

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20101018/23bd17ba/attachment.html 


More information about the rules-users mailing list