Comments (3)
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.
Side note: why is there an extra <<<NULL>>>
in both cases?
from c2go.
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)
- panic: unknown node type: 'MSAllocatorAttr 0x21a234729f0 <line:420:25>' HOT 1
- How to handle dependencies? HOT 2
- panic: could not match regexp with string HOT 1
- panic: unknown node type: 'CallbackAttr 0x562b0bc30c88 <line:199:12> Implicit 2 3'
- Cannot tranpile (sic)
- panic: unknown node type: ColdAttr HOT 1
- __int128 is translated as int64
- panic: unknown node type: BuiltinAttr HOT 2
- panic: unknown node type: 'BuiltinAttr 0x7fb08f04f838 <<invalid sloc>> Inherited Implicit 720' HOT 2
- panic: could not match regexp with string (translation_unit_decl) HOT 2
- 'const' removed from struct name / cannot determine sizeof union HOT 2
- docker container for c2go HOT 8
- panic: runtime error: invalid memory address or nil pointer dereference
- An alternative to github.com/elliotchance/c2go HOT 1
- panic: unknown node type: 'BuiltinAttr 0x10db7b0 <<invalid sloc>> Inherited Implicit 749' HOT 1
- FreeBSD implementation
- panic: unknown node type: 'BuiltinAttr 0x1d448112da0 <<invalid sloc>> Implicit 836' HOT 3
- Installation of c2go HOT 3
- Is it possible to convert .cpp aswell? HOT 1
- Compile `pikchr` source code
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from c2go.