Clang : What does AST (abstract syntax tree) look like?

后端 未结 3 2051
清酒与你
清酒与你 2021-02-06 01:52

Hi I am new in Compiler development, and am wondering how AST look like. I have a small section of code, and I use Clang for generating the AST. I don\'t get much information ou

3条回答
  •  無奈伤痛
    2021-02-06 02:08

    The AST is a linked structure in memory ("tree" does not make justice to the complexity of the thing, but it's the name people use). What -ast-print produces is a textual representation of the AST. Since the human who set the option is already familiar with C/C++-like syntax, it is printed in a representation that follows that syntax. This is a design choice, not a happy coincidence.

    If you want to see what the AST looks like when it's not printed on purpose in a familiar syntax, you could for instance look at GIMPLE, GCC's internal representation.

提交回复
热议问题