Skip to content

Commit fb9d550

Browse files
committed
Addressed (some) comments
1 parent 516671f commit fb9d550

File tree

11 files changed

+191
-218
lines changed

11 files changed

+191
-218
lines changed

crates/solidity-v2/inputs/language/src/BREAKING_CHANGES.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,29 +28,31 @@ We should consider adding validation for these at a later stage if needed:
2828
- `HexLiteral` and `YulHexLiteral` and `DecimalLiteral` and `YulDecimalLiteral`:
2929
- It was illegal for them to be followed by `IdentifierStart`. Now we will produce two separate tokens rather than rejecting it.
3030

31-
## Language Definition Changes
31+
## Grammar
3232

3333
The following changes modify the language definition to support the new parser and resolve grammar ambiguities.
3434
In some cases we also try to simplify the model.
3535

3636
### AddressKeyword
3737

3838
- Made the `address` keyword reserved in all versions, handling the few cases where it can be used as an identifier separately.
39-
- `MemberAccessIdentifier` handles the cases where `address` can be used as an `Identifier`, either in an `IdentifierPath` or a `MemberAccessExpression`.
39+
- `IdentifierPathElement` handles the cases where `address` can be used as an `Identifier`, either in an `IdentifierPath` or a `MemberAccessExpression`.
4040

41-
### MemberAccessIdentifier
41+
### IdentifierPathElement
4242

43-
New enum added to allow the reserved `address` keyword in member access expressions (from Solidity 0.6.0):
43+
New enum added to allow the reserved `address` keyword in identifier paths and member access expressions
44+
(from Solidity 0.6.0):
4445

4546
- Variants: `Identifier` | `AddressKeyword` (enabled from 0.6.0)
46-
- Used in `MemberAccessExpression` (previously just `Identifier`) and in `IdentifierPathTailElements` (for identifier path tails)
47+
- Used in `MemberAccessExpression` and in `IdentifierPath`
4748

4849
### IdentifierPath
4950

50-
Changed from a simple `Separated` list to a structured format to allow the reserved `address` keyword to appear in identifier paths (but not as the head):
51+
Changed from a `Separated` list of `Identifier`, to a list of `IdentifierPathElement`, to capture the reserved
52+
`AddressKeyword` as part of the path.
5153

5254
- **Before**: `Separated(name = IdentifierPath, reference = Identifier, separator = Period)`
53-
- **After**: `Struct` with `head: Identifier` and `tail: Optional<IdentifierPathTail>`, where `IdentifierPathTail` contains a `Period` separator followed by `IdentifierPathTailElements` (a `Separated` list of `MemberAccessIdentifier`).
55+
- **After**: `Separated(name = IdentifierPath, reference = IdentifierPathElement, separator = Period)`
5456

5557
### TupleDeconstructionStatement
5658

crates/solidity-v2/inputs/language/src/definition.rs

Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ language_v2_macros::compile!(Language(
496496
// `address` is a reserved keyword, but it can still be used as an identifier in some contexts,
497497
// in particular as a member access (e.g., `myPayload.address`) or as an identifier
498498
// path
499-
// See `MemberAccessIdentifier` for details
499+
// See `IdentifierPathElement` for details
500500
name = AddressKeyword,
501501
identifier = Identifier,
502502
definitions = [KeywordDefinition(value = Atom("address"))]
@@ -3528,7 +3528,7 @@ language_v2_macros::compile!(Language(
35283528
model = Postfix,
35293529
fields = (
35303530
period = Required(Period),
3531-
member = Required(MemberAccessIdentifier)
3531+
member = Required(IdentifierPathElement)
35323532
)
35333533
)]
35343534
),
@@ -3580,14 +3580,6 @@ language_v2_macros::compile!(Language(
35803580
colon = Required(Colon),
35813581
end = Optional(reference = Expression)
35823582
)
3583-
),
3584-
Enum(
3585-
// A member access can be either an identifier or the reserved `address` keyword
3586-
name = MemberAccessIdentifier,
3587-
variants = [
3588-
EnumVariant(reference = Identifier),
3589-
EnumVariant(reference = AddressKeyword, enabled = From("0.6.0"))
3590-
]
35913583
)
35923584
]
35933585
),
@@ -4024,27 +4016,21 @@ language_v2_macros::compile!(Language(
40244016
lexical_context = Solidity,
40254017
items = [
40264018
// Since an identifier path can include the reserved keyword `address` as parth of the path
4027-
// (but not as the head), we differentiate between head (any `Identifier`)
4028-
// and tail (which can use `MemberAccessIdentifier`)
4029-
Struct(
4030-
name = IdentifierPath,
4031-
fields = (
4032-
head = Required(Identifier),
4033-
tail = Optional(reference = IdentifierPathTail)
4034-
)
4035-
),
4036-
Struct(
4037-
name = IdentifierPathTail,
4038-
fields = (
4039-
sep = Required(Period),
4040-
elements = Required(IdentifierPathTailElements)
4041-
)
4042-
),
4019+
// we use `IdentifierPathElement` to represent each element, instead of `Identifier`.
40434020
Separated(
4044-
name = IdentifierPathTailElements,
4045-
reference = MemberAccessIdentifier,
4021+
name = IdentifierPath,
4022+
reference = IdentifierPathElement,
40464023
separator = Period
40474024
),
4025+
Enum(
4026+
// An element of an identifier path can be either an identifier or the reserved `address` keyword
4027+
// Note: This is also used on `MemberAccessExpression`
4028+
name = IdentifierPathElement,
4029+
variants = [
4030+
EnumVariant(reference = Identifier),
4031+
EnumVariant(reference = AddressKeyword, enabled = From("0.6.0"))
4032+
]
4033+
),
40484034
Token(
40494035
name = Identifier,
40504036
definitions = [TokenDefinition(Sequence([

crates/solidity-v2/outputs/cargo/cst/src/structured_cst/nodes.generated.rs

Lines changed: 22 additions & 51 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/solidity-v2/outputs/cargo/parser/src/parser/temp_cst_output/node_checker.generated.rs

Lines changed: 54 additions & 72 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)