Pattern-Matching Parse Trees

andre <[email protected]> Sat, 16 Sep 2023 15:15:52 +0200
Newsgroups gmane.comp.lang.smalltalk.vwnc
Message-ID <[email protected]>
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