Merge pull request #9511 from ethereum/ast-hex-string

[BREAKING] Distinguish between stringLiteral and hexStringLiteral in the JSON AST
This commit is contained in:
chriseth 2020-07-27 12:34:40 +02:00 committed by GitHub
commit 5812cd8213
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 8 additions and 3 deletions

View File

@ -3,6 +3,7 @@
Breaking changes: Breaking changes:
* Inline Assembly: Disallow ``.`` in user-defined function and variable names. * Inline Assembly: Disallow ``.`` in user-defined function and variable names.
* Inline Assembly: Slot and offset of storage pointer variable ``x`` are accessed via ``x.slot`` and ``x.offset`` instead of ``x_slot`` and ``x_offset``. * Inline Assembly: Slot and offset of storage pointer variable ``x`` are accessed via ``x.slot`` and ``x.offset`` instead of ``x_slot`` and ``x_offset``.
* JSON AST: Mark hex string literals with ``kind: "hexString"``.
* JSON AST: Remove members with ``null`` value from JSON output. * JSON AST: Remove members with ``null`` value from JSON output.
* Parser: Disallow ``gwei`` as identifier. * Parser: Disallow ``gwei`` as identifier.
* Parser: Disallow dot syntax for ``value`` and ``gas``. * Parser: Disallow dot syntax for ``value`` and ``gas``.

View File

@ -104,6 +104,7 @@ Declarations
Interface Changes Interface Changes
================= =================
* JSON AST: Mark hex string literals with ``kind: "hexString"``.
* JSON AST: Members with value ``null`` are removed from JSON output. * JSON AST: Members with value ``null`` are removed from JSON output.
* NatSpec: Constructors and functions have consistent userdoc output. * NatSpec: Constructors and functions have consistent userdoc output.

View File

@ -919,8 +919,9 @@ string ASTJsonConverter::literalTokenKind(Token _token)
case Token::Number: case Token::Number:
return "number"; return "number";
case Token::StringLiteral: case Token::StringLiteral:
case Token::HexStringLiteral:
return "string"; return "string";
case Token::HexStringLiteral:
return "hexString";
case Token::TrueLiteral: case Token::TrueLiteral:
case Token::FalseLiteral: case Token::FalseLiteral:
return "bool"; return "bool";

View File

@ -943,6 +943,8 @@ Token ASTJsonImporter::literalTokenKind(Json::Value const& _node)
tok = Token::Number; tok = Token::Number;
else if (_node["kind"].asString() == "string") else if (_node["kind"].asString() == "string")
tok = Token::StringLiteral; tok = Token::StringLiteral;
else if (_node["kind"].asString() == "hexString")
tok = Token::HexStringLiteral;
else if (_node["kind"].asString() == "bool") else if (_node["kind"].asString() == "bool")
tok = (member(_node, "value").asString() == "true") ? Token::TrueLiteral : Token::FalseLiteral; tok = (member(_node, "value").asString() == "true") ? Token::TrueLiteral : Token::FalseLiteral;
else else

View File

@ -79,7 +79,7 @@
"isConstant": false, "isConstant": false,
"isLValue": false, "isLValue": false,
"isPure": true, "isPure": true,
"kind": "string", "kind": "hexString",
"lValueRequested": false, "lValueRequested": false,
"nodeType": "Literal", "nodeType": "Literal",
"src": "53:7:1", "src": "53:7:1",

View File

@ -130,7 +130,7 @@
"isLValue": false, "isLValue": false,
"isPure": true, "isPure": true,
"lValueRequested": false, "lValueRequested": false,
"token": "string", "token": "hexString",
"type": "literal_string (contains invalid UTF-8 sequence at position 0)" "type": "literal_string (contains invalid UTF-8 sequence at position 0)"
}, },
"id": 5, "id": 5,