llcppsigfetch:basic marco process

This commit is contained in:
luoliwoshang
2024-08-16 18:39:09 +08:00
parent 2b1d4b6672
commit 02651c93a7
4 changed files with 110 additions and 1 deletions

View File

@@ -0,0 +1,24 @@
#stdout
TestDefine Case 1:
{
"temp.h": {
"path": "temp.h",
"decls": [],
"includes": [],
"macros": [{
"Name": {
"Token": 2,
"Lit": "foo"
},
"Body": [{
"Token": 3,
"Lit": "1"
}]
}]
}
}
#stderr
#exit 0

View File

@@ -0,0 +1,33 @@
package main
import (
"github.com/goplus/llgo/c"
"github.com/goplus/llgo/chore/_xtool/llcppsigfetch/parse"
)
func main() {
TestDefine()
}
func TestDefine() {
testCases := []string{
`#define foo 1`,
}
for i, content := range testCases {
converter, err := parse.NewConverter(content, true)
if err != nil {
panic(err)
}
_, err = converter.Convert()
if err != nil {
panic(err)
}
json := converter.MarshalASTFiles()
c.Printf(c.Str("TestDefine Case %d:\n%s\n\n"), c.Int(i+1), json.Print())
converter.Dispose()
}
}