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

2012-02-16 Thread mikeg
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.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


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

2012-02-16 Thread Edson Tirelli
   First it is important to know that you are dealing with internal APIs
here and they can change from version to version, although they haven't
changed much in the latest few versions.

   If you use the DRLParser directly, it will give you an AST-like
descriptor model (root object is a PackageDescr). That model contains info
like line/column of each element in the source file, including the type
declarations. Of course, comments are discarded by the parser, but if you
want to inject/remove stuff you can simply use the position information to
do that in the original file and this way preserve comments and ordering,
etc.

   Edson

On Thu, Feb 16, 2012 at 1:50 PM, mikeg m...@thegoldners.com wrote:

 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.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users