Skip to content

Commit

Permalink
Change version pragma grammar to be more constrained (#1086)
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonyBlakey authored Aug 23, 2024
1 parent 8a11407 commit f749e53
Show file tree
Hide file tree
Showing 40 changed files with 384 additions and 396 deletions.
5 changes: 5 additions & 0 deletions .changeset/spotty-houses-watch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@nomicfoundation/slang": patch
---

The grammar for `VersionExpressionSet` has changed to more accurately model the allowed structure.
88 changes: 40 additions & 48 deletions crates/solidity/inputs/language/src/definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,59 +132,51 @@ codegen_language_macros::compile!(Language(
separator = BarBar
),
Repeated(name = VersionExpressionSet, reference = VersionExpression),
Precedence(
Enum(
name = VersionExpression,
precedence_expressions = [
PrecedenceExpression(
name = VersionRange,
operators = [PrecedenceOperator(
model = BinaryLeftAssociative,
fields = (operator = Required(Minus))
)]
),
PrecedenceExpression(
name = VersionComparator,
operators = [
PrecedenceOperator(
model = Prefix,
fields = (operator = Required(Caret))
),
PrecedenceOperator(
model = Prefix,
fields = (operator = Required(Tilde))
),
PrecedenceOperator(
model = Prefix,
fields = (operator = Required(Equal))
),
PrecedenceOperator(
model = Prefix,
fields = (operator = Required(LessThan))
),
PrecedenceOperator(
model = Prefix,
fields = (operator = Required(GreaterThan))
),
PrecedenceOperator(
model = Prefix,
fields = (operator = Required(LessThanEqual))
),
PrecedenceOperator(
model = Prefix,
fields = (operator = Required(GreaterThanEqual))
)
]
)
],
primary_expressions = [
PrimaryExpression(reference = VersionSpecifiers),
PrimaryExpression(reference = SingleQuotedVersionLiteral),
PrimaryExpression(reference = DoubleQuotedVersionLiteral)
variants = [
EnumVariant(reference = VersionRange),
EnumVariant(reference = VersionTerm)
]
),
Struct(
name = VersionRange,
fields = (
start = Required(VersionLiteral),
minus = Required(Minus),
end = Required(VersionLiteral)
)
),
Struct(
name = VersionTerm,
fields = (
operator = Optional(reference = VersionOperator),
literal = Required(VersionLiteral)
)
),
Enum(
name = VersionOperator,
variants = [
EnumVariant(reference = Caret),
EnumVariant(reference = Tilde),
EnumVariant(reference = Equal),
EnumVariant(reference = LessThan),
EnumVariant(reference = GreaterThan),
EnumVariant(reference = LessThanEqual),
EnumVariant(reference = GreaterThanEqual)
]
),
Enum(
name = VersionLiteral,
variants = [
EnumVariant(reference = SimpleVersionLiteral),
EnumVariant(reference = SingleQuotedVersionLiteral),
EnumVariant(reference = DoubleQuotedVersionLiteral)
]
),
Separated(
// __SLANG_VERSION_SPECIFIER_SYNTAX__ (keep in sync)
name = VersionSpecifiers,
name = SimpleVersionLiteral,
reference = VersionSpecifier,
separator = Period
),
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit f749e53

Please sign in to comment.