Skip to content

Commit

Permalink
Adjust antlr grammar
Browse files Browse the repository at this point in the history
  • Loading branch information
matheusaaguiar committed Apr 24, 2024
1 parent 53615d2 commit b0e31af
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
1 change: 1 addition & 0 deletions docs/grammar/SolidityLexer.g4
Expand Up @@ -85,6 +85,7 @@ SignedIntegerType:
Storage: 'storage';
String: 'string';
Struct: 'struct';
Transient: 'transient';
True: 'true';
Try: 'try';
Type: 'type';
Expand Down
20 changes: 15 additions & 5 deletions docs/grammar/SolidityParser.g4
Expand Up @@ -165,7 +165,7 @@ locals[
boolean overrideSpecifierSet = false,
]
:
Function (identifier | Fallback | Receive)
Function (identifier | Fallback | Receive | Transient)
LParen (arguments=parameterList)? RParen
(
{!$visibilitySet}? visibility {$visibilitySet = true;}
Expand Down Expand Up @@ -273,7 +273,10 @@ locals [boolean constantnessSet = false, boolean visibilitySet = false, boolean
| {!$overrideSpecifierSet}? overrideSpecifier {$overrideSpecifierSet = true;}
| {!$constantnessSet}? Immutable {$constantnessSet = true;}
)*
name=identifier
(
location=Transient name=identifier
| name=identifier
)
(Assign initialValue=expression)?
Semicolon;

Expand Down Expand Up @@ -364,7 +367,14 @@ locals [boolean visibilitySet = false, boolean mutabilitySet = false]
/**
* The declaration of a single variable.
*/
variableDeclaration: type=typeName location=dataLocation? name=identifier;
variableDeclaration
:
type=typeName
(
Tlocation=Transient name=identifier?
| location=dataLocation? name=identifier
);

dataLocation: Memory | Storage | Calldata;

/**
Expand Down Expand Up @@ -419,7 +429,7 @@ 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 | Transient;

literal: stringLiteral | numberLiteral | booleanLiteral | hexStringLiteral | unicodeStringLiteral;

Expand Down Expand Up @@ -497,7 +507,7 @@ tryStatement: Try expression (Returns LParen returnParameters=parameterList RPar
*/
catchClause: Catch (identifier? LParen (arguments=parameterList) RParen)? block;

returnStatement: Return expression? Semicolon;
returnStatement: Return (expression | Transient)? Semicolon;
/**
* An emit statement. The contained expression needs to refer to an event.
*/
Expand Down

0 comments on commit b0e31af

Please sign in to comment.