xlab / c-for-go

Automatic C-Go Bindings Generator for Go Programming Language
https://c.for-go.com
MIT License
1.5k stars 119 forks source link

"panic: Enum" while processing notcurses.yml #101

Open dankamongmen opened 4 years ago

dankamongmen commented 4 years ago

Hey there! I'm the author of Notcurses, and I'm considering use of c-for-go to generate our Go bindings. I've created the following simple notcurses.yml:

[schwarzgerat](0) $ cat notcurses.yml 
# run ala "c-for-go -ccincl notcurses.yml"
---
GENERATOR:
  PackageName: notcurses
  PackageDescription: "Go bindings for Notcurses"
  PackageLicense: "Apache-2.0"
  Includes:
    - notcurses/notcurses.h

PARSER:
  # use -cincl when running c-for-go
  IncludePaths: ["/usr/include"]
  SourcesPaths: ["notcurses/notcurses.h"]

TRANSLATOR:
  Rules:
    global:
      - {action: accept}
      - {load: snakecase}
[schwarzgerat](0) $ 

and am running this on my installed 1.7.6 notcurses/notcurses.h. I get the following panic:

[schwarzgerat](0) $ ~/src/c-for-go/c-for-go -ccincl notcurses.yml 
  processing notcurses.yml ⠙panic: Enum

goroutine 1 [running]:
modernc.org/cc.(*Model).typ(0x969e60, 0x18, 0x9, 0xc000b4d890)
    /home/dank/go/pkg/mod/modernc.org/cc@v1.0.0/model.go:204 +0x3a5
modernc.org/cc.(*Model).BinOpType(0x969e60, 0x7c5480, 0xc0003619d0, 0x7c5480, 0xc000cab1f0, 0xc000cab1f0, 0xc0000102d0)
    /home/dank/go/pkg/mod/modernc.org/cc@v1.0.0/model.go:1541 +0x3a5
modernc.org/cc.(*Model).binOp(0x969e60, 0xc000024e00, 0x7bdae0, 0xc0001a0fc0, 0x7bdae0, 0xc0001a1080, 0x7c5480, 0xc00040ee70, 0x52d517, 0x969e60, ...)
    /home/dank/go/pkg/mod/modernc.org/cc@v1.0.0/model.go:1451 +0x2b2
modernc.org/cc.(*Expression).eval(0xc0001a1140, 0xc000024e00, 0x40deb8, 0x60, 0x721600, 0x20a58701)
    /home/dank/go/pkg/mod/modernc.org/cc@v1.0.0/ast2.go:2402 +0x9ed7
modernc.org/cc.(*ExpressionList).eval(0xc00072da90, 0xc000024e00, 0xe9, 0xc0001c6938, 0xc000da3400, 0xc00040ee70)
    /home/dank/go/pkg/mod/modernc.org/cc@v1.0.0/ast2.go:2716 +0x67
modernc.org/cc.yyParse(0x7bdb60, 0xc000024e00, 0x0)
    /home/dank/go/pkg/mod/modernc.org/cc@v1.0.0/parser.go:5183 +0x15a5d
modernc.org/cc.Parse(0xc0001aaa80, 0x332, 0xc0000e0a80, 0x1, 0x1, 0x969e60, 0xc000199c80, 0xa, 0xa, 0x0, ...)
    /home/dank/go/pkg/mod/modernc.org/cc@v1.0.0/cc.go:830 +0x5f8
github.com/xlab/c-for-go/parser.ParseWith(0xc0001e0600, 0xc0000e08b0, 0x1, 0x1)
    /home/dank/src/c-for-go/parser/parser.go:101 +0x1058
main.NewProcess(0x7ffdff38a293, 0xd, 0x0, 0x0, 0xc000014a70, 0xc0000111a0, 0x8c290900)
    /home/dank/src/c-for-go/process.go:80 +0x2a7
main.main()
    /home/dank/src/c-for-go/main.go:79 +0x1c5
[schwarzgerat](2) $ 

(btw, is that Braille character intended?)

anyway, I can dig into this, but I thought perhaps you might know what's up immediately. Feel free to request whatever in the term of debugging/verbose runs, etc.

dankamongmen commented 4 years ago

Hrmmm, it looks like this might actually be a modernc problem? It would be nice to have some better diagnostics in any case.