|Sources for development of this article may be located at|
Other types of transformational languages
Why is this only about text transformational languages. As an example the TREE-META unparse transformation rules. They transform a tree structure into sequential instruction code.
A lexer transform a string into tokens. A parser transforms token lists into a tree structure.
Many transformational languages have a form of pattern and action rule structure:
<pattern> -> <action>
<pattern> -> <replacement>
Some use imbeaded actions. TREE-META's syntax rules transform input into tree structures.
EXPR = TERM $(('+':ADD/'-':SUB) TERM ); TERM = FACTOR $(('*':MPY/'/':DIV) FACTOR ); FACTOR = .ID / .NUMBER / '(' EXPR ')';
The above rules recognize an arithmetic expression in text form and transform it into an abstract syntax tree:
a*(b+c) >> MPY[a,ADD[b,c]] MPY / \ a ADD / \ b c
The unparse rules are of the form:
<tree pattern> -> <action>