Theory, examples of reversible parsers?

前端 未结 11 1249
滥情空心
滥情空心 2021-01-13 22:50

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. Mathematicall

11条回答
  •  独厮守ぢ
    2021-01-13 23:22

    There are several "lens languages" that allow bidirection transformation of source code.

    It is also possible to implement reversible parsers using definite clause grammars in Prolog. In SWI-Prolog, the phrase/3 predicate converts parse trees into text and vice-versa. This book provides some additional examples of reversible parsing in Prolog.

提交回复
热议问题