Skip to content

Latest commit

 

History

History
 
 

bigcode-astgen

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

bigcode-astgen

Tools to convert source code into an AST in JSON format.

Supported languages

The following languages are currently supported

AST description

We use the format described in js150, without the trailing 0.

The formatted AST is an array of objects with the following properties:

  • (Required) id: unique integer identifying current AST node.
  • (Required) type: string containing type of current AST node.
  • (Optional) value: string containing value (if any) of the current AST node.
  • (Optional) children: array of integers denoting children (if any) of the current AST node.

For example, the following program

console.log("Hello World!");

gives the following AST.

[{"id":0, "type":"Program", "children": [1]},
 {"id":1, "type":"ExpressionStatement", "children": [2]},
 {"id":2, "type":"CallExpression", "children":[3,6]},
 {"id":3, "type":"MemberExpression", "children":[4,5]},
 {"id":4, "type":"Identifier", "value":"console"},
 {"id":5, "type":"Property", "value":"log"},
 {"id":6, "type":"LiteralString", "value":"Hello World!"}]