diff options
author | Nicolai <NicolaiSoeborg@users.noreply.github.com> | 2016-07-23 07:45:10 +0800 |
---|---|---|
committer | Nicolai <NicolaiSoeborg@users.noreply.github.com> | 2016-07-23 07:45:10 +0800 |
commit | 5512b855944ef437e74f4eb647e3c5b36e1db731 (patch) | |
tree | fab0558321cb026148fdfdb1da4c9c06bd9739c3 /libsolidity | |
parent | 1c341add59d39a35a25363bcf75c55245c373213 (diff) | |
download | dexon-solidity-5512b855944ef437e74f4eb647e3c5b36e1db731.tar.gz dexon-solidity-5512b855944ef437e74f4eb647e3c5b36e1db731.tar.zst dexon-solidity-5512b855944ef437e74f4eb647e3c5b36e1db731.zip |
Begin fixing expression syntax
Diffstat (limited to 'libsolidity')
-rw-r--r-- | libsolidity/grammar.txt | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/libsolidity/grammar.txt b/libsolidity/grammar.txt index d03b5f46..b0b018d7 100644 --- a/libsolidity/grammar.txt +++ b/libsolidity/grammar.txt @@ -7,12 +7,12 @@ Imports = StringLiteral ('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 InheritanceSpecifier = Identifier ( '(' Expression ( ',' Expression )* ')' )? -StateVariableDeclaration = TypeName ( 'public' | 'internal' | 'private' )? Identifier ';' +StateVariableDecOrDef = TypeName ( 'public' | 'internal' | 'private' )? Identifier ('=' Expression)? ';' UsingDeclaration = 'using' Identifier 'for' TypeName ';' StructDefinition = 'struct' Identifier '{' ( VariableDeclaration ';' (VariableDeclaration ';')* )? '}' @@ -37,9 +37,9 @@ ArrayTypeName = TypeName '[' Expression? ']' Block = '{' Statement* '}' 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 )? WhileStatement = 'while' '(' Expression ')' Statement VardefOrExprStmt = VariableDefinition | ExpressionStatement @@ -49,27 +49,31 @@ Break = 'break' Return = 'return' Expression? Throw = 'throw' VariableDefinition = VariableDeclaration ( '=' Expression )? +Assignment = Expression ('=' | '|=' | '^=' | '&=' | '<<=' | '>>=' | '+=' | '-=' | '*=' | '/=' | '%=') Expression -Expression = Assignment | UnaryOperation | BinaryOperation | FunctionCall | NewExpression | IndexAccess | - MemberAccess | PrimaryExpression -// The expression syntax is actually much more complicated -Assignment = Expression (AssignmentOp Expression) -AssignmentOp = '|=' | '^=' | '&=' | '<<=' | '>>=' | '+=' | '-=' | '*=' | '/=' | '%=' -UnaryOperation = '!' | '~' | '++' | '--' | 'delete' -BinaryOperation = '|' | '^' | '&' | '<<' | '>>' | '+' | '-' | '*' | '/' | '%' - | '||' | '&&' | '**' | '==' | '!=' | '<' | '>' | '<=' | '>=' +Expression = + ('!' | '~' | '++' | '--') expression + | expression ('**' | '*' | '/' | '%') expression + | expression ('|' | '^' | '&' | '<<' | '>>') expression + | expression ('+' | '-') expression + | expression ('<=' | '>=' | '<' | '>') expression + | expression ('==' | '!=') expression + | expression ('&&' | '||') expression + | PrimaryExpression + +PrimaryExpression = Identifier | BooleanLiteral | NumberLiteral | StringLiteral + | FunctionCall | MemberAccess | IndexAccess | '(' Expression ')' FunctionCall = Identifier '(' Expression? ( ',' Expression )* ')' NewExpression = 'new' Identifier MemberAccess = Expression '.' Identifier IndexAccess = Expression '[' Expression? ']' -PrimaryExpression = Identifier | BooleanLiteral | NumberLiteral | StringLiteral | ElementaryTypeName | '(' Expression ')' BooleanLiteral = 'true' | 'false' NumberLiteral = '0x'? [0-9]+ NumberUnit? NumberUnit = 'wei' | 'szabo' | 'finney' | 'ether' | 'seconds' | 'minutes' | 'hours' | 'days' | 'weeks' | 'years' -StringLiteral = '"' (~('"' | '\\' | '\r' | '\n') | '\\' ('"' | '\\'))* '"'; +StringLiteral = '"' (~('"' | '\\' | '\r' | '\n') | '\\' ('"' | '\\'))* '"' Identifier = [a-zA-Z_] [a-zA-Z_0-9]* ElementaryTypeName = 'address' | 'bool' | 'string' | 'var' |