Skip to content

Commit

Permalink
add support for emit statement (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
duaraghav8 committed Mar 13, 2018
1 parent 07a8a4f commit 403f30a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
13 changes: 13 additions & 0 deletions solidity.pegjs
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,7 @@ Zs = [\u0020\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]

/* Tokens */

EmitToken = "emit" !IdentifierPart
ExperimentalToken = "experimental" !IdentifierPart
ExternalToken = "external" !IdentifierPart
PureToken = "pure" !IdentifierPart
Expand Down Expand Up @@ -1075,6 +1076,7 @@ Statement
/ ReturnStatement
/ ThrowStatement
/ UsingStatement
/ EmitStatement

Block
= "{" __ body:(StatementList __)? "}" {
Expand Down Expand Up @@ -1261,6 +1263,17 @@ UsingStatement
}
}

EmitStatement
= EmitToken __ callexpr:CallExpression EOS
{
return {
type: "EmitStatement",
expression: callexpr,
start: location().start.offset,
end: location().end.offset
};
}

SymbolList
= head:Symbol tail:( __ "," __ Symbol)* {
return buildList(head, tail, 3);
Expand Down
9 changes: 9 additions & 0 deletions test/doc_examples.sol
Original file line number Diff line number Diff line change
Expand Up @@ -536,4 +536,13 @@ contract Bar {
}
}

contract EventTester {
event Transfer(string name, uint amount);

function foo() public {
Transfer("Jacob", 2901);
emit Transfer("Jacob", 2901);
}
}

//end of file

0 comments on commit 403f30a

Please sign in to comment.