mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #9215 from a3d4/fix-grammar-pragma-version
Fix pragma solidity version in antlr grammar
This commit is contained in:
commit
e419e904d3
@ -11,23 +11,11 @@ sourceUnit
|
||||
: (pragmaDirective | importDirective | structDefinition | enumDefinition | contractDefinition)* EOF ;
|
||||
|
||||
pragmaDirective
|
||||
: 'pragma' pragmaName pragmaValue ';' ;
|
||||
: 'pragma' pragmaName ( ~';' )* ';' ;
|
||||
|
||||
pragmaName
|
||||
: identifier ;
|
||||
|
||||
pragmaValue
|
||||
: version | expression ;
|
||||
|
||||
version
|
||||
: versionConstraint versionConstraint? ;
|
||||
|
||||
versionConstraint
|
||||
: versionOperator? VersionLiteral ;
|
||||
|
||||
versionOperator
|
||||
: '^' | '~' | '>=' | '>' | '<' | '<=' | '=' ;
|
||||
|
||||
importDirective
|
||||
: 'import' StringLiteralFragment ('as' identifier)? ';'
|
||||
| 'import' ('*' | identifier) ('as' identifier)? 'from' StringLiteralFragment ';'
|
||||
@ -473,9 +461,6 @@ fragment
|
||||
SingleQuotedStringCharacter
|
||||
: ~['\r\n\\] | ('\\' .) ;
|
||||
|
||||
VersionLiteral
|
||||
: [0-9]+ ( '.' [0-9]+ ('.' [0-9]+)? )? ;
|
||||
|
||||
WS
|
||||
: [ \t\r\n\u000C]+ -> skip ;
|
||||
|
||||
|
7
test/libsolidity/syntaxTests/pragma/version_check.sol
Normal file
7
test/libsolidity/syntaxTests/pragma/version_check.sol
Normal file
@ -0,0 +1,7 @@
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
pragma solidity < 142857;
|
||||
pragma solidity >= 0.0;
|
||||
pragma solidity >= 0.0.0;
|
||||
|
||||
contract C {
|
||||
}
|
Loading…
Reference in New Issue
Block a user