1.0.7 • Published 6 years ago
node-castjson v1.0.7
README (node-castjson)
A warper interface for castjson whihc is a C language project parsing C/C++ source code to AST(JSON) with LLVM libclang.
Installation
npm install node-castjson
Quick Start
const CASTJson = require('node-castjson');
let jsonbuf = {'data': ''};
let bStatus = castJson.parse('test/sample/dirmodule.c', jsonbuf);
if (bStatus) {
console.log(JSON.parse(jsonbuf.data));
}
Example
Input: One function in test/sample/dirmodule.c!ReadDir()
static
const FILE_ENTRY*
ReadDir(
IN char* const szPath,
IN bool const bRecursive
)
{
const FILE_ENTRY* pFileEntry = NULL;
szPath;
bRecursive;
return pFileEntry;
}
Output: JSON format from castjson.exe/castjson.out utility.
{ File: 'dirmodule.c',
Functions: [
{ "Name" : "ReadDir",
"Return" : "const FILE_ENTRY *",
"Parameters" : { "szPath" : "char *const",
"bRecursive" : "bool" }
]
}
Test
$ mocha
CAstJson class
- getToolPath()
√ should return true
- parse()
√ should return true (153ms)
2 passing (163ms)
Resource
- node-castjson
https://github.com/dougpuob/node-castjson.git
- castjson
https://github.com/dougpuob/castjson.git
License
MIT