mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
User-defined literal suffixes: Grammar
This commit is contained in:
parent
81118c729e
commit
5d59bbeca6
@ -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';
|
||||||
|
@ -16,7 +16,7 @@ sourceUnit: (
|
|||||||
| contractDefinition
|
| contractDefinition
|
||||||
| interfaceDefinition
|
| interfaceDefinition
|
||||||
| libraryDefinition
|
| libraryDefinition
|
||||||
| functionDefinition
|
| functionDefinition[true]
|
||||||
| constantVariableDeclaration
|
| constantVariableDeclaration
|
||||||
| structDefinition
|
| structDefinition
|
||||||
| enumDefinition
|
| enumDefinition
|
||||||
@ -85,7 +85,7 @@ inheritanceSpecifier: name=identifierPath arguments=callArgumentList?;
|
|||||||
*/
|
*/
|
||||||
contractBodyElement:
|
contractBodyElement:
|
||||||
constructorDefinition
|
constructorDefinition
|
||||||
| functionDefinition
|
| functionDefinition[false]
|
||||||
| modifierDefinition
|
| modifierDefinition
|
||||||
| fallbackFunctionDefinition
|
| fallbackFunctionDefinition
|
||||||
| receiveFunctionDefinition
|
| receiveFunctionDefinition
|
||||||
@ -156,10 +156,11 @@ overrideSpecifier: Override (LParen overrides+=identifierPath (Comma overrides+=
|
|||||||
* Depending on the context in which the function is defined, further restrictions may apply,
|
* Depending on the context in which the function is defined, further restrictions may apply,
|
||||||
* e.g. functions in interfaces have to be unimplemented, i.e. may not contain a body block.
|
* e.g. functions in interfaces have to be unimplemented, i.e. may not contain a body block.
|
||||||
*/
|
*/
|
||||||
functionDefinition
|
functionDefinition[boolean free]
|
||||||
locals[
|
locals[
|
||||||
boolean visibilitySet = false,
|
boolean visibilitySet = false,
|
||||||
boolean mutabilitySet = false,
|
boolean mutabilitySet = false,
|
||||||
|
boolean suffixSet = false,
|
||||||
boolean virtualSet = false,
|
boolean virtualSet = false,
|
||||||
boolean overrideSpecifierSet = false,
|
boolean overrideSpecifierSet = false,
|
||||||
]
|
]
|
||||||
@ -169,7 +170,8 @@ locals[
|
|||||||
(
|
(
|
||||||
{!$visibilitySet}? visibility {$visibilitySet = true;}
|
{!$visibilitySet}? visibility {$visibilitySet = true;}
|
||||||
| {!$mutabilitySet}? stateMutability {$mutabilitySet = true;}
|
| {!$mutabilitySet}? stateMutability {$mutabilitySet = true;}
|
||||||
| modifierInvocation
|
| {!$free}? modifierInvocation
|
||||||
|
| {$free}? {!$suffixSet}? Suffix {$suffixSet = true;}
|
||||||
| {!$virtualSet}? Virtual {$virtualSet = true;}
|
| {!$virtualSet}? Virtual {$virtualSet = true;}
|
||||||
| {!$overrideSpecifierSet}? overrideSpecifier {$overrideSpecifierSet = true;}
|
| {!$overrideSpecifierSet}? overrideSpecifier {$overrideSpecifierSet = true;}
|
||||||
)*
|
)*
|
||||||
@ -396,6 +398,7 @@ expression:
|
|||||||
identifier
|
identifier
|
||||||
| literal
|
| literal
|
||||||
| literalWithSubDenomination
|
| literalWithSubDenomination
|
||||||
|
| suffixedLiteral
|
||||||
| elementaryTypeName[false]
|
| elementaryTypeName[false]
|
||||||
) # PrimaryExpression
|
) # PrimaryExpression
|
||||||
;
|
;
|
||||||
@ -411,12 +414,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.
|
||||||
|
@ -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=()
|
||||||
|
Loading…
Reference in New Issue
Block a user