See inline.<br><br><div class="gmail_quote">On 27 May 2011 20:19, jstroup <span dir="ltr"><<a href="mailto:jstroup@regenstrief.org">jstroup@regenstrief.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi Droolers,<br>
<br>
Regarding this blurb from the 5.2 DSL reference:<br>
<br>
<br></blockquote><div>[snip] <br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
Given this DSL (test_expander.dsl)<br>
<br>
[when](C|c)heese is "{type}"=Cheese(type=="{type}")<br>
[when](is|hails|comes) from {country}=Cheese(country=="{country}")<br>
[then]Add the message {message}=System.out.println({message});<br>
<br>
And this DSLR<br>
<br>
package com.sample<br>
import com.sample.DroolsTest.Cheese;<br>
expander test_expander.dsl<br>
<br>
rule "rule_1"<br>
when<br>
Cheese is "cheddar" and is from Italy<br>
then<br>
Add the message "Cheddar IS from Italy"<br>
end<br>
<br></blockquote><div><br>This will not do what the text implies because the expansion is <br> Cheese(type=="cheddar") Cheese(country==="Italy")<br>and there is nothing that links these Cheese facts, which could<br>
be one and the same but also any other pair matching the<br>individual constraints.<br><blockquote class="gmail_quote"></blockquote></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
<br>
I know that rule_2 fails because I removed the “distinctive characters” so<br>
ANTLR is confused on what to capture.</blockquote><div><br>
ANTLR has nothing to do with DSL expansion, which is entirely based on<br>
regular expressions.<br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> It just seems so unnatural for a rule<br>
author to have to somehow magically know to add quotes in order to merge<br>
different DSL expressions to generate a composite DRL pattern.</blockquote><div><br>The DSL designer has a range of options (characters, buzz words,...) but at the<br>end of the day (s)he will have to document it for the rule authors. There's no<br>
way they'll know what to write, out of the blue.<br> </div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
2) We can no longer just write “Cheese is cheddar” by itself but are<br>
forced to write “Cheese is cheddar and” if we want to match only the first<br>
expression. You might as well just combined the two expressions into one<br>
since there is no real advantage now to having two expressions!<br></blockquote><div><br>There is a feature for adding arbitrary constraints into a preceding pattern.<br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
One nice thing would be for the Guvnor DSL editor to<br>
<br>
1)try the capture greedily first,<br>
2)get the annoying “no viable alternative error”,<br>
3)CATCH the error instead of just giving up,<br>
4)capture non-greedily and match only the first word,<br>
5)then search for matching DSL expressions beyond that.<br>
<br>
Or something like that.</blockquote><div><br>Exactly. There is the fundamental problem of different levels of grammars<br>for DRL and natural languages, and this can't be overcome easily. <br><br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
The only time you should have to add quotes is if<br>
the text you are matching actually contains multiple words. Anything else is<br>
counter-intuitive.</blockquote><div><br>The DSL designer can avoid this, at the cost of slightly more verbose phrases.<br><br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Please tell me the planned replacement for DSL addresses<br>
this!<br></blockquote><div><br>Feel free to contribute proposals (but not "something like that", please).<br>Wolfgang<br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
Jeff<br>
<br></blockquote></div>