Posts

Showing posts with the label #BNF

Describing the syntax of Solidity using BNF

SOURCE: https://github.com/ethereum/solidity/blob/develop/docs/grammar.txt SourceUnit = (PragmaDirective | ImportDirective | ContractDefinition)* // Pragma actually parses anything up to the trailing ';' to be fully forward-compatible. PragmaDirective = 'pragma' Identifier ([^;]+) ';' ImportDirective = 'import' StringLiteral ('as' Identifier)? ';' | 'import' ('*' | Identifier) ('as' Identifier)? 'from' StringLiteral ';' | 'import' '{' Identifier ('as' Identifier)? ( ',' Identifier ('as' Identifier)? )* '}' 'from' StringLiteral ';' ContractDefinition = ( 'contract' | 'library' | 'interface' ) Identifier ( 'is' InheritanceSpecifier (',' InheritanceSpecifier )* )? '{' ContractPart* '}' ContractPart = StateVariableDecla...