no viable alternative at input ''

807 views
Skip to first unread message

Евгений Мартын

unread,
Oct 26, 2015, 11:01:44 AM10/26/15
to Drools Setup
I am trying to write the file dsl.

in file DSLconway.dsl:

  [condition][theCell]Cell=Cell(  )
  [condition][]− neighbors {i}=liveNeighbors < {i}
  [condition][]− live=cellState == CellState.LIVE
  [condition][]− evaluate=phase == Phase.EVALUATE

in file conway-ruleflow.drl:

  rule "Kill The Lonely"
      ruleflow-group "evaluate"
      no-loop
  when
  //    A live cell has fewer than 2 live neighbors
  //    theCell: Cell(liveNeighbors < 2, cellState == CellState.LIVE, phase == Phase.EVALUATE)

      Cell
          − neighbors 2
          − live
          − evaluate

  then
      modify( theCell ) {setPhase(Phase.KILL)}
  end

when I run the program in the console:

[main] ERROR org.drools.compiler.kie.builder.impl.AbstractKieModule - Unable to build KieBaseModel:defaultKieBase
[5,13]: DSL lexer error
[6,13]: DSL lexer error
[7,13]: DSL lexer error
[20,2]: [ERR 101] Line 20:2 no viable alternative at input ''
[21,2]: [ERR 101] Line 21:2 no viable alternative at input ''
[22,2]: [ERR 101] Line 22:2 no viable alternative at input ''
[20,4]: [ERR 102] Line 20:4 mismatched input 'neighbors' in rule "Kill The Lonely"
[0,0]: Parser returned a null Package

Exception in thread "main" java.lang.RuntimeException: Build Errors:
Error Messages:
Message [id=1, level=ERROR, path=null, line=5, column=0
   text=DSL lexer error]
Message [id=2, level=ERROR, path=null, line=6, column=0
   text=DSL lexer error]
Message [id=3, level=ERROR, path=null, line=7, column=0
   text=DSL lexer error]
Message [id=4, level=ERROR, path=org/drools/example/conway/ruleflow/conway-ruleflow.drl, line=20, column=0
   text=[ERR 101] Line 20:2 no viable alternative at input '']
Message [id=5, level=ERROR, path=org/drools/example/conway/ruleflow/conway-ruleflow.drl, line=21, column=0
   text=[ERR 101] Line 21:2 no viable alternative at input '']
Message [id=6, level=ERROR, path=org/drools/example/conway/ruleflow/conway-ruleflow.drl, line=22, column=0
   text=[ERR 101] Line 22:2 no viable alternative at input '']
Message [id=7, level=ERROR, path=org/drools/example/conway/ruleflow/conway-ruleflow.drl, line=20, column=0
   text=[ERR 102] Line 20:4 mismatched input 'neighbors' in rule "Kill The Lonely"]
Message [id=8, level=ERROR, path=org/drools/example/conway/ruleflow/conway-ruleflow.drl, line=0, column=0
   text=Parser returned a null Package]
---
Warning Messages:
---
Info Messages:

    at org.drools.examples.conway.RuleFlowDelegate.<init>(RuleFlowDelegate.java:88)
    at org.drools.examples.conway.CellGridImpl.<init>(CellGridImpl.java:51)
    at org.drools.examples.conway.ui.ConwayGUI.<init>(ConwayGUI.java:61)
    at org.drools.examples.conway.AbstractRunConway.start(AbstractRunConway.java:32)
    at org.drools.examples.conway.ConwayRuleFlowGroupRun.init(ConwayRuleFlowGroupRun.java:26)
    at org.drools.examples.conway.ConwayRuleFlowGroupRun.main(ConwayRuleFlowGroupRun.java:22)

what am I doing wrong?

Marian Buenosayres

unread,
Nov 8, 2015, 10:11:59 AM11/8/15
to Drools Setup
I think you need to add an expander declaration before the rule like this

expander DSLconway.dsl

But I'm not sure if it's needed for Drools 6
Reply all
Reply to author
Forward
0 new messages