Saturday, 15 January 2011

java - Build transformation engine based on rules -



java - Build transformation engine based on rules -

i want build transformation engine based on rule set (from cobol java) illustration have next cobol code:

perform 3 times if x = 10 then; else phone call para01. end perform.

i want able define rules following:

rule1: pattern: perform $var times ==> (int = 0; < $var; ++) rule2: pattern: if status ; else block_of_code ==> if (!(condition)) block_of_code

so java code after transformed this:

for (int = 0; < 3; ++) if (!(a== 10)) para01();

is there tool, platform available help? in case need develop scratch, there recommendation? give thanks much

some people seek kind of thing regular expressions. doesn't work; regular expressions can't handle context-free matching.

the right reply program transformation systems.

these tools parse source, build asts, , allow 1 write code transformations in source syntax, much op has shown.

while there ton of theory (see scholar.google.com term "program transformation), building these tools difficult. notion of parsing code fragments (as op has hinted at) requires pretty interesting twists in parsing machinery. i've been in space since 1980s, , seen tools listed @ wikipedia built on lastly 15-20 years; don't see lot more of them. experience have building our scheme (see bio) 50 man-years of phd level software engineering, i'm not surprised don't see more of them.

these tools typically require precise language front end end useful, , much of work in using them goes after have basic transformation engines built. (see discussion on parsing java , c++; applies as complex legacy languages cobol).

[a query in comment wanted know more larn more technical detail. if want "first-cut" deep technical detail, survey pretty good, focuses on "pure" transformation engines (operating on abstract syntax trees).

i happen believe 1 needs considerably more that; see bio give-and-take of "life after parsing". can older technical paper on our dms system, and/or more recent video overview of our system, including how differs, in google tech talk.

in comment on original question, there request "deep technical tour". see this detailed give-and-take on how dms handles rewrite rules; page links deep discussions of related topics.

java parsing compiler-construction transform transformation

No comments:

Post a Comment