Skip to content

Syntax Diagram

walter-weinmann edited this page Oct 30, 2017 · 5 revisions

SourceUnit:

    SourceUnit
             ::= ( PragmaDirective | ImportDirective | ContractDefinition )*
no references

PragmaDirective:

    PragmaDirective
             ::= 'PRAGMA' Identifier [^;]+ ';'
referenced by:

ImportDirective:

    ImportDirective
             ::= 'IMPORT' ( StringLiteral ( 'AS' Identifier )? | ( ( '*' | Identifier ) ( 'AS' Identifier )? | '{' Identifier ( 'AS' Identifier )? ( ',' Identifier ( 'AS' Identifier )? )* '}' ) 'FROM' StringLiteral ) ';'
referenced by:

ContractDefinition:

    ContractDefinition
             ::= ( 'CONTRACT' | 'LIBRARY' | 'INTERFACE' ) Identifier ( 'IS' InheritanceSpecifier ( ',' InheritanceSpecifier )* )? '{' ContractPart* '}'
referenced by:

ContractPart:

    ContractPart
             ::= StateVariableDeclaration
               | UsingForDeclaration
               | StructDefinition
               | ModifierDefinition
               | FunctionDefinition
               | EventDefinition
               | EnumDefinition
referenced by:

InheritanceSpecifier:

    InheritanceSpecifier
             ::= UserDefinedTypeName ( '(' Expression ( ',' Expression )* ')' )?
referenced by:

StateVariableDeclaration:

    StateVariableDeclaration
             ::= TypeName ( 'PUBLIC' | 'INTERNAL' | 'PRIVATE' | 'CONSTANT' )? Identifier ( '=' Expression )? ';'
referenced by:

UsingForDeclaration:

    UsingForDeclaration
             ::= 'USING' Identifier 'FOR' ( '*' | TypeName ) ';'
referenced by:

StructDefinition:

    StructDefinition
             ::= 'STRUCT' Identifier '{' ( VariableDeclaration ';' )* '}'
referenced by:

ModifierDefinition:

    ModifierDefinition
             ::= 'MODIFIER' Identifier ParameterList? Block
referenced by:

ModifierInvocation:

    ModifierInvocation
             ::= Identifier ( '(' ExpressionList? ')' )?
referenced by:

FunctionDefinition:

    FunctionDefinition
             ::= 'FUNCTION' Identifier? ParameterList ( ModifierInvocation | StateMutability | 'EXTERNAL' | 'PUBLIC' | 'INTERNAL' | 'PRIVATE' )* ( 'RETURNS' ParameterList )? ( ';' | Block )
referenced by:

EventDefinition:

    EventDefinition
             ::= 'EVENT' Identifier IndexedParameterList 'ANONYMOUS'? ';'
referenced by:

EnumValue:

    EnumValue
             ::= Identifier
referenced by:

EnumDefinition:

    EnumDefinition
             ::= 'ENUM' Identifier '{' EnumValue? ( ',' EnumValue )* '}'
referenced by:

IndexedParameterList:

    IndexedParameterList
             ::= '(' ( TypeName 'INDEXED'? Identifier? ( ',' TypeName 'INDEXED'? Identifier? )* )? ')'
referenced by:

ParameterList:

    ParameterList
             ::= '(' ( TypeName Identifier? ( ',' TypeName Identifier? )* )? ')'
referenced by:

TypeNameList:

    TypeNameList
             ::= '(' ( TypeName ( ',' TypeName )* )? ')'
referenced by:

VariableDeclaration:

    VariableDeclaration
             ::= TypeName StorageLocation? Identifier
referenced by:

TypeName:

    TypeName ::= ElementaryTypeName
               | Mapping
               | ArrayTypeName
               | FunctionTypeName
referenced by:

UserDefinedTypeName:

    UserDefinedTypeName
             ::= Identifier ( '.' Identifier )*
referenced by:

Mapping:

    Mapping  ::= 'MAPPING' '(' ElementaryTypeName '=>' TypeName ')'
referenced by:

ArrayTypeName:

    ArrayTypeName
             ::= TypeName '[' Expression? ']'
referenced by:

FunctionTypeName:

    FunctionTypeName
             ::= 'FUNCTION' TypeNameList ( 'INTERNAL' | 'EXTERNAL' | StateMutability )* ( 'RETURNS' TypeNameList )?
referenced by:

StorageLocation:

    StorageLocation
             ::= 'MEMORY'
               | 'STORAGE'
referenced by:

StateMutability:

    StateMutability
             ::= 'PURE'
               | 'CONSTANT'
               | 'VIEW'
               | 'PAYABLE'
referenced by:

Block:

    Block    ::= '{' Statement* '}'
referenced by:

Statement:

    Statement
             ::= IfStatement
               | WhileStatement
               | ForStatement
               | Block
               | InlineAssemblyStatement
               | ( DoWhileStatement | '_' | 'CONTINUE' | 'BREAK' | Return | 'THROW' | SimpleStatement ) ';'
referenced by:

ExpressionStatement:

    ExpressionStatement
             ::= Expression
referenced by:

IfStatement:

    IfStatement
             ::= 'IF' '(' Expression ')' Statement ( 'ELSE' Statement )?
referenced by:

WhileStatement:

    WhileStatement
             ::= 'WHILE' '(' Expression ')' Statement
referenced by:

SimpleStatement:

    SimpleStatement
             ::= VariableDefinition
               | ExpressionStatement
referenced by:

ForStatement:

    ForStatement
             ::= 'FOR' '(' SimpleStatement? ';' Expression? ';' ExpressionStatement? ')' Statement
referenced by:

InlineAssemblyStatement:

    InlineAssemblyStatement
             ::= 'ASSEMBLY' StringLiteral? InlineAssemblyBlock
referenced by:

DoWhileStatement:

    DoWhileStatement
             ::= 'DO' Statement 'WHILE' '(' Expression ')'
referenced by:

Return:

    Return   ::= 'RETURN' Expression?
referenced by:

VariableDefinition:

    VariableDefinition
             ::= ( 'VAR' IdentifierList | VariableDeclaration ) ( '=' Expression )?
referenced by:

IdentifierList:

    IdentifierList
             ::= '(' Identifier? ( ',' Identifier? )* ')'
referenced by:

Expression:

    Expression
             ::= Expression ( '++' | '--' | ( '**' | '*' | '/' | '%' | '+' | '-' | '<<' | '>>' | '&' | '^' | '|' | '<' | '>' | '<=' | '>=' | '==' | '!=' | '&&' | '||' | '?' Expression ':' | '=' | '|=' | '^=' | '&=' | '<<=' | '>>=' | '+=' | '-=' | '*=' | '/=' | '%=' ) Expression )
               | NewExpression
               | IndexAccess
               | MemberAccess
               | FunctionCall
               | '(' Expression ')'
               | ( '!' | '~' | 'delete' | '++' | '--' | '+' | '-' ) Expression
               | PrimaryExpression
referenced by:

PrimaryExpression:

    PrimaryExpression
             ::= BooleanLiteral
               | NumberLiteral
               | HexLiteral
               | StringLiteral
               | TupleExpression
               | Identifier
               | ElementaryTypeNameExpression
referenced by:

ExpressionList:

    ExpressionList
             ::= Expression ( ',' Expression )*
referenced by:

NameValueList:

    NameValueList
             ::= Identifier ':' Expression ( ',' Identifier ':' Expression )*
referenced by:

FunctionCall:

    FunctionCall
             ::= Expression '(' FunctionCallArguments ')'
referenced by:

FunctionCallArguments:

    FunctionCallArguments
             ::= ( '{' NameValueList? '}' | ExpressionList )?
referenced by:

NewExpression:

    NewExpression
             ::= 'NEW' TypeName
referenced by:

MemberAccess:

    MemberAccess
             ::= Expression '.' Identifier
referenced by:

IndexAccess:

    IndexAccess
             ::= Expression '[' Expression? ']'
referenced by:

BooleanLiteral:

    BooleanLiteral
             ::= 'TRUE'
               | 'FALSE'
referenced by:

NumberLiteral:

    NumberLiteral
             ::= ( HexNumber | DecimalNumber ) ( ' ' NumberUnit )?
referenced by:

NumberUnit:

    NumberUnit
             ::= 'WEI'
               | 'SZABO'
               | 'FINNEY'
               | 'ETHER'
               | 'SECONDS'
               | 'MINUTES'
               | 'HOURS'
               | 'DAYS'
               | 'WEEKS'
               | 'YEARS'
referenced by:

HexLiteral:

    HexLiteral
             ::= 'HEX' ( '"' ( [0-9a-fA-F] [0-9a-fA-F] )* '"' | "'" ( [0-9a-fA-F] [0-9a-fA-F] )* "'" )
referenced by:

StringLiteral:

    StringLiteral
             ::= '"' ( [^"\rn] | '\\' . )* '"'
referenced by:

Identifier:

    Identifier
             ::= [a-zA-Z_$] [a-zA-Z_$0-9]*
referenced by:

HexNumber:

    HexNumber
             ::= '0x' [0-9a-fA-F]+
referenced by:

DecimalNumber:

    DecimalNumber
             ::= [0-9]+
referenced by:

TupleExpression:

    TupleExpression
             ::= '(' ( Expression ( ',' Expression )* )? ')'
               | '[' ( Expression ( ',' Expression )* )? ']'
referenced by:

ElementaryTypeNameExpression:

    ElementaryTypeNameExpression
             ::= ElementaryTypeName
referenced by:

ElementaryTypeName:

    ElementaryTypeName
             ::= 'ADDRESS'
               | 'BOOL'
               | 'STRING'
               | 'VAR'
               | Int
               | Uint
               | Byte
               | Fixed
               | Ufixed
referenced by:

Int:

    Int      ::= 'INT'
               | 'INT8'
               | 'INT16'
               | 'INT24'
               | 'INT32'
               | 'INT40'
               | 'INT48'
               | 'INT56'
               | 'INT64'
               | 'INT72'
               | 'INT80'
               | 'INT88'
               | 'INT96'
               | 'INT104'
               | 'INT112'
               | 'INT120'
               | 'INT128'
               | 'INT136'
               | 'INT144'
               | 'INT152'
               | 'INT160'
               | 'INT168'
               | 'INT176'
               | 'INT184'
               | 'INT192'
               | 'INT200'
               | 'INT208'
               | 'INT216'
               | 'INT224'
               | 'INT232'
               | 'INT240'
               | 'INT248'
               | 'INT256'
referenced by:

Uint:

    Uint     ::= 'UINT'
               | 'UINT8'
               | 'UINT16'
               | 'UINT24'
               | 'UINT32'
               | 'UINT40'
               | 'UINT48'
               | 'UINT56'
               | 'UINT64'
               | 'UINT72'
               | 'UINT80'
               | 'UINT88'
               | 'UINT96'
               | 'UINT104'
               | 'UINT112'
               | 'UINT120'
               | 'UINT128'
               | 'UINT136'
               | 'UINT144'
               | 'UINT152'
               | 'UINT160'
               | 'UINT168'
               | 'UINT176'
               | 'UINT184'
               | 'UINT192'
               | 'UINT200'
               | 'UINT208'
               | 'UINT216'
               | 'UINT224'
               | 'UINT232'
               | 'UINT240'
               | 'UINT248'
               | 'UINT256'
referenced by:

Byte:

    Byte     ::= 'BYTE'
               | 'BYTES'
               | 'BYTES1'
               | 'BYTES2'
               | 'BYTES3'
               | 'BYTES4'
               | 'BYTES5'
               | 'BYTES6'
               | 'BYTES7'
               | 'BYTES8'
               | 'BYTES9'
               | 'BYTES10'
               | 'BYTES11'
               | 'BYTES12'
               | 'BYTES13'
               | 'BYTES14'
               | 'BYTES15'
               | 'BYTES16'
               | 'BYTES17'
               | 'BYTES18'
               | 'BYTES19'
               | 'BYTES20'
               | 'BYTES21'
               | 'BYTES22'
               | 'BYTES23'
               | 'BYTES24'
               | 'BYTES25'
               | 'BYTES26'
               | 'BYTES27'
               | 'BYTES28'
               | 'BYTES29'
               | 'BYTES30'
               | 'BYTES31'
               | 'BYTES32'
referenced by:

Fixed:

    Fixed    ::= 'FIXED' ( DecimalNumber 'x' DecimalNumber )?
referenced by:

Ufixed:

    Ufixed   ::= 'UFIXED' ( DecimalNumber 'x' DecimalNumber )?
referenced by:

InlineAssemblyBlock:

    InlineAssemblyBlock
             ::= '{' AssemblyItem* '}'
referenced by:

AssemblyItem:

    AssemblyItem
             ::= Identifier
               | FunctionalAssemblyExpression
               | InlineAssemblyBlock
               | AssemblyLocalBinding
               | AssemblyAssignment
               | AssemblyLabel
               | NumberLiteral
               | StringLiteral
               | HexLiteral
referenced by:

AssemblyLocalBinding:

    AssemblyLocalBinding
             ::= 'LET' Identifier ':=' FunctionalAssemblyExpression
referenced by:

AssemblyAssignment:

    AssemblyAssignment
             ::= Identifier ':=' FunctionalAssemblyExpression
               | '=:' Identifier
referenced by:

AssemblyLabel:

    AssemblyLabel
             ::= Identifier ':'
referenced by:

FunctionalAssemblyExpression:

    FunctionalAssemblyExpression
             ::= Identifier '(' AssemblyItem? ( ',' AssemblyItem )* ')'
referenced by:

  ... generated by Railroad Diagram Generator