Recursive Descent Parser

后端 未结 5 1664
南笙
南笙 2020-12-23 15:23

The book \'Modern Compiler Design\' is the nice book about compilers. In its source code something that is annoying me is AST or Abstract Syntax Tree. Suppose we want to wri

5条回答
  •  星月不相逢
    2020-12-23 15:34

    Nine times out of ten you'll save the AST in memory for whatever you are doing after lexing and parsing are done.

    Once you have an AST you can do a number of things:

    • Evaluate it directly (perhaps using recursion, perhaps using your own custom stack)
    • Transform it into some other output, such as code in another language or some other type of translation.
    • Compile it to preferred instruction set
    • etc.

提交回复
热议问题