Theory, examples of reversible parsers?

前端 未结 11 1180
滥情空心
滥情空心 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:13

    Actually, generating code from a parse tree is strictly easier than parsing code, at least in a mathematical sense. There are many grammars which are ambiguous, that is, there is no unique way to parse them, but a parse tree can always be converted to a string in a unique way, modulo whitespace.

    The Dragon book gives a good description of the theory of parsers.

提交回复
热议问题