Discussion:
Understanding "no viable alternative ..." errors
Pritam
2010-01-13 17:09:07 UTC
Permalink
While executing the following rule,

rule "home dummy"
when
pointId: Point(page == "home", region ="center-content")
content: Content(id=="adslot")
properties["type"]=="ad" from content
then
filter.put(content.id, true);
end

I get the following error:
[ERR 101] Line 16:46 no viable alternative at input 'EQUALS' in rule "home
dummy" in pattern PointId[18,16]: [ERR 102] Line 18:16 mismatched input
'"type"' expecting ']' in rule "home dummy" in pattern properties

The documentation explains that this is the most common error but I still
struggle to understand the correct grammar for writing rules. Can anyone
point me to a good resource (I even read the book "drools 5) for writing the
following rule in a drl format?

" If a Point has a page, "home" and region, "center-content" and the Content
id is "adslot" with a property, type as "ad" then filter the Content (using
a global map and passing a boolean flag)

Thanks
--
View this message in context: http://n3.nabble.com/Understanding-no-viable-alternative-errors-tp119375p119375.html
Sent from the Drools - User mailing list archive at Nabble.com.
Esteban Aliverti
2010-01-13 17:13:54 UTC
Permalink
Did you miss an = sign in region??

rule "home dummy"
when
pointId: Point(page == "home", region =*=*"center-content")
content: Content(id=="adslot")
properties["type"]=="ad" from content
then
filter.put(content.id, true);
end

Best,
Post by Pritam
While executing the following rule,
rule "home dummy"
when
pointId: Point(page == "home", region ="center-content")
content: Content(id=="adslot")
properties["type"]=="ad" from content
then
filter.put(content.id, true);
end
[ERR 101] Line 16:46 no viable alternative at input 'EQUALS' in rule "home
dummy" in pattern PointId[18,16]: [ERR 102] Line 18:16 mismatched input
'"type"' expecting ']' in rule "home dummy" in pattern properties
The documentation explains that this is the most common error but I still
struggle to understand the correct grammar for writing rules. Can anyone
point me to a good resource (I even read the book "drools 5) for writing the
following rule in a drl format?
" If a Point has a page, "home" and region, "center-content" and the Content
id is "adslot" with a property, type as "ad" then filter the Content (using
a global map and passing a boolean flag)
Thanks
--
http://n3.nabble.com/Understanding-no-viable-alternative-errors-tp119375p119375.html
Sent from the Drools - User mailing list archive at Nabble.com.
_______________________________________________
rules-users mailing list
https://lists.jboss.org/mailman/listinfo/rules-users
--
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Esteban Aliverti
David Sinclair
2010-01-13 17:15:01 UTC
Permalink
You are missing another = sign for your region check, i.e. pointId:
Point(page == "home", region == "center-content")

Also, is there a join between the Point and the Content? Otherwise you'll
have the cartesian product of points and content
Post by Pritam
While executing the following rule,
rule "home dummy"
when
pointId: Point(page == "home", region ="center-content")
content: Content(id=="adslot")
properties["type"]=="ad" from content
then
filter.put(content.id, true);
end
[ERR 101] Line 16:46 no viable alternative at input 'EQUALS' in rule "home
dummy" in pattern PointId[18,16]: [ERR 102] Line 18:16 mismatched input
'"type"' expecting ']' in rule "home dummy" in pattern properties
The documentation explains that this is the most common error but I still
struggle to understand the correct grammar for writing rules. Can anyone
point me to a good resource (I even read the book "drools 5) for writing the
following rule in a drl format?
" If a Point has a page, "home" and region, "center-content" and the Content
id is "adslot" with a property, type as "ad" then filter the Content (using
a global map and passing a boolean flag)
Thanks
--
http://n3.nabble.com/Understanding-no-viable-alternative-errors-tp119375p119375.html
Sent from the Drools - User mailing list archive at Nabble.com.
_______________________________________________
rules-users mailing list
https://lists.jboss.org/mailman/listinfo/rules-users
Edson Tirelli
2010-01-13 17:15:48 UTC
Permalink
The error simply means that your syntax is incorrect and the parser
could not understand the character at line 16, character 46. In this case,
you are using "=" instead of the correct "==":

pointId: Point(page == "home", region == "center-content")

Also, remember that constraints can only exist inside a pattern, so your
"properties" constraint must go inside the proper pattern that I guess is
"Content"

content: Content(id=="adslot", properties["type"]=="ad" )

[]s
Edson
Post by Pritam
While executing the following rule,
rule "home dummy"
when
pointId: Point(page == "home", region ="center-content")
content: Content(id=="adslot")
properties["type"]=="ad" from content
then
filter.put(content.id, true);
end
[ERR 101] Line 16:46 no viable alternative at input 'EQUALS' in rule "home
dummy" in pattern PointId[18,16]: [ERR 102] Line 18:16 mismatched input
'"type"' expecting ']' in rule "home dummy" in pattern properties
The documentation explains that this is the most common error but I still
struggle to understand the correct grammar for writing rules. Can anyone
point me to a good resource (I even read the book "drools 5) for writing the
following rule in a drl format?
" If a Point has a page, "home" and region, "center-content" and the Content
id is "adslot" with a property, type as "ad" then filter the Content (using
a global map and passing a boolean flag)
Thanks
--
http://n3.nabble.com/Understanding-no-viable-alternative-errors-tp119375p119375.html
Sent from the Drools - User mailing list archive at Nabble.com.
_______________________________________________
rules-users mailing list
https://lists.jboss.org/mailman/listinfo/rules-users
--
Edson Tirelli
JBoss Drools Core Development
JBoss by Red Hat @ www.jboss.com
Pritam
2010-01-13 17:27:15 UTC
Permalink
Ah, that was an oversight. After fixing that, I now get ...

mismatched input '"type"' expecting ']' in rule "filter content if
advertisement" in pattern properties

Is something wrong with this mvel syntax?
properties["type"]=="ad" from content
Post by Pritam
While executing the following rule,
dialect "mvel"
import xxx.*
import java.util.*
global HashMap filter
rule "filter content if advertisement"
when
point: Point(page == "home", region ="center-content")
content: Content(id=="adslot")
properties["type"]=="ad" from content
then
filter.put(content.id, true);
end
[ERR 101] Line 16:46 no viable alternative at input 'EQUALS' in rule
"filter content if advertisement" in pattern Point[18,16]: [ERR 102] Line
18:16 mismatched input '"type"' expecting ']' in rule "filter content if
advertisement" in pattern properties
The documentation explains that this is the most common error but I still
struggle to understand the correct grammar for writing rules. Can anyone
point me to a good resource (I even read the book "Drools 5" by Packt) for
writing the following rule in a drl format?
" If a Point has a page, "home" and region, "center-content" and the
Content id is "adslot" with a property, type as "ad" then filter the
Content (using a global map and passing a boolean flag)
Thanks
--
View this message in context: http://n3.nabble.com/Understanding-no-viable-alternative-errors-tp119375p119401.html
Sent from the Drools - User mailing list archive at Nabble.com.
Andreas Volz
2010-01-14 12:00:05 UTC
Permalink
Just have a look at Edson's answer to your first mail:

"Also, remember that constraints can only exist inside a pattern, so your
"properties" constraint must go inside the proper pattern that I guess is
"Content"

content: Content(id=="adslot", properties["type"]=="ad" )"


Cheers,
Andreas
Post by Pritam
Ah, that was an oversight. After fixing that, I now get ...
mismatched input '"type"' expecting ']' in rule "filter content if
advertisement" in pattern properties
Is something wrong with this mvel syntax?
properties["type"]=="ad" from content
Post by Pritam
While executing the following rule,
dialect "mvel"
import xxx.*
import java.util.*
global HashMap filter
rule "filter content if advertisement"
when
point: Point(page == "home", region ="center-content")
content: Content(id=="adslot")
properties["type"]=="ad" from content
then
filter.put(content.id, true);
end
[ERR 101] Line 16:46 no viable alternative at input 'EQUALS' in rule
"filter content if advertisement" in pattern Point[18,16]: [ERR 102] Line
18:16 mismatched input '"type"' expecting ']' in rule "filter content if
advertisement" in pattern properties
The documentation explains that this is the most common error but I still
struggle to understand the correct grammar for writing rules. Can anyone
point me to a good resource (I even read the book "Drools 5" by Packt) for
writing the following rule in a drl format?
" If a Point has a page, "home" and region, "center-content" and the
Content id is "adslot" with a property, type as "ad" then filter the
Content (using a global map and passing a boolean flag)
Thanks
--
http://n3.nabble.com/Understanding-no-viable-alternative-errors-tp119375p119401.html
Sent from the Drools - User mailing list archive at Nabble.com.
--
Andreas Volz
Consultant
mailto:***@valtech.de
Mobile: +49 173 5955343

Valtech GmbH
Zweigstraße 10
80336 München
Germany

Phone: +49 89 893242-0
Fax: +49 89 893242-31

http://www.valtech.de

Geschäftsführer: Ingo Kriescher
Amtsgericht Düsseldorf HRB48672


_______________________________________________
Post by Pritam
rules-users mailing list
https://lists.jboss.org/mailman/listinfo/rules-users
Loading...