sqlite-parser icon indicating copy to clipboard operation
sqlite-parser copied to clipboard

Do you have the AST definition document?

Open lunexnocty opened this issue 5 years ago • 1 comments

I'm learning this project and I want a document about how AST defined just like https://esprima.readthedocs.io/en/latest/syntax-tree-format.html

lunexnocty avatar Apr 08 '20 15:04 lunexnocty

Hey @lunexnocty

I don't think there is any documentation like this. There are still a few options though:

  • I've a project that generated SQL from the AST output by sqlite-parser. The code is quite good as an example of using the AST. It should cover all paths (I haven't run it with a current version of the library but the AST has been fairly stable). You can take a look here: https://github.com/jdrew1303/sqlgenerate/blob/master/sqlgenerate.js
  • You can look through the test folder. There are examples of the SQL and the json ast generated by this library. It's been the main guide I've used while working with the library.
  • You can use GrammKit to generate railroad diagrams of the language. You might need to preprocess the peg file before using this. pegjs-strip might be of some help with this.

Hope this helps 👍 👋

jdrew1303 avatar Apr 14 '20 23:04 jdrew1303