Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Theory, examples of reversible parsers?

Does anyone out there know about examples and the theory behind parsers that will take (maybe) an abstract syntax tree and produce code, instead of vice-versa. Mathematically, at least intuitively, I believe the function of code->AST is reversible, but I'm trying to find work/examples of this... besides the usual resources like the Dragon book and such. Any ideas?

like image 897
Dervin Thunk Avatar asked Mar 01 '23 21:03

Dervin Thunk


1 Answers

Such thing is called a Visitor. Is traverses the tree and does whatever has to be done, for example optimize or generate code.

like image 81
paweloque Avatar answered Mar 11 '23 12:03

paweloque