Revert "Add Steve Johnson-style parser recovery rules:"

This reverts commit 97f8ee0d1b.
This commit is contained in:
chriseth
2019-05-28 18:09:24 +02:00
parent b716b211ef
commit 4ee703e6e5
27 changed files with 137 additions and 489 deletions
@@ -1,20 +0,0 @@
pragma solidity >=0.0.0;
contract Error1 {
constructor() public {
balances[tx.origin] = ; // missing RHS.
}
// Without error recovery we stop due to the above error.
// Error recovery however recovers at the above ';'
// There should be an AST for the above, albeit with error
// nodes.
// This function parses properly and should give AST info.
function five() public view returns(uint) {
return 5;
}
}
// ----
// ParserError: (95-96): Expected primary expression.
// Warning: (95-96): Recovered in Statement at ';'.
@@ -1,7 +0,0 @@
contract Errort6 {
using foo for ; // missing type name
}
// ----
// ParserError: (36-37): Expected type name
// Warning: (59-60): Recovered in ContractDefinition at '}'.
@@ -1,13 +0,0 @@
pragma solidity >=0.0.0;
// Example to show why deleting the token at the
// is bad when error recovery is in effect. Here, ")" is missing
// and there is a ";" instead. That causes us to
// not be able to synchronize to ';'. Advance again and
// '}' is deleted and then we can't synchronize the contract.
// There should be an an AST created this contract (with errors).
contract Error2 {
mapping (address => uint balances; // missing ) before "balances"
}
// ----
// ParserError: (417-425): Expected ')' but got identifier
@@ -1,23 +0,0 @@
// Example which where scanning hits EOS, so we reset.
// Here we recover in the contractDefinition.
// There should be an an AST created this contract (with errors).
contract Error2 {
mapping (address => uint balances) // missing ;
}
// There is no error in this contract
contract SendCoin {
function sendCoin(address receiver, uint amount) public returns(bool sufficient) {
if (balances[msg.sender] < amount) return false;
balances[msg.sender] -= amount;
balances[receiver] += amount;
emit Transfer(msg.sender, receiver, amount);
return true;
}
}
// ----
// ParserError: (212-220): Expected ')' but got identifier
// ParserError: (220-221): Expected ';' but got ')'
// ParserError: (220-221): Function, variable, struct or modifier declaration expected.
// Warning: (235-236): Recovered in ContractDefinition at '}'.
@@ -1,11 +0,0 @@
pragma solidity >=0.0.0;
contract Error3 {
constructor() public {
balances[tx.origin] = ; // missing RHS.
}
}
// ----
// ParserError: (95-96): Expected primary expression.
// Warning: (95-96): Recovered in Statement at ';'.
@@ -1,29 +0,0 @@
// An example with multiple errors.
// Most are caught by inserting an expected token.
// However some us S C Johnson recovery to
// skip over tokens.
pragma solidity >=0.0.0;
contract Error4 {
constructor() public {
balances[tx.origin] = 1 2; // missing operator
}
function sendCoin(address receiver, uint amount) public returns(bool sufficient) {
if (balances[msg.sender] < amount) return false;
balances[msg.sender] -= amount // Missing ";"
balances[receiver] += amount // Another missing ";"
emit Transfer(msg.sender // truncated line
return true;
}
}
// ----
// ParserError: (249-250): Expected ';' but got 'Number'
// ParserError: (471-479): Expected ';' but got identifier
// ParserError: (529-533): Expected ';' but got 'emit'
// ParserError: (577-583): Expected ',' but got 'return'
// ParserError: (577-583): Expected primary expression.
// Warning: (588-589): Recovered in Statement at ';'.