抽象语法树的生成

int main(int argc, char **argv)
{
 int i, j = 5;
 if (i) {
    return (j * 1 - j);
 }
 else {
 exit(1);
 }
}
<> (D:\git\cbc\cbc-project\test\ast.cb:1)
variables:
functions:
    <> (D:\git\cbc\cbc-project\test\ast.cb:1)
    name: "main"
    isPrivate: false
    params:
        parameters:
            <> (D:\git\cbc\cbc-project\test\ast.cb:1)
            name: "argc"
            typeNode: int
            <> (D:\git\cbc\cbc-project\test\ast.cb:1)
            name: "argv"
            typeNode: char**
    body:
        <> (D:\git\cbc\cbc-project\test\ast.cb:2)
        variables:
            <> (D:\git\cbc\cbc-project\test\ast.cb:3)
            name: "i"
            isPrivate: false
            typeNode: int
            initializer: null
            <> (D:\git\cbc\cbc-project\test\ast.cb:3)
            name: "j"
            isPrivate: false
            typeNode: int
            initializer:
                <> (D:\git\cbc\cbc-project\test\ast.cb:3)
                typeNode: int
                value: 5
        stmts:
            <> (D:\git\cbc\cbc-project\test\ast.cb:4)
            cond:
                <> (D:\git\cbc\cbc-project\test\ast.cb:4)
                name: "i"
            thenBody:
                <> (D:\git\cbc\cbc-project\test\ast.cb:4)
                variables:
                stmts:
                    <> (D:\git\cbc\cbc-project\test\ast.cb:5)
                    expr:
                        <> (D:\git\cbc\cbc-project\test\ast.cb:5)
                        operator: "-"
                        left:
                            <> (D:\git\cbc\cbc-project\test\ast.cb:5)
                            operator: "*"
                            left:
                                <> (D:\git\cbc\cbc-project\test\ast.cb:5)
                                name: "j"
                            right:
                                <> (D:\git\cbc\cbc-project\test\ast.cb:5)
                                typeNode: int
                                value: 1
                        right:
                            <> (D:\git\cbc\cbc-project\test\ast.cb:5)
                            name: "j"
            elseBody:
                <> (D:\git\cbc\cbc-project\test\ast.cb:7)
                variables:
                stmts:
                    <> (D:\git\cbc\cbc-project\test\ast.cb:8)
                    expr:
                        <> (D:\git\cbc\cbc-project\test\ast.cb:8)
                        expr:
                            <> (D:\git\cbc\cbc-project\test\ast.cb:8)
                            name: "exit"
                        args:
                            <> (D:\git\cbc\cbc-project\test\ast.cb:8)
                            typeNode: int
                            value: 1

 

 

你可能感兴趣的:(编译原理)