title: Drools - Grouping multiple dsl conditions in dslr's when part throws error
body: <p>Am creating a small rule engine and using drools for it. My design is like the developer (that's me :)) will develop dsl and a business user can create rules (dslr).</p>
  
  <p><strong>dsl file</strong></p>
  
  <pre><code>[When]When [Pp]urchase amount is greater than "{Value}" = e : Event(EventAction.isPurchaseGreaterThan(e,{Value}))
  [When]If [Cc]ustomer tier equals to "{CustomerTier}"=e1 : Event(EventAction.isCustomerTierEqualTo(e1,"{CustomerTier}")
  [Then]Give "{Discount}" Percentage Discount = RewardAction.applyDiscount(e, {Discount});
  [Then]Suggest Redemption = System.out.println("Redemption Suggested");
  </code></pre>
  
  <p><strong>dslr file</strong></p>
  
  <pre><code>rule "Discount For Purchase-1"
      when (When purchase amount is greater than "100") &amp;&amp; (If customer tier equals to "Silver")
      then     #Error is thrown in this line
          Give "5" Percentage Discount 
  end 
  </code></pre>
  
  <p>The rest of the java code is similar to the one given in examples. In this code am getting the following error</p>
  
  <p><strong>Error</strong></p>
  
  <pre><code>Line 15:4 mismatched input 'then' in rule "Discount For Purchase-1"
  </code></pre>
  
  <p>Whereas the below dslr works fine</p>
  
  <pre><code>rule "Discount For Purchase-1"
      when (When purchase amount is greater than "100")
      then
          Give "5" Percentage Discount 
  end 
  </code></pre>
  
  <p><strong>Generated DRL</strong></p>
  
  <pre><code>when (e : Event(EventAction.isPurchaseGreaterThan(e,100))) &amp;&amp; (e : Event(EventAction.isCustomerTierEqualTo(e,"Silver"))
  </code></pre>
  
  <p><strong>Note on this Generated DRL</strong> - I might get duplicate variable error for 'e'. That's another problem. But just to sort out this problem i've even tried modifing the second variable to 'e1' in dsl. </p>
  
  <p>And for your information i've tried the below to resolve the error, but noting helped me out</p>
  
  <pre><code>When (When purchase amount is greater than "100" &amp;&amp; If customer tier equals to "Silver")
  When (When purchase amount is greater than "100" and If customer tier equals to "Silver")
  When ((When purchase amount is greater than "100") &amp;&amp; (If customer tier equals to "Silver"))
  When ((When purchase amount is greater than "100") and (If customer tier equals to "Silver"))
  When ((When purchase amount is greater than "100") and (If customer tier equals to "Silver"));
  When ((When purchase amount is greater than "100") &amp;&amp; (If customer tier equals to "Silver"));
  </code></pre>
  
  <p><strong>Update :</strong></p>
  
  <p><strong>Generated drl</strong></p>
  
  <pre><code>=== DRL xpanded from DSLR ===
     1  #created on: 5 Oct, 2016
     2  package com.test.loyalty.rules
     3  
     4  #list any import classes here.
     5  import com.test.loyalty.*
     6  import com.test.loyalty.model.*
     7  import com.test.loyalty.util.*
     8  
     9  
    10  
    11  #declare any global variables here
    12  
    13  rule "Discount For Purchase-1"
    14      when 
    15        e : Event(EventAction.isPurchaseGreaterThan(e,100))
    16        e1 : Event(EventAction.isCustomerTierEqualTo(e1,"Silver")
    17      then
    18          System.out.println("Redemption Suggested"); 
    19  end
    20  
    21  rule "Discount For Purchase-2"
    22      when
    23          e : Event(EventAction.isPurchaseGreaterThan(e,100))
    24        e1 : Event(EventAction.isCustomerTierEqualTo(e1,"Gold")
    25      then
    26          System.out.println("Redemption Suggested"); 
    27  end
    28  
  
  
  =============================
  [ERR 102] Line 17:4 mismatched input 'then' in rule "Discount For Purchase-1"
  17
  [ERR 102] Line 25:4 mismatched input 'then' in rule "Discount For Purchase-2"
  25
  java.lang.IllegalArgumentException: Could not parse knowledge.
      at com.test.loyalty.LoyaltyTest.readKnowledgeBase(LoyaltyTest.java:124)
      at com.test.loyalty.LoyaltyTest.init(LoyaltyTest.java:104)
      at com.test.loyalty.LoyaltyTest.main(LoyaltyTest.java:38)
  </code></pre>
  
  <p>can somebody help me with this? Thanks in advance.</p>