Skip to content

Commit

Permalink
Do the same for Repeated nodes in v2
Browse files Browse the repository at this point in the history
  • Loading branch information
Xanewok committed Nov 20, 2023
1 parent 1d35427 commit 8b463ee
Showing 1 changed file with 33 additions and 68 deletions.
101 changes: 33 additions & 68 deletions crates/solidity/inputs/language/src/definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,9 @@ codegen_language_macros::compile!(Language(
items = [
Struct(
name = SourceUnit,
fields = (members = Required(NonTerminal(SourceUnitMembers)))
),
Repeated(
name = SourceUnitMembers,
repeated = SourceUnitMember,
allow_empty = true
fields = (members = Optional(kind = NonTerminal(SourceUnitMembers)))
),
Repeated(name = SourceUnitMembers, repeated = SourceUnitMember),
Enum(
name = SourceUnitMember,
variants = [
Expand Down Expand Up @@ -2101,7 +2097,7 @@ codegen_language_macros::compile!(Language(
name = Required(Terminal([Identifier])),
inheritence = Optional(kind = NonTerminal(InheritanceSpecifier)),
open_brace = Required(Terminal([OpenBrace])),
members = Required(NonTerminal(ContractMembers)),
members = Optional(kind = NonTerminal(ContractMembers)),
close_brace = Required(Terminal([CloseBrace]))
)
),
Expand All @@ -2124,11 +2120,7 @@ codegen_language_macros::compile!(Language(
arguments = Optional(kind = NonTerminal(ArgumentsDeclaration))
)
),
Repeated(
name = ContractMembers,
repeated = ContractMember,
allow_empty = true
),
Repeated(name = ContractMembers, repeated = ContractMember),
Enum(
name = ContractMember,
variants = [
Expand Down Expand Up @@ -2190,15 +2182,11 @@ codegen_language_macros::compile!(Language(
name = Required(Terminal([Identifier])),
inheritence = Optional(kind = NonTerminal(InheritanceSpecifier)),
open_brace = Required(Terminal([OpenBrace])),
members = Required(NonTerminal(InterfaceMembers)),
members = Optional(kind = NonTerminal(InterfaceMembers)),
close_brace = Required(Terminal([CloseBrace]))
)
),
Repeated(
name = InterfaceMembers,
repeated = ContractMember,
allow_empty = true
)
Repeated(name = InterfaceMembers, repeated = ContractMember)
]
),
Topic(
Expand All @@ -2214,15 +2202,11 @@ codegen_language_macros::compile!(Language(
library_keyword = Required(Terminal([LibraryKeyword])),
name = Required(Terminal([Identifier])),
open_brace = Required(Terminal([OpenBrace])),
members = Required(NonTerminal(LibraryMembers)),
members = Optional(kind = NonTerminal(LibraryMembers)),
close_brace = Required(Terminal([CloseBrace]))
)
),
Repeated(
name = LibraryMembers,
repeated = ContractMember,
allow_empty = true
)
Repeated(name = LibraryMembers, repeated = ContractMember)
]
),
Topic(
Expand All @@ -2238,15 +2222,11 @@ codegen_language_macros::compile!(Language(
struct_keyword = Required(Terminal([StructKeyword])),
name = Required(Terminal([Identifier])),
open_brace = Required(Terminal([OpenBrace])),
members = Required(NonTerminal(StructMembers)),
members = Optional(kind = NonTerminal(StructMembers)),
close_brace = Required(Terminal([CloseBrace]))
)
),
Repeated(
name = StructMembers,
repeated = StructMember,
allow_empty = true
),
Repeated(name = StructMembers, repeated = StructMember),
Struct(
name = StructMember,
error_recovery = FieldsErrorRecovery(terminator = semicolon),
Expand Down Expand Up @@ -2306,7 +2286,7 @@ codegen_language_macros::compile!(Language(
error_recovery = FieldsErrorRecovery(terminator = semicolon),
fields = (
type_name = Required(NonTerminal(TypeName)),
attributes = Required(NonTerminal(StateVariableAttributes)),
attributes = Optional(kind = NonTerminal(StateVariableAttributes)),
name = Required(Terminal([Identifier])),
value = Optional(kind = NonTerminal(StateVariableDefinitionValue)),
semicolon = Required(Terminal([Semicolon]))
Expand All @@ -2321,8 +2301,7 @@ codegen_language_macros::compile!(Language(
),
Repeated(
name = StateVariableAttributes,
repeated = StateVariableAttribute,
allow_empty = true
repeated = StateVariableAttribute
),
Enum(
name = StateVariableAttribute,
Expand Down Expand Up @@ -2354,7 +2333,7 @@ codegen_language_macros::compile!(Language(
ReceiveKeyword
])),
parameters = Required(NonTerminal(ParametersDeclaration)),
attributes = Required(NonTerminal(FunctionAttributes)),
attributes = Optional(kind = NonTerminal(FunctionAttributes)),
returns = Optional(kind = NonTerminal(ReturnsDeclaration)),
body = Required(NonTerminal(FunctionBody))
)
Expand All @@ -2380,11 +2359,7 @@ codegen_language_macros::compile!(Language(
name = Optional(kind = Terminal([Identifier]))
)
),
Repeated(
name = FunctionAttributes,
repeated = FunctionAttribute,
allow_empty = true
),
Repeated(name = FunctionAttributes, repeated = FunctionAttribute),
Enum(
name = FunctionAttribute,
variants = [
Expand Down Expand Up @@ -2447,15 +2422,14 @@ codegen_language_macros::compile!(Language(
fields = (
constructor_keyword = Required(Terminal([ConstructorKeyword])),
parameters = Required(NonTerminal(ParametersDeclaration)),
attributes = Required(NonTerminal(ConstructorAttributes)),
attributes = Optional(kind = NonTerminal(ConstructorAttributes)),
body = Required(NonTerminal(Block))
)
),
Repeated(
name = ConstructorAttributes,
repeated = ConstructorAttribute,
enabled = From("0.4.22"),
allow_empty = true
enabled = From("0.4.22")
),
Enum(
name = ConstructorAttribute,
Expand All @@ -2473,15 +2447,15 @@ codegen_language_macros::compile!(Language(
fields = (
function_keyword = Required(Terminal([FunctionKeyword])),
parameters = Required(NonTerminal(ParametersDeclaration)),
attributes = Required(NonTerminal(UnnamedFunctionAttributes)),
attributes =
Optional(kind = NonTerminal(UnnamedFunctionAttributes)),
body = Required(NonTerminal(FunctionBody))
)
),
Repeated(
name = UnnamedFunctionAttributes,
repeated = UnnamedFunctionAttribute,
enabled = Till("0.6.0"),
allow_empty = true
enabled = Till("0.6.0")
),
Enum(
name = UnnamedFunctionAttribute,
Expand All @@ -2501,16 +2475,16 @@ codegen_language_macros::compile!(Language(
fields = (
fallback_keyword = Required(Terminal([FallbackKeyword])),
parameters = Required(NonTerminal(ParametersDeclaration)),
attributes = Required(NonTerminal(FallbackFunctionAttributes)),
attributes =
Optional(kind = NonTerminal(FallbackFunctionAttributes)),
returns = Optional(kind = NonTerminal(ReturnsDeclaration)),
body = Required(NonTerminal(FunctionBody))
)
),
Repeated(
name = FallbackFunctionAttributes,
repeated = FallbackFunctionAttribute,
enabled = From("0.6.0"),
allow_empty = true
enabled = From("0.6.0")
),
Enum(
name = FallbackFunctionAttribute,
Expand All @@ -2531,15 +2505,15 @@ codegen_language_macros::compile!(Language(
fields = (
receive_keyword = Required(Terminal([ReceiveKeyword])),
parameters = Required(NonTerminal(ParametersDeclaration)),
attributes = Required(NonTerminal(ReceiveFunctionAttributes)),
attributes =
Optional(kind = NonTerminal(ReceiveFunctionAttributes)),
body = Required(NonTerminal(FunctionBody))
)
),
Repeated(
name = ReceiveFunctionAttributes,
repeated = ReceiveFunctionAttribute,
enabled = From("0.6.0"),
allow_empty = true
enabled = From("0.6.0")
),
Enum(
name = ReceiveFunctionAttribute,
Expand All @@ -2563,15 +2537,11 @@ codegen_language_macros::compile!(Language(
modifier_keyword = Required(Terminal([ModifierKeyword])),
name = Required(Terminal([Identifier])),
parameters = Optional(kind = NonTerminal(ParametersDeclaration)),
attributes = Required(NonTerminal(ModifierAttributes)),
attributes = Optional(kind = NonTerminal(ModifierAttributes)),
body = Required(NonTerminal(FunctionBody))
)
),
Repeated(
name = ModifierAttributes,
repeated = ModifierAttribute,
allow_empty = true
),
Repeated(name = ModifierAttributes, repeated = ModifierAttribute),
Enum(
name = ModifierAttribute,
variants = [
Expand Down Expand Up @@ -2730,14 +2700,13 @@ codegen_language_macros::compile!(Language(
fields = (
function_keyword = Required(Terminal([FunctionKeyword])),
parameters = Required(NonTerminal(ParametersDeclaration)),
attributes = Required(NonTerminal(FunctionTypeAttributes)),
attributes = Optional(kind = NonTerminal(FunctionTypeAttributes)),
returns = Optional(kind = NonTerminal(ReturnsDeclaration))
)
),
Repeated(
name = FunctionTypeAttributes,
repeated = FunctionTypeAttribute,
allow_empty = true
repeated = FunctionTypeAttribute
),
Enum(
name = FunctionTypeAttribute,
Expand Down Expand Up @@ -2848,11 +2817,11 @@ codegen_language_macros::compile!(Language(
),
fields = (
open_brace = Required(Terminal([OpenBrace])),
statements = Required(NonTerminal(Statements)),
statements = Optional(kind = NonTerminal(Statements)),
close_brace = Required(Terminal([CloseBrace]))
)
),
Repeated(name = Statements, repeated = Statement, allow_empty = true),
Repeated(name = Statements, repeated = Statement),
Enum(
name = Statement,
variants = [
Expand Down Expand Up @@ -4037,15 +4006,11 @@ codegen_language_macros::compile!(Language(
),
fields = (
open_brace = Required(Terminal([OpenBrace])),
statements = Required(NonTerminal(YulStatements)),
statements = Optional(kind = NonTerminal(YulStatements)),
close_brace = Required(Terminal([CloseBrace]))
)
),
Repeated(
name = YulStatements,
repeated = YulStatement,
allow_empty = true
),
Repeated(name = YulStatements, repeated = YulStatement),
Enum(
name = YulStatement,
variants = [
Expand Down

0 comments on commit 8b463ee

Please sign in to comment.