Allow hex string literals in Yul.

This commit is contained in:
chriseth
2021-04-08 15:03:33 +02:00
parent 6d6112a81b
commit f04adde664
18 changed files with 64 additions and 12 deletions
+1 -1
View File
@@ -564,5 +564,5 @@ yulPath: YulIdentifier (YulPeriod YulIdentifier)*;
*/
yulFunctionCall: (YulIdentifier | YulEVMBuiltin) YulLParen (yulExpression (YulComma yulExpression)*)? YulRParen;
yulBoolean: YulTrue | YulFalse;
yulLiteral: YulDecimalNumber | YulStringLiteral | YulHexNumber | yulBoolean;
yulLiteral: YulDecimalNumber | YulStringLiteral | YulHexNumber | yulBoolean | YulHexStringLiteral;
yulExpression: yulPath | yulFunctionCall | yulLiteral;
+2 -1
View File
@@ -263,6 +263,7 @@ YulLeave: 'leave';
YulLet: 'let';
YulSwitch: 'switch';
YulTrue: 'true';
YulHex: 'hex';
/**
* Builtin functions in the EVM Yul dialect.
@@ -314,7 +315,7 @@ YulDecimalNumber: '0' | ([1-9] [0-9]*);
YulStringLiteral:
'"' DoubleQuotedStringCharacter* '"'
| '\'' SingleQuotedStringCharacter* '\'';
YulHexStringLiteral: HexString;
YulWS: [ \t\r\n\u000C]+ -> skip ;
YulCOMMENT: '/*' .*? '*/' -> channel(HIDDEN) ;
+4 -1
View File
@@ -174,7 +174,10 @@ whitespace, i.e. there is no terminating ``;`` or newline required.
Literals
--------
You can use integer constants in decimal or hexadecimal notation.
As literals, you can use integer constants in decimal or hexadecimal notation
or strings as ASCII (`"abc"`) or HEX strings (`hex"616263"`) of up to
32 bytes length.
When compiling for the EVM, this will be translated into an
appropriate ``PUSHi`` instruction. In the following example,
``3`` and ``2`` are added resulting in 5 and then the