<div><br></div>   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&#39;t changed much in the latest few versions.<div><br></div><div>
   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.</div>
<div><br></div><div>   Edson<br><br><div class="gmail_quote">On Thu, Feb 16, 2012 at 1:50 PM, mikeg <span dir="ltr">&lt;<a href="mailto:mike@thegoldners.com">mike@thegoldners.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
My project uses Drools type declarations with custom annotations that are<br>
used to assist in the dynamic mapping of underlying domain data to drools<br>
fact types.<br>
<br>
I need to provide a Swing user interface for rule creation that guides the<br>
user through the custom type declarations, rules, and functions.  Guvnor<br>
doesn&#39;t seem to be a good fit.<br>
<br>
I&#39;ve looked at drools-verifier (and the older DrlDumper class) and its use<br>
of the Visitor pattern to traverse a rule package, but it is a lot of work<br>
to implement just for the type declaration enhancements.  Producing<br>
identical DRL to the imported file seems difficult.  Also, any inline<br>
comments and formatting is lost.<br>
<br>
Alternatively, I could parse (via regex patterns) the DRL to extract the<br>
type declarations, rules, and functions and then reconstruct the complete<br>
package file.  This seems simpler, though brittle. Also, the regex gets<br>
complicated when attempting to get extended information (metadata,<br>
annotations, etc.).<br>
<br>
Any thoughts on either approach?  Is there an easier way to process a rules<br>
file into a simple data model that doesn&#39;t lose the original DRL syntax?<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://drools.46999.n3.nabble.com/Regex-parsing-of-drl-file-versus-Visitor-pattern-tp3751402p3751402.html" target="_blank">http://drools.46999.n3.nabble.com/Regex-parsing-of-drl-file-versus-Visitor-pattern-tp3751402p3751402.html</a><br>

Sent from the Drools: User forum mailing list archive at Nabble.com.<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>  Edson Tirelli<br>  JBoss Drools Core Development<br>  JBoss by Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a><br>
</div>