Skip to content

Commit

Permalink
add support for pragma experimental
Browse files Browse the repository at this point in the history
  • Loading branch information
duaraghav8 committed Oct 11, 2017
1 parent cfb1c65 commit d21ebb8
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
9 changes: 9 additions & 0 deletions imports.pegjs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ HexDigit

AsToken = "as" !IdentifierPart
ContractToken = "contract" !IdentifierPart
ExperimentalToken = "experimental" !IdentifierPart
FromToken = "from" !IdentifierPart
ForToken = "for" !IdentifierPart
ImportToken = "import" !IdentifierPart
Expand Down Expand Up @@ -223,6 +224,14 @@ PragmaStatement
end: location().end.offset
}
}
/ PragmaToken __ ExperimentalToken __ featureName:(Identifier / StringLiteral) EOS {
return {
type: "ExperimentalPragmaStatement",
feature: featureName,
start: location().start.offset,
end: location().end.offset
}
}

ImportStatement
= ImportToken __ from:StringLiteral __ alias:(AsToken __ Identifier)? __ EOS
Expand Down
9 changes: 9 additions & 0 deletions solidity.pegjs
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,7 @@ ElseToken = "else" !IdentifierPart
EnumToken = "enum" !IdentifierPart
EtherToken = "ether" !IdentifierPart
EventToken = "event" !IdentifierPart
ExperimentalToken = "experimental" !IdentifierPart
ExportToken = "export" !IdentifierPart
ExtendsToken = "extends" !IdentifierPart
FalseToken = "false" !IdentifierPart
Expand Down Expand Up @@ -1114,6 +1115,14 @@ PragmaStatement
end: location().end.offset
}
}
/ PragmaToken __ ExperimentalToken __ featureName:(Identifier / StringLiteral) EOS {
return {
type: "ExperimentalPragmaStatement",
feature: featureName,
start: location().start.offset,
end: location().end.offset
}
}

ImportStatement
= ImportToken __ from:StringLiteral __ alias:(AsToken __ Identifier)? __ EOS
Expand Down
8 changes: 8 additions & 0 deletions test/doc_examples.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ 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 statements that enable experimental (breaking) features
pragma experimental "SMTChecker";
pragma experimental ABIEncoderV2;
pragma experimental "v0.5.0";
pragma experimental __test;
pragma experimental __testOnlyAnalysis;

import "SomeFile.sol";
import "SomeFile.sol" as SomeOtherFile;
import * as SomeSymbol from "AnotherFile.sol";
Expand Down

1 comment on commit d21ebb8

@duaraghav8
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.