C parser in Javascript

前端 未结 3 1534
别跟我提以往
别跟我提以往 2021-02-15 17:00

I\'d like to parse C header files in Javascript. Is there any such library available? Otherwise, any tips to help me get started?

Update: My ultimate go

3条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-15 17:56

    You should check out clang.

    For a simple command-line invocation, you can try this:

    clang -cc1 -ast-dump-xml myfile.h
    

    Or you can build your own tool using clang reasonably-well-documented parser library, which will build an AST for you, and let you walk it as you see fit (perhaps for output in JSON).

提交回复
热议问题