[rules-users] typed grammar in DSL

B Berteh berteh at hotmail.com
Wed Jun 13 10:03:56 EDT 2007


Hello,

I'd like to use extensively the DSL feature in order to provide
paraphrasing for rules... and still ensure that only syntactically rules
can be build.

This discussion mixes up IDE and rules core (dsl) issues.



Ideally I'd define DSL shortcuts with type handling to prevent common
errors in rule creation. My DSL would include, eg:


[when]	The date {date} is outdated =
	    eval(Calendar.getInstance(TimeZone.getDefault()).getTime() <
date.getTime())

[date]  today =
	   Calendar.getInstance(TimeZone.getDefault())

[date]  {people}'s birthday =
	   people.getBirthday()

[people] Jack =
	   People.get("Jack")



And the selfcompletion would only provide the "date" placeholders when I
am completing the first LHS "when", hiding any other LHS, RHS or
[people] template.



A few related questions:
- Is this already available and if yes how/where?
- Is this of interest to anyone? currently working thereon?
- I'm willing to foster that question into JBoss Rules if no one is
doing it, as I'd need it... yesterday ;o)  any comment/input/remark
would therefore be welcome.

Ideally this would bring the DSL feature close to a BNF grammar
declaration that provides implementation translation.


To go event further one should eventually take care of multiple
variables with same type, that would self-complete with the relevant
templates. like in:

[when]  {date_1} was at least 100 years before {date_2} =
		#java code ~ date_1.getTime() + 100 years < date_2.getTime()



and eventually take care of "parametric variables". In the following
example selecting Jack as people_1 would allow to select Car or Bike for
his transport means, but no Aircraft... that would be available to Rita
only.

[when]  {people_1} has a dog and a {transport[people_1]} =
		eval(people_1.hasTransport(transport)

[people] Jack =
	   People.get("Jack")
[people] Rita =
	   People.get("Rita")

#some transports are not available to Jack, like an aircraft
[transport[people]] Jack -> Car =
			Transport._CAR
[transport[people]] Jack -> Bike =
			Transport._BIKE
[transport[people]] Rita -> Aircraft =
			Transport._AIRCRAFT





I actually did build rules from such strongly-typed grammars and
contextual behaviors (called parametric variables above) in other
prototypical systems. The final quality of the rules where satisfactory,
but the execution engine was not, so I am switching to JBoss... but
would rather not loose the type checking as it greatly improves the
quality of the designes rules from my experience.

Thanks for reading this long post, and feel free to give me any comment
you got.

Bertrand.

_________________________________________________________________
Tout ce qu'il y a de plus trendy pour Windows Live Messenger... 
http://divertissements.fr.msn.be/funwithmessenger




More information about the rules-users mailing list