Skip to content

Commit

Permalink
Add support for 'calldata' storage specifier
Browse files Browse the repository at this point in the history
  • Loading branch information
duaraghav8 committed Dec 23, 2018
1 parent 270f999 commit afbe296
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ Pegjs-based Parser for the Solidity Programming language.
It was originally a fork of [Consensys' solidity-parser](https://github.com/ConsenSys/solidity-parser) by Tim Coulter. @cgewecke, @duaraghav8 and @federicobond are co-authors.

## Note
Solparse is primarily meant for [Solium](https://github.com/duaraghav8/Solium). Because its sole purpose is to make life easier for the linter, we do not guarantee that there won't be any breaking changes, although we work hard to keep it friendly.
Solparse is primarily meant for [Ethlint](https://github.com/duaraghav8/Ethlint). Because its sole purpose is to make life easier for the linter, we do not guarantee that there won't be any breaking changes, although we work hard to keep it friendly.

If you use solparse in your production systems, use it as a fixed dependency, i.e., stick to a fixed version of the parser.
If you use solparse in your production systems, use it as a fixed dependency.

### License

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "index.js",
"scripts": {
"prepublish": "npm run build",
"build": "mkdirp ./build && pegjs --cache -o ./build/parser.js ./solidity.pegjs && pegjs -o ./build/imports_parser.js ./imports.pegjs",
"build": "mkdir -p ./build && pegjs --cache -o ./build/parser.js ./solidity.pegjs && pegjs -o ./build/imports_parser.js ./imports.pegjs",
"test": "mocha --timeout 5000 --reporter spec",
"lint": "eslint index.js test/ cli.js"
},
Expand Down
9 changes: 5 additions & 4 deletions solidity.pegjs
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,7 @@ PayableToken = "payable" !IdentifierPart
AnonymousToken = "anonymous" !IdentifierPart
AsToken = "as" !IdentifierPart
BreakToken = "break" !IdentifierPart
CalldataToken = "calldata" !IdentifierPart
ConstantToken = "constant" !IdentifierPart
ContinueToken = "continue" !IdentifierPart
ContractToken = "contract" !IdentifierPart
Expand Down Expand Up @@ -784,6 +785,7 @@ VisibilitySpecifier
StorageLocationSpecifier
= StorageToken
/ MemoryToken
/ CalldataToken

StateVariableSpecifiers
= specifiers:(VisibilitySpecifier __ ConstantToken?){
Expand Down Expand Up @@ -1632,16 +1634,15 @@ CommaSeparatedModifierNameList
}

InformalParameter
= type:Type __ isindexed:IndexedToken? __ isconstant:ConstantToken? __ isstorage:StorageToken? __ ismemory:MemoryToken? __ id:Identifier?
= type:Type __ isindexed:IndexedToken? __ isconstant:ConstantToken? __ storage:StorageLocationSpecifier? __ id:Identifier?
{
return {
type: "InformalParameter",
literal: type,
id: id ? id.name : null,
is_indexed: isindexed != null,
is_storage: isconstant != null,
is_storage: isstorage != null,
is_memory: ismemory != null,
is_constant: isconstant != null,
storage_location: storage ? storage[0]: null,
start: location().start.offset,
end: location().end.offset
};
Expand Down
9 changes: 9 additions & 0 deletions test/doc_examples.sol
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,15 @@ library IntegerSet
/// Number of stored items.
uint size;
}
struct Request {
bytes calldata data;
function(bytes memory) external callback;
}
function bar(uint[] memory self, function (uint) pure returns (uint) f) public {
(bool success, bytes memory data) = otherContract.call("f");
uint[] calldata x = m_x;
}
function f(uint[][] calldata x) external {}
function insert(data storage self, uint value) returns (bool alreadyPresent)
{
uint index = self.index[value];
Expand Down

1 comment on commit afbe296

@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.