AW: Pattern-Matching Parse Trees

"Christian Haider" <[email protected]> Sat, 16 Sep 2023 16:46:42 +0200
Newsgroups gmane.comp.lang.smalltalk.vwnc
Message-ID <[email protected]>
Look at Refactory.Browser.ParseTreeRewriter which does exactly what you
want.
All the refactorings and code critic rule are implemented with it, so there
are plenty of examples.

HTH,
Christian

-----Ursprüngliche Nachricht-----
Von: [email protected] <[email protected]>
Im Auftrag von andre
Gesendet: Samstag, 16. September 2023 15:16
An: [email protected]
Betreff: [vwnc] Pattern-Matching Parse Trees

Is there a way to match patterns in a parse tree and do transformations and
replacements? Something like

'{CONDITION} ifFalse:[ {STATEMENTS} ]' => '{CONDITION} not ifTrue:[
{STATEMENTS} ]'

I would like to write a set of transformation rules to normalize Smalltalk
code in order to prepare it for automated translation to other languages. 

This is mainly to simplify expressions and control structures to make them
compatible with the target language. Ideally idioms and design patterns can
be transformed entirely, so pattern matching needs to go deep into a parse
tree and check for constraints at any level.

TIA

Andre