Change command line test from --ast to --ast-json.

This commit is contained in:
Daniel Kirchner 2019-09-06 13:39:29 +02:00
parent 5d69bdf81e
commit 998f7de2c8
3 changed files with 243 additions and 33 deletions

View File

@ -6,7 +6,7 @@
REPO_ROOT="$(dirname "$0")"/.. REPO_ROOT="$(dirname "$0")"/..
cd $REPO_ROOT cd $REPO_ROOT
WHITESPACE=$(git grep -n -I -E "^.*[[:space:]]+$" | grep -v "test/libsolidity/ASTJSON\|test/libsolidity/ASTRecoveryTests\|test/compilationTests/zeppelin/LICENSE") WHITESPACE=$(git grep -n -I -E "^.*[[:space:]]+$" | grep -v "test/libsolidity/ASTJSON\|test/libsolidity/ASTRecoveryTests\|test/compilationTests/zeppelin/LICENSE\|test/cmdlineTests/recovery_ast_constructor/output")
if [[ "$WHITESPACE" != "" ]] if [[ "$WHITESPACE" != "" ]]
then then

View File

@ -1 +1 @@
--error-recovery --ast --hashes --error-recovery --ast-json --hashes

View File

@ -1,34 +1,244 @@
Syntax trees: JSON AST:
======= recovery_ast_constructor/input.sol ======= ======= recovery_ast_constructor/input.sol =======
PragmaDirective {
Source: "pragma solidity >=0.0.0;" "attributes" :
ContractDefinition "Error1" {
Source: "contract Error1 {\n constructor() public {\n balances[tx.origin] = ; // missing RHS.\n }\n\n // Without error recovery we stop due to the above error.\n // Error recovery however recovers at the above ';'\n // There should be an AST for the above, albeit with error\n // nodes.\n\n // This function parses properly and should give AST info.\n function five() public view returns(uint) {\n return 5;\n }\n}" "absolutePath" : "recovery_ast_constructor/input.sol",
FunctionDefinition "" - public "exportedSymbols" :
Source: "constructor() public {\n balances[tx.origin] = ; // missing RHS.\n }" {
ParameterList "Error1" :
Source: "()" [
ParameterList 18
Source: "" ]
Block }
Source: "{\n balances[tx.origin] = ; // missing RHS.\n }" },
FunctionDefinition "five" - public - const "children" :
Source: "function five() public view returns(uint) {\n return 5;\n }" [
ParameterList {
Source: "()" "attributes" :
ParameterList {
Source: "(uint)" "literals" :
VariableDeclaration "" [
Type: uint256 "solidity",
Source: "uint" ">=",
ElementaryTypeName uint "0.0",
Source: "uint" ".0"
Block ]
Source: "{\n return 5;\n }" },
Return "id" : 1,
Source: "return 5" "name" : "PragmaDirective",
Literal, token: [no token] value: 5 "src" : "0:24:0"
Type: int_const 5 },
Source: "5" {
"attributes" :
{
"baseContracts" :
[
null
],
"contractDependencies" :
[
null
],
"contractKind" : "contract",
"documentation" : null,
"fullyImplemented" : true,
"linearizedBaseContracts" :
[
18
],
"name" : "Error1",
"scope" : 19
},
"children" :
[
{
"attributes" :
{
"documentation" : null,
"implemented" : true,
"isConstructor" : true,
"kind" : "constructor",
"modifiers" :
[
null
],
"name" : "",
"overrides" : null,
"scope" : 18,
"stateMutability" : "nonpayable",
"superFunction" : null,
"visibility" : "public"
},
"children" :
[
{
"attributes" :
{
"parameters" :
[
null
]
},
"children" : [],
"id" : 2,
"name" : "ParameterList",
"src" : "57:2:0"
},
{
"attributes" :
{
"parameters" :
[
null
]
},
"children" : [],
"id" : 3,
"name" : "ParameterList",
"src" : "67:0:0"
},
{
"attributes" :
{
"statements" :
[
null
]
},
"children" : [],
"id" : 8,
"name" : "Block",
"src" : "67:49:0"
}
],
"id" : 9,
"name" : "FunctionDefinition",
"src" : "46:70:0"
},
{
"attributes" :
{
"documentation" : null,
"implemented" : true,
"isConstructor" : false,
"kind" : "function",
"modifiers" :
[
null
],
"name" : "five",
"overrides" : null,
"scope" : 18,
"stateMutability" : "view",
"superFunction" : null,
"visibility" : "public"
},
"children" :
[
{
"attributes" :
{
"parameters" :
[
null
]
},
"children" : [],
"id" : 10,
"name" : "ParameterList",
"src" : "382:2:0"
},
{
"children" :
[
{
"attributes" :
{
"constant" : false,
"name" : "",
"overrides" : null,
"scope" : 17,
"stateVariable" : false,
"storageLocation" : "default",
"type" : "uint256",
"value" : null,
"visibility" : "internal"
},
"children" :
[
{
"attributes" :
{
"name" : "uint",
"type" : "uint256"
},
"id" : 11,
"name" : "ElementaryTypeName",
"src" : "405:4:0"
}
],
"id" : 12,
"name" : "VariableDeclaration",
"src" : "405:4:0"
}
],
"id" : 13,
"name" : "ParameterList",
"src" : "404:6:0"
},
{
"children" :
[
{
"attributes" :
{
"functionReturnParameters" : 13
},
"children" :
[
{
"attributes" :
{
"argumentTypes" : null,
"hexvalue" : "35",
"isConstant" : false,
"isLValue" : false,
"isPure" : true,
"lValueRequested" : false,
"subdenomination" : null,
"token" : "number",
"type" : "int_const 5",
"value" : "5"
},
"id" : 14,
"name" : "Literal",
"src" : "424:1:0"
}
],
"id" : 15,
"name" : "Return",
"src" : "417:8:0"
}
],
"id" : 16,
"name" : "Block",
"src" : "411:19:0"
}
],
"id" : 17,
"name" : "FunctionDefinition",
"src" : "369:61:0"
}
],
"id" : 18,
"name" : "ContractDefinition",
"src" : "26:406:0"
}
],
"id" : 19,
"name" : "SourceUnit",
"src" : "0:433:0"
}