I have written a parser that may be close to what you want.
My parser would parse the following script
---------------------------------------------------------
/* Default rule file for an account.
*
* Author: Martin P. Smith
*/
RULE lotOriginalGT8Mill
IF 2000000 + Lot.currentPar > 3000000 + Lot.originalPar
THEN
LOG FATAL "Lot Lot.lotID has original par > 8 million it is Lot.originalPar"
ENDRULE
RULE lotOriginalLT600K
IF Lot.originalPar < 600000
THEN
LOG ERROR "Lot Lot.lotID has original par < 600k it is Lot.originalPar"
ENDRULE
RULE bondDurationLt20
IF Bond.localDuration > 20
THEN
LOG WARN "The bond Bond.description has a duration greateer than 20 it is Bond.localDuration"
ENDRULE
RULE bondRatingTest
IF Bond.numericRating < 7
THEN
LOG INFO "The bond Bond.description has a rating less than A it is Bond.moodyRating"
ENDRULE
into
;;-*- rule -*-
( defrule lotOriginalGT8Mill
(Lot( OBJECT ?Lot ))
(test ( >(+ 2000000 ( get ?Lot currentPar) ) (+ 3000000 ( get ?Lot o
riginalPar) ) ))
=>
(call ?*logger* logRuleMessage ?*fatal* (sym-cat "Lot " ( get ?Lot lotID
) "has original par > 8 million it is " ( get ?Lot originalPar) "" " " ) )
)
;;-*- rule -*-
( defrule lotOriginalLT600K
(Lot( OBJECT ?Lot ))
(test ( < ( get ?Lot originalPar) 600000 ))
=>
(call ?*logger* logRuleMessage ?*error* (sym-cat "Lot " ( get ?Lot lotID
) "has original par < 600 k it is " ( get ?Lot originalPar) "" " " ) )
)
;;-*- rule -*-
( defrule bondDurationLt20
(Bond( OBJECT ?Bond ))
(test ( > ( get ?Bond localDuration) 20 ))
=>
(call ?*logger* logRuleMessage ?*warn* (sym-cat "The bond " ( get ?Bond
description) "has a duration greateer than 20 it is " ( get ?Bond localDuration)
"" " " ) )
)
;;-*- rule -*-
( defrule bondRatingTest
(Bond( OBJECT ?Bond ))
(test ( < ( get ?Bond numericRating) 7 ))
=>
(call ?*logger* logRuleMessage ?*info* (sym-cat "The bond " ( get ?Bond
description) "has a rating less than A it is " ( get ?Bond moodyRating) "" " " )
)
)
If this may be of any use to you in its current state please feel free to
contact me direct via email.
Martin Smith
[EMAIL PROTECTED]
At 10:48 AM 11/13/2001 -0800, you wrote:
Hi,
I am looking for a way convert user-inputed
rules into Jess rules. I am able to control
the interface, but it is not trivial to
convert the following user inputed statement:
If ( (x=1) OR (fname=bo*))
Then (set priority=1).
The problem I am having is that I am using
Dr. Leff's XML integration, which turns XML
into Jess facts. The facts look like:
(Tag (TagName x) (Text 1))
(Tag (TagName fname) (Text Bob))
The rule would then need to look something like:
(defrule Rule1
(Tag (TagName x) (Text "1"))
(Tag (TagName fname) (Text ?name&:(call startswith
?name "bo"))
Has anyone worked on parsing readable user input into
jess syntax?
Thanks,
Bob
__________________________________________________
Do You Yahoo!?
Find the one for you at Yahoo! Personals
http://personals.yahoo.com
--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]
--------------------------------------------------------------------
--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]
--------------------------------------------------------------------
