Giter VIP home page Giter VIP logo

Comments (3)

jnjackins avatar jnjackins commented on August 23, 2024

It looks like there needs to be some special casing around handling of null nodes during AST parsing.

If I comment out the section of main.go that removes <<<NULL>>> from the AST, then I get the following, for for(;;) print("foo"):

|   `-ForStmt 0x7fd828076c18 <line:3:2, col:19>
|     |-<<<NULL>>>
|     |-<<<NULL>>>
|     |-<<<NULL>>>
|     |-<<<NULL>>>
|     `-CallExpr 0x7fd828076bd0 <col:11, col:19> 'int'
|       |-ImplicitCastExpr 0x7fd828076bb8 <col:11> 'int (*)()' <FunctionToPointerDecay>
|       | `-DeclRefExpr 0x7fd828076b08 <col:11> 'int ()' Function 0x7fd828076a60 'print' 'int ()'
|       `-ImplicitCastExpr 0x7fd828076c00 <col:17> 'char *' <ArrayToPointerDecay>
|         `-StringLiteral 0x7fd828076b68 <col:17> 'char [1]' lvalue ""

And the following for for(1;1;1) print("foo"):

|   `-ForStmt 0x7fad58076c78 <line:3:2, col:22>
|     |-IntegerLiteral 0x7fad58076a40 <col:7> 'int' 1
|     |-<<<NULL>>>
|     |-IntegerLiteral 0x7fad58076a60 <col:9> 'int' 1
|     |-IntegerLiteral 0x7fad58076a80 <col:11> 'int' 1
|     `-CallExpr 0x7fad58076c30 <col:14, col:22> 'int'
|       |-ImplicitCastExpr 0x7fad58076c18 <col:14> 'int (*)()' <FunctionToPointerDecay>
|       | `-DeclRefExpr 0x7fad58076b68 <col:14> 'int ()' Function 0x7fad58076ac0 'print' 'int ()'
|       `-ImplicitCastExpr 0x7fad58076c60 <col:20> 'char *' <ArrayToPointerDecay>
|         `-StringLiteral 0x7fad58076bc8 <col:20> 'char [1]' lvalue ""

from c2go.

jnjackins avatar jnjackins commented on August 23, 2024

Side note: why is there an extra <<<NULL>>> in both cases?

from c2go.

elliotchance avatar elliotchance commented on August 23, 2024

That's a good question, I don't know what the extra <<<NULL>>> are supposed to mean, but I ignore them when parsing: https://github.com/elliotchance/c2go/blob/master/main.go#L26-L30

This always gives me three parts for the for loop: https://github.com/elliotchance/c2go/blob/master/for_stmt.go#L30-L32

However, as you say, if there are less than three parts then that code would not work. Mind submitting a patch with the test C file?

from c2go.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.