mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
User-defined operators: Parsing and grammar
This commit is contained in:
@@ -311,11 +311,35 @@ errorDefinition:
|
||||
LParen (parameters+=errorParameter (Comma parameters+=errorParameter)*)? RParen
|
||||
Semicolon;
|
||||
|
||||
/**
|
||||
* Operators that users are allowed to implement for some types with `using for`.
|
||||
*/
|
||||
userDefinableOperator:
|
||||
BitAnd
|
||||
| BitNot
|
||||
| BitOr
|
||||
| BitXor
|
||||
| Sar
|
||||
| Shl
|
||||
| Add
|
||||
| Div
|
||||
| Exp
|
||||
| Mod
|
||||
| Mul
|
||||
| Sub
|
||||
| Equal
|
||||
| GreaterThan
|
||||
| GreaterThanOrEqual
|
||||
| LessThan
|
||||
| LessThanOrEqual
|
||||
| NotEqual
|
||||
| Not;
|
||||
|
||||
/**
|
||||
* Using directive to attach library functions and free functions to types.
|
||||
* Can occur within contracts and libraries and at the file level.
|
||||
*/
|
||||
usingDirective: Using (identifierPath | (LBrace identifierPath (Comma identifierPath)* RBrace)) For (Mul | typeName) Global? Semicolon;
|
||||
usingDirective: Using (identifierPath | (LBrace identifierPath (As userDefinableOperator)? (Comma identifierPath (As userDefinableOperator)?)* RBrace)) For (Mul | typeName) Global? Semicolon;
|
||||
/**
|
||||
* A type name can be an elementary type, a function type, a mapping type, a user-defined type
|
||||
* (e.g. a contract or struct) or an array type.
|
||||
|
||||
Reference in New Issue
Block a user