Distinguish between stringLiteral and hexStringLiteral in the JSON AST

This commit is contained in:
Alex Beregszaszi 2020-07-27 09:52:36 +01:00
parent 7ad27188a0
commit 5ecc84e92e
6 changed files with 8 additions and 3 deletions

View File

@ -3,6 +3,7 @@
Breaking changes:
* 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``.
* JSON AST: Mark hex string literals with ``kind: "hexString"``.
* JSON AST: Remove members with ``null`` value from JSON output.
* Parser: Disallow ``gwei`` as identifier.
* Parser: Disallow dot syntax for ``value`` and ``gas``.

View File

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

View File

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

View File

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

View File

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

View File

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