[rules-users] Regex parsing of drl file versus Visitor pattern

mikeg mike at thegoldners.com
Thu Feb 16 13:50:17 EST 2012


My project uses Drools type declarations with custom annotations that are
used to assist in the dynamic mapping of underlying domain data to drools
fact types.

I need to provide a Swing user interface for rule creation that guides the
user through the custom type declarations, rules, and functions.  Guvnor
doesn't seem to be a good fit.

I've looked at drools-verifier (and the older DrlDumper class) and its use
of the Visitor pattern to traverse a rule package, but it is a lot of work
to implement just for the type declaration enhancements.  Producing
identical DRL to the imported file seems difficult.  Also, any inline
comments and formatting is lost.

Alternatively, I could parse (via regex patterns) the DRL to extract the
type declarations, rules, and functions and then reconstruct the complete
package file.  This seems simpler, though brittle. Also, the regex gets
complicated when attempting to get extended information (metadata,
annotations, etc.).

Any thoughts on either approach?  Is there an easier way to process a rules
file into a simple data model that doesn't lose the original DRL syntax?



--
View this message in context: http://drools.46999.n3.nabble.com/Regex-parsing-of-drl-file-versus-Visitor-pattern-tp3751402p3751402.html
Sent from the Drools: User forum mailing list archive at Nabble.com.



More information about the rules-users mailing list