mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Begin fixing expression syntax
This commit is contained in:
parent
1c341add59
commit
5512b85594
@ -7,12 +7,12 @@ Imports = StringLiteral ('as' Identifier)?
|
|||||||
| ('*' | Identifier) ('as' Identifier)? 'from' StringLiteral
|
| ('*' | Identifier) ('as' Identifier)? 'from' StringLiteral
|
||||||
| '{' Identifier ('as' Identifier)? ( ',' Identifier ('as' Identifier)? )* '}' 'from' StringLiteral
|
| '{' Identifier ('as' Identifier)? ( ',' Identifier ('as' Identifier)? )* '}' 'from' StringLiteral
|
||||||
|
|
||||||
ContractPart = StateVariableDeclaration | UsingDeclaration
|
ContractPart = StateVariableDecOrDef | UsingDeclaration
|
||||||
| StructDefinition | ModifierDefinition | FunctionDefinition | EventDefinition | EnumDefinition
|
| StructDefinition | ModifierDefinition | FunctionDefinition | EventDefinition | EnumDefinition
|
||||||
|
|
||||||
InheritanceSpecifier = Identifier ( '(' Expression ( ',' Expression )* ')' )?
|
InheritanceSpecifier = Identifier ( '(' Expression ( ',' Expression )* ')' )?
|
||||||
|
|
||||||
StateVariableDeclaration = TypeName ( 'public' | 'internal' | 'private' )? Identifier ';'
|
StateVariableDecOrDef = TypeName ( 'public' | 'internal' | 'private' )? Identifier ('=' Expression)? ';'
|
||||||
UsingDeclaration = 'using' Identifier 'for' TypeName ';'
|
UsingDeclaration = 'using' Identifier 'for' TypeName ';'
|
||||||
StructDefinition = 'struct' Identifier '{'
|
StructDefinition = 'struct' Identifier '{'
|
||||||
( VariableDeclaration ';' (VariableDeclaration ';')* )? '}'
|
( VariableDeclaration ';' (VariableDeclaration ';')* )? '}'
|
||||||
@ -37,9 +37,9 @@ ArrayTypeName = TypeName '[' Expression? ']'
|
|||||||
|
|
||||||
Block = '{' Statement* '}'
|
Block = '{' Statement* '}'
|
||||||
Statement = IfStatement | WhileStatement | ForStatement | Block |
|
Statement = IfStatement | WhileStatement | ForStatement | Block |
|
||||||
( Continue | Break | Return | Throw | VariableDefinition | ExpressionStatement ) ';'
|
( Continue | Break | Return | Throw | VardefOrExprStmt ) ';'
|
||||||
|
|
||||||
ExpressionStatement = Expression
|
ExpressionStatement = Expression | VariableDefinition | Assignment | 'delete' Expression
|
||||||
IfStatement = 'if' '(' Expression ')' Statement ( 'else' Statement )?
|
IfStatement = 'if' '(' Expression ')' Statement ( 'else' Statement )?
|
||||||
WhileStatement = 'while' '(' Expression ')' Statement
|
WhileStatement = 'while' '(' Expression ')' Statement
|
||||||
VardefOrExprStmt = VariableDefinition | ExpressionStatement
|
VardefOrExprStmt = VariableDefinition | ExpressionStatement
|
||||||
@ -49,27 +49,31 @@ Break = 'break'
|
|||||||
Return = 'return' Expression?
|
Return = 'return' Expression?
|
||||||
Throw = 'throw'
|
Throw = 'throw'
|
||||||
VariableDefinition = VariableDeclaration ( '=' Expression )?
|
VariableDefinition = VariableDeclaration ( '=' Expression )?
|
||||||
|
Assignment = Expression ('=' | '|=' | '^=' | '&=' | '<<=' | '>>=' | '+=' | '-=' | '*=' | '/=' | '%=') Expression
|
||||||
|
|
||||||
Expression = Assignment | UnaryOperation | BinaryOperation | FunctionCall | NewExpression | IndexAccess |
|
Expression =
|
||||||
MemberAccess | PrimaryExpression
|
('!' | '~' | '++' | '--') expression
|
||||||
// The expression syntax is actually much more complicated
|
| expression ('**' | '*' | '/' | '%') expression
|
||||||
Assignment = Expression (AssignmentOp Expression)
|
| expression ('|' | '^' | '&' | '<<' | '>>') expression
|
||||||
AssignmentOp = '|=' | '^=' | '&=' | '<<=' | '>>=' | '+=' | '-=' | '*=' | '/=' | '%='
|
| expression ('+' | '-') expression
|
||||||
UnaryOperation = '!' | '~' | '++' | '--' | 'delete'
|
| expression ('<=' | '>=' | '<' | '>') expression
|
||||||
BinaryOperation = '|' | '^' | '&' | '<<' | '>>' | '+' | '-' | '*' | '/' | '%'
|
| expression ('==' | '!=') expression
|
||||||
| '||' | '&&' | '**' | '==' | '!=' | '<' | '>' | '<=' | '>='
|
| expression ('&&' | '||') expression
|
||||||
|
| PrimaryExpression
|
||||||
|
|
||||||
|
PrimaryExpression = Identifier | BooleanLiteral | NumberLiteral | StringLiteral
|
||||||
|
| FunctionCall | MemberAccess | IndexAccess | '(' Expression ')'
|
||||||
|
|
||||||
FunctionCall = Identifier '(' Expression? ( ',' Expression )* ')'
|
FunctionCall = Identifier '(' Expression? ( ',' Expression )* ')'
|
||||||
NewExpression = 'new' Identifier
|
NewExpression = 'new' Identifier
|
||||||
MemberAccess = Expression '.' Identifier
|
MemberAccess = Expression '.' Identifier
|
||||||
IndexAccess = Expression '[' Expression? ']'
|
IndexAccess = Expression '[' Expression? ']'
|
||||||
PrimaryExpression = Identifier | BooleanLiteral | NumberLiteral | StringLiteral | ElementaryTypeName | '(' Expression ')'
|
|
||||||
|
|
||||||
BooleanLiteral = 'true' | 'false'
|
BooleanLiteral = 'true' | 'false'
|
||||||
NumberLiteral = '0x'? [0-9]+ NumberUnit?
|
NumberLiteral = '0x'? [0-9]+ NumberUnit?
|
||||||
NumberUnit = 'wei' | 'szabo' | 'finney' | 'ether'
|
NumberUnit = 'wei' | 'szabo' | 'finney' | 'ether'
|
||||||
| 'seconds' | 'minutes' | 'hours' | 'days' | 'weeks' | 'years'
|
| 'seconds' | 'minutes' | 'hours' | 'days' | 'weeks' | 'years'
|
||||||
StringLiteral = '"' (~('"' | '\\' | '\r' | '\n') | '\\' ('"' | '\\'))* '"';
|
StringLiteral = '"' (~('"' | '\\' | '\r' | '\n') | '\\' ('"' | '\\'))* '"'
|
||||||
Identifier = [a-zA-Z_] [a-zA-Z_0-9]*
|
Identifier = [a-zA-Z_] [a-zA-Z_0-9]*
|
||||||
|
|
||||||
ElementaryTypeName = 'address' | 'bool' | 'string' | 'var'
|
ElementaryTypeName = 'address' | 'bool' | 'string' | 'var'
|
||||||
|
Loading…
Reference in New Issue
Block a user