diff --git a/docs/grammar/SolidityLexer.g4 b/docs/grammar/SolidityLexer.g4 index 0452f9fa0..d3a387d97 100644 --- a/docs/grammar/SolidityLexer.g4 +++ b/docs/grammar/SolidityLexer.g4 @@ -85,6 +85,7 @@ SignedIntegerType: Storage: 'storage'; String: 'string'; Struct: 'struct'; +Suffix: 'suffix'; True: 'true'; Try: 'try'; Type: 'type'; diff --git a/docs/grammar/SolidityParser.g4 b/docs/grammar/SolidityParser.g4 index d2ef74cff..937d481a5 100644 --- a/docs/grammar/SolidityParser.g4 +++ b/docs/grammar/SolidityParser.g4 @@ -182,7 +182,8 @@ locals[ freeFunctionDefinition: Function (identifier | Fallback | Receive) LParen (arguments=parameterList)? RParen - stateMutability? + stateMutability? Suffix? + | Suffix? stateMutability? (Returns LParen returnParameters=parameterList RParen)? (Semicolon | body=block); @@ -406,6 +407,7 @@ expression: identifier | literal | literalWithSubDenomination + | suffixedLiteral | elementaryTypeName[false] ) # 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. */ -identifier: Identifier | From | Error | Revert | Global; +identifier: Identifier | From | Error | Revert | Global | Suffix; literal: stringLiteral | numberLiteral | booleanLiteral | hexStringLiteral | unicodeStringLiteral; literalWithSubDenomination: numberLiteral SubDenomination; +suffixedLiteral: literal identifier (Period identifier)*; + booleanLiteral: True | False; /** * A full string literal consists of either one or several consecutive quoted strings. diff --git a/scripts/test_antlr_grammar.sh b/scripts/test_antlr_grammar.sh index 3394534f8..406f6144b 100755 --- a/scripts/test_antlr_grammar.sh +++ b/scripts/test_antlr_grammar.sh @@ -129,7 +129,8 @@ done < <( grep -v -E 'license/license_hidden_unicode.sol' | grep -v -E 'license/license_unicode.sol' | # 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=()