[rules-dev] modify keyword in java

Mark Proctor mproctor at codehaus.org
Sun Nov 25 07:05:45 EST 2007


I was thinking about the modify keyword and how nice it would to have 
that work from java dialect too. I think we might be able to hack this 
with a simple scanner.
1) scan for the "modify ("......") {". We can balance text the first 
opening and closing parenthesis.
2) take the contents  of the  "("......")" and assign it to X and do 
modifyRetract( X ). if the contents starts with "new"  we need to handle 
that slightly differently, note no ModifyRetract is needed and we have 
to assign the results to an anonymous variable.
3) scan for "=" then backtrack to find the field name (delimeted by the 
first "{" or a ","
4) for each field = Y write it to X.setX to Y
5) then do modifyInsert( Y )

I could write a custom line scanner for this, but wondering if it could 
actually be done more efficiently in antlr?

Any takers? :)

Mark



More information about the rules-dev mailing list