Proposed AST
Example 1 - Function body
function a(){
uint x = 5
}
{
"type": "FunctionDeclaration",
"name": "a",
"params": null,
"modifiers": null,
"body": {
"type": "BlockStatement",
"body": [
{
"type": "ExpressionStatement",
"expression": {
"type": "DeclarativeExpression",
"name": "x",
"literal": {
"type": "Type",
"literal": "uint",
"members": [],
"array_parts": [],
"start": 8306,
"end": 8310
},
"storage_location": null,
"start": 8306,
"end": 8312
},
"start": 8306,
"end": 8313
}
],
"start": 8300,
"end": 8317
},
"is_abstract": false,
"start": 8288,
"end": 8317
}
Example 2: Function body, extra spaces
function spaces() {
uint y;
}
{
"type": "FunctionDeclaration",
"name": "spaces",
"params": null,
"modifiers": null,
"body": {
"type": "BlockStatement",
"body": [
{
"type": "ExpressionStatement",
"expression": {
"type": "DeclarativeExpression",
"name": "y",
"literal": {
"type": "Type",
"literal": "uint",
"members": [],
"array_parts": [],
"start": 8346,
"end": 8350
},
"storage_location": null,
"start": 8346,
"end": 8352
},
"start": 8346,
"end": 8353
}
],
"start": 8340,
"end": 8357
},
"is_abstract": false,
"start": 8320,
"end": 8357
}
Example 3: Abstract
function abstract();
{
"type": "FunctionDeclaration",
"name": "abstract",
"params": null,
"modifiers": null,
"body": null,
"is_abstract": true,
"start": 8360,
"end": 8380
}
Current AST
function a(){
var x = 5;
}
{
"type": "FunctionDeclaration",
"name": "a",
"params": null,
"modifiers": null,
"body": {
"type": "BlockStatement",
"body": [
{
"type": "VariableDeclaration",
"declarations": [
{
"type": "VariableDeclarator",
"id": {
"type": "Identifier",
"name": "x",
"start": 8049,
"end": 8050
},
"init": {
"type": "Literal",
"value": 5,
"start": 8053,
"end": 8054
},
"start": 8049,
"end": 8054
}
],
"start": 8045,
"end": 8055
}
],
"start": 8045,
"end": 8055
},
"is_abstract": false,
"start": 8027,
"end": 8059
}