Skip to content

Commit

Permalink
Update rules.msgb and remove the uses of the ellipsis operator
Browse files Browse the repository at this point in the history
  • Loading branch information
ggiraldez committed Jul 11, 2024
1 parent fe90489 commit 0cab3fc
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 90 deletions.
63 changes: 18 additions & 45 deletions crates/solidity/inputs/language/bindings/rules.msgb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ attribute symbol_reference = symbol => type = "push_symbol", symbol = symbol, i
node @contract.defs
}

@contract [ContractDefinition ... @name name: [Identifier] ...] {
@contract [ContractDefinition @name name: [Identifier]] {
node def
attr (def) node_definition = @name

Expand All @@ -44,11 +44,9 @@ attribute symbol_reference = symbol => type = "push_symbol", symbol = symbol, i
}

;; Connect the contract to its containing source unit
@source_unit [SourceUnit ... [SourceUnitMembers
...
@source_unit [SourceUnit [SourceUnitMembers
[SourceUnitMember @contract [ContractDefinition]]
...
] ...] {
]] {
edge @source_unit.defs -> @contract.defs
edge @contract.lexical_scope -> @source_unit.lexical_scope
}
Expand All @@ -63,7 +61,7 @@ attribute symbol_reference = symbol => type = "push_symbol", symbol = symbol, i
node @interface.defs
}

@interface [InterfaceDefinition ... @name name: [Identifier] ...] {
@interface [InterfaceDefinition @name name: [Identifier]] {
node def
attr (def) node_definition = @name

Expand All @@ -73,9 +71,7 @@ attribute symbol_reference = symbol => type = "push_symbol", symbol = symbol, i

;; Connect the interface to its containing source unit
@source_unit [SourceUnit [SourceUnitMembers
...
[SourceUnitMember @interface [InterfaceDefinition]]
...
]] {
edge @source_unit.defs -> @interface.defs
edge @interface.lexical_scope -> @source_unit.lexical_scope
Expand All @@ -91,7 +87,7 @@ attribute symbol_reference = symbol => type = "push_symbol", symbol = symbol, i
node @library.defs
}

@library [LibraryDefinition ... @name name: [Identifier] ...] {
@library [LibraryDefinition @name name: [Identifier]] {
node def
attr (def) node_definition = @name

Expand All @@ -101,9 +97,7 @@ attribute symbol_reference = symbol => type = "push_symbol", symbol = symbol, i

;; Connect the library to its containing source unit
@source_unit [SourceUnit [SourceUnitMembers
...
[SourceUnitMember @library [LibraryDefinition]]
...
]] {
edge @source_unit.defs -> @library.defs
edge @library.lexical_scope -> @source_unit.lexical_scope
Expand All @@ -119,7 +113,7 @@ attribute symbol_reference = symbol => type = "push_symbol", symbol = symbol, i
node @function.defs
}

@function [FunctionDefinition ... name: [FunctionName ... @name [Identifier] ...] ...] {
@function [FunctionDefinition name: [FunctionName @name [Identifier]]] {
node def
attr (def) node_definition = @name

Expand All @@ -132,7 +126,7 @@ attribute symbol_reference = symbol => type = "push_symbol", symbol = symbol, i
node @param.defs
}

@param [Parameter ... @name [Identifier]] {
@param [Parameter @name [Identifier]] {
node def
attr (def) node_definition = @name

Expand All @@ -142,23 +136,17 @@ attribute symbol_reference = symbol => type = "push_symbol", symbol = symbol, i

;; Connect the parameters to the functions they belong to
@function [FunctionDefinition
...
parameters: [_ ... parameters: [Parameters ... @param item: [Parameter] ...] ...]
...
parameters: [_ parameters: [Parameters @param item: [Parameter]]]
] {
edge @function.lexical_scope -> @param.defs
edge @function.defs -> @param.defs
}

;; Connect the function to the contract/interface/library they belong to
[SourceUnitMember @unit_member variant: [_
...
members: [_
...
item: [_ @function variant: [FunctionDefinition]]
...
]
...
]
] {
edge @unit_member.lexical_scope -> @function.defs
Expand All @@ -172,7 +160,7 @@ attribute symbol_reference = symbol => type = "push_symbol", symbol = symbol, i
}

;; Connect the function body to the function definition
@function [FunctionDefinition ... @body body: [FunctionBody] ...] {
@function [FunctionDefinition @body body: [FunctionBody]] {
edge @body.lexical_scope -> @function.lexical_scope
edge @function.defs -> @body.defs
}
Expand All @@ -192,7 +180,7 @@ attribute symbol_reference = symbol => type = "push_symbol", symbol = symbol, i
node @stmt.defs
}

@block [Block ... statements: [_ ... @stmt [Statement]...] ...] {
@block [Block statements: [_ @stmt [Statement]]] {
edge @stmt.lexical_scope -> @block.lexical_scope
edge @block.defs -> @stmt.defs
}
Expand All @@ -207,7 +195,7 @@ attribute symbol_reference = symbol => type = "push_symbol", symbol = symbol, i
;;; Declaration Statements
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

@stmt [Statement [VariableDeclarationStatement ... @name name: [Identifier] ...]] {
@stmt [Statement [VariableDeclarationStatement @name name: [Identifier]]] {
node def
attr (def) node_definition = @name

Expand All @@ -216,13 +204,9 @@ attribute symbol_reference = symbol => type = "push_symbol", symbol = symbol, i
}

@stmt [Statement [TupleDeconstructionStatement
...
[TupleDeconstructionElements
...
item: [_ member: [_ variant: [_ ... @name name: [Identifier]]]]
...
item: [_ member: [_ variant: [_ @name name: [Identifier]]]]
]
...
]] {
node def
attr (def) node_definition = @name
Expand All @@ -241,7 +225,7 @@ attribute symbol_reference = symbol => type = "push_symbol", symbol = symbol, i
node @state_var.defs
}

@state_var [StateVariableDefinition ... @name name: [Identifier] ...] {
@state_var [StateVariableDefinition @name name: [Identifier]] {
node def
attr (def) node_definition = @name

Expand All @@ -250,13 +234,9 @@ attribute symbol_reference = symbol => type = "push_symbol", symbol = symbol, i
}

[SourceUnitMember @unit_member variant: [_
...
members: [_
...
item: [_ @state_var variant: [StateVariableDefinition]]
...
]
...
]
] {
edge @unit_member.lexical_scope -> @state_var.defs
Expand All @@ -273,7 +253,7 @@ attribute symbol_reference = symbol => type = "push_symbol", symbol = symbol, i
node @struct.defs
}

@struct [StructDefinition ... @name name: [Identifier] ...] {
@struct [StructDefinition @name name: [Identifier]] {
node def
attr (def) node_definition = @name

Expand All @@ -283,13 +263,9 @@ attribute symbol_reference = symbol => type = "push_symbol", symbol = symbol, i

;; Connect the struct to the contract/interface/library they belong to
[SourceUnitMember @unit_member variant: [_
...
members: [_
...
item: [_ @struct variant: [StructDefinition]]
...
]
...
]
] {
edge @unit_member.lexical_scope -> @struct.defs
Expand All @@ -301,7 +277,7 @@ attribute symbol_reference = symbol => type = "push_symbol", symbol = symbol, i
node @member.defs
}

@member item: [StructMember ... @name name: [Identifier] ...] {
@member item: [StructMember @name name: [Identifier]] {
node member
attr (member) pop_symbol = "."
edge @member.defs -> member
Expand All @@ -322,18 +298,18 @@ attribute symbol_reference = symbol => type = "push_symbol", symbol = symbol, i
node @expr.lexical_scope
}

@expr [Expression ... @name variant: [Identifier]] {
@expr [Expression @name variant: [Identifier]] {
node ref
attr (ref) node_reference = @name

edge ref -> @expr.lexical_scope
}

@expr [Expression ... variant: [_ ... @child [Expression] ...] ...] {
@expr [Expression variant: [_ @child [Expression]]] {
edge @child.lexical_scope -> @expr.lexical_scope
}

@stmt [Statement ... variant: [_ ... @expr [Expression] ...] ...] {
@stmt [Statement variant: [_ @expr [Expression]]] {
edge @expr.lexical_scope -> @stmt.lexical_scope
}

Expand All @@ -349,11 +325,8 @@ attribute symbol_reference = symbol => type = "push_symbol", symbol = symbol, i
}

[MemberAccessExpression
...
@expr operand: [Expression]
...
@member member: [MemberAccess]
...
] {
node member
attr (member) push_symbol = "."
Expand Down
Loading

0 comments on commit 0cab3fc

Please sign in to comment.