User-defined literal suffixes: Grammar

This commit is contained in:
Matheus Aguiar 2023-03-15 18:54:45 -03:00 committed by Kamil Śliwak
parent 00509830d5
commit f97e3884cb
3 changed files with 9 additions and 3 deletions

View File

@ -85,6 +85,7 @@ SignedIntegerType:
Storage: 'storage'; Storage: 'storage';
String: 'string'; String: 'string';
Struct: 'struct'; Struct: 'struct';
Suffix: 'suffix';
True: 'true'; True: 'true';
Try: 'try'; Try: 'try';
Type: 'type'; Type: 'type';

View File

@ -182,7 +182,8 @@ locals[
freeFunctionDefinition: freeFunctionDefinition:
Function (identifier | Fallback | Receive) Function (identifier | Fallback | Receive)
LParen (arguments=parameterList)? RParen LParen (arguments=parameterList)? RParen
stateMutability? stateMutability? Suffix?
| Suffix? stateMutability?
(Returns LParen returnParameters=parameterList RParen)? (Returns LParen returnParameters=parameterList RParen)?
(Semicolon | body=block); (Semicolon | body=block);
@ -406,6 +407,7 @@ expression:
identifier identifier
| literal | literal
| literalWithSubDenomination | literalWithSubDenomination
| suffixedLiteral
| elementaryTypeName[false] | elementaryTypeName[false]
) # PrimaryExpression ) # PrimaryExpression
; ;
@ -421,12 +423,14 @@ inlineArrayExpression: LBrack (expression ( Comma expression)* ) RBrack;
/** /**
* Besides regular non-keyword Identifiers, some keywords like 'from' and 'error' can also be used as identifiers. * Besides regular non-keyword Identifiers, some keywords like 'from' and 'error' can also be used as identifiers.
*/ */
identifier: Identifier | From | Error | Revert | Global; identifier: Identifier | From | Error | Revert | Global | Suffix;
literal: stringLiteral | numberLiteral | booleanLiteral | hexStringLiteral | unicodeStringLiteral; literal: stringLiteral | numberLiteral | booleanLiteral | hexStringLiteral | unicodeStringLiteral;
literalWithSubDenomination: numberLiteral SubDenomination; literalWithSubDenomination: numberLiteral SubDenomination;
suffixedLiteral: literal identifier (Period identifier)*;
booleanLiteral: True | False; booleanLiteral: True | False;
/** /**
* A full string literal consists of either one or several consecutive quoted strings. * A full string literal consists of either one or several consecutive quoted strings.

View File

@ -129,7 +129,8 @@ done < <(
grep -v -E 'license/license_hidden_unicode.sol' | grep -v -E 'license/license_hidden_unicode.sol' |
grep -v -E 'license/license_unicode.sol' | grep -v -E 'license/license_unicode.sol' |
# Skipping tests with 'something.address' as 'address' as the grammar fails on those # Skipping tests with 'something.address' as 'address' as the grammar fails on those
grep -v -E 'inlineAssembly/external_function_pointer_address.*.sol' grep -v -E 'inlineAssembly/external_function_pointer_address.*.sol' |
grep -v -E 'literalSuffixes/application/invalid_address_member_on_suffix.sol'
) )
YUL_FILES=() YUL_FILES=()