From d9928c8953cab5386c4e213fcdbf1d4753d88e5a Mon Sep 17 00:00:00 2001 From: duaraghav8 Date: Tue, 26 Dec 2017 21:32:57 +0530 Subject: [PATCH] fix #21 --- solidity.pegjs | 14 +++++++++++++- test/doc_examples.sol | 20 ++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/solidity.pegjs b/solidity.pegjs index 4b9d756..ecd6af5 100755 --- a/solidity.pegjs +++ b/solidity.pegjs @@ -384,7 +384,19 @@ UnicodeEscapeSequence } VersionLiteral - = operator:(RelationalOperator / EqualityOperator / BitwiseXOROperator)? __ ("v")? major:DecimalIntegerLiteral "." minor:DecimalIntegerLiteral "." patch:DecimalIntegerLiteral { + = operator:(RelationalOperator / EqualityOperator / BitwiseXOROperator)? __ ("v")? major:DecimalIntegerLiteral minor:("." DecimalIntegerLiteral)? patch:("." DecimalIntegerLiteral)? { + if (patch === null) { + patch = 0; + } else { + patch = patch[1]; + } + + if (minor === null) { + minor = 0; + } else { + minor = minor[1]; + } + return { type: "VersionLiteral", operator: operator, diff --git a/test/doc_examples.sol b/test/doc_examples.sol index ebfeede..cdb2192 100755 --- a/test/doc_examples.sol +++ b/test/doc_examples.sol @@ -11,6 +11,26 @@ pragma solidity > 0.4.0; pragma solidity != 0.4.0; pragma solidity >=0.4.0 <0.4.8; // from https://github.com/ethereum/solidity/releases/tag/v0.4.0 +pragma solidity 0.4; +pragma solidity v0.4; +pragma solidity ^0.4; +pragma solidity >= 0.4; +pragma solidity <= 0.4; +pragma solidity < 0.5; +pragma solidity > 0.4; +pragma solidity != 0.4; +pragma solidity >=0.4 <=0.4; + +pragma solidity 0; +pragma solidity v0; +pragma solidity ^0; +pragma solidity >= 0; +pragma solidity <= 0; +pragma solidity < 1; +pragma solidity > 0; +pragma solidity != 0; +pragma solidity >=0 <=1; + // Pragma statements that enable experimental (breaking) features pragma experimental "SMTChecker";