> http://www.google.com/search?hl=en&lr=&safe=off&q=java
> +tree+pattern+matching&btnG=Search
I tried that before I posted my question to the forum. But I looked at the first 50 hits and all addressed pattern matching in strings and accidentally contained the word "tree". I then decided to not look in to the other 2.999.950 hits. I'm not looking for string pattern matching but for tree pattern matching. This kind of algs are used in compiler kits for code generation. My purpose is a bit different. I want to manipulate an abstract syntax tree of a home grown language to remove some statements and change some others. Of course I could walk the tree and hard code the manipulations, but I thought using a ready implementation of a appropriate alg that takes some spec of the tree patterns to manipulate would be a cleaner approach and simpler to maintain.
> I tried that before I posted my question to the
> forum. But I looked at the first 50 hits and all
> addressed pattern matching in strings and
> accidentally contained the word "tree". I then
> decided to not look in to the other 2.999.950 hits.
Forgive my prejudgment, but your original post of 1 sentence didn't give me the impression you did an awfull lot of research. That's why I posted the link to Google.
> I'm not looking for string pattern matching but for
> tree pattern matching. This kind of algs are used in
> compiler kits for code generation. My purpose is a
> bit different. I want to manipulate an abstract
> syntax tree of a home grown language to remove some
> statements and change some others. Of course I could
> walk the tree and hard code the manipulations, but I
> thought using a ready implementation of a appropriate
> alg that takes some spec of the tree patterns to
> manipulate would be a cleaner approach and simpler to
> maintain.
Google (or any search engine) can be used in a more subtle way; you can exlude some words from your search like the word "String" by putting a minus-sign in front of it:
http://www.google.com/search?hl=en&lr=&safe=off&q=java+%22tree+pattern+matching%22+-string&btnG=Search
In those first few hits the opensource tool ANTLR comes up, which might be of use to you:
http://www.antlr.org/
Thank you prometheuzz. I've seen ANTLR before but did not take it into account, because I thought that it would not take me further than I am beeing. Till now I use JavaCC, another parser generator, because I worked with it in a former project. I took a look at http://www.antlr.org/ and they claim "excellent support for tree construction, tree walking and translation". Seems to be worth to have a closer look at it.
Another aproach could be to generate/parse XML and translate with XSLT ?