{"action":"created","comment":{"url":"https://api.github.com/repos/ethereum/cpp-ethereum/pulls/comments/23045554","id":23045554,"diff_hunk":"@@ -0,0 +1,137 @@\n+/*\n+    This file is part of cpp-ethereum.\n+\n+    cpp-ethereum is free software: you can redistribute it and/or modify\n+    it under the terms of the GNU General Public License as published by\n+    the Free Software Foundation, either version 3 of the License, or\n+    (at your option) any later version.\n+\n+    cpp-ethereum is distributed in the hope that it will be useful,\n+    but WITHOUT ANY WARRANTY; without even the implied warranty of\n+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n+    GNU General Public License for more details.\n+\n+    You should have received a copy of the GNU General Public License\n+    along with cpp-ethereum.  If not, see <http://www.gnu.org/licenses/>.\n+*/\n+/**\n+ * @author Lefteris <lefteris@ethdev.com>\n+ * @date 2015\n+ * Converts the AST into json format\n+ */\n+\n+#pragma once\n+\n+#include <ostream>\n+#include <stack>\n+#include <libsolidity/ASTVisitor.h>\n+#include <libsolidity/Exceptions.h>\n+#include <jsoncpp/json/json.h>\n+\n+namespace dev\n+{\n+namespace solidity\n+{\n+\n+/**\n+ * Converter of the AST into JSON format\n+ */\n+class ASTJsonConverter: public ASTConstVisitor\n+{\n+public:\n+\t/// Create a converter for the given abstract syntax tree. If the source is specified,\n+\t/// the corresponding parts of the source are printed with each node.\n+\tASTJsonConverter(ASTNode const& _ast);\n+\t/// Output the json representation of the AST to _stream.\n+\tvoid print(std::ostream& _stream);\n+\n+\tbool visit(ImportDirective const& _node) override;\n+\tbool visit(ContractDefinition const& _node) override;\n+\tbool visit(StructDefinition const& _node) override;\n+\tbool visit(ParameterList const& _node) override;\n+\tbool visit(FunctionDefinition const& _node) override;\n+\tbool visit(VariableDeclaration const& _node) override;\n+\tbool visit(TypeName const& _node) override;\n+\tbool visit(ElementaryTypeName const& _node) override;\n+\tbool visit(UserDefinedTypeName const& _node) override;\n+\tbool visit(Mapping const& _node) override;\n+\tbool visit(Statement const& _node) override;\n+\tbool visit(Block const& _node) override;\n+\tbool visit(IfStatement const& _node) override;\n+\tbool visit(BreakableStatement const& _node) override;\n+\tbool visit(WhileStatement const& _node) override;\n+\tbool visit(ForStatement const& _node) override;\n+\tbool visit(Continue const& _node) override;\n+\tbool visit(Break const& _node) override;\n+\tbool visit(Return const& _node) override;\n+\tbool visit(VariableDefinition const& _node) override;\n+\tbool visit(ExpressionStatement const& _node) override;\n+\tbool visit(Expression const& _node) override;\n+\tbool visit(Assignment const& _node) override;\n+\tbool visit(UnaryOperation const& _node) override;\n+\tbool visit(BinaryOperation const& _node) override;\n+\tbool visit(FunctionCall const& _node) override;\n+\tbool visit(NewExpression const& _node) override;\n+\tbool visit(MemberAccess const& _node) override;\n+\tbool visit(IndexAccess const& _node) override;\n+\tbool visit(PrimaryExpression const& _node) override;\n+\tbool visit(Identifier const& _node) override;\n+\tbool visit(ElementaryTypeNameExpression const& _node) override;\n+\tbool visit(Literal const& _node) override;\n+\n+\tvoid endVisit(ImportDirective const&) override;\n+\tvoid endVisit(ContractDefinition const&) override;\n+\tvoid endVisit(StructDefinition const&) override;\n+\tvoid endVisit(ParameterList const&) override;\n+\tvoid endVisit(FunctionDefinition const&) override;\n+\tvoid endVisit(VariableDeclaration const&) override;\n+\tvoid endVisit(TypeName const&) override;\n+\tvoid endVisit(ElementaryTypeName const&) override;\n+\tvoid endVisit(UserDefinedTypeName const&) override;\n+\tvoid endVisit(Mapping const&) override;\n+\tvoid endVisit(Statement const&) override;\n+\tvoid endVisit(Block const&) override;\n+\tvoid endVisit(IfStatement const&) override;\n+\tvoid endVisit(BreakableStatement const&) override;\n+\tvoid endVisit(WhileStatement const&) override;\n+\tvoid endVisit(ForStatement const&) override;\n+\tvoid endVisit(Continue const&) override;\n+\tvoid endVisit(Break const&) override;\n+\tvoid endVisit(Return const&) override;\n+\tvoid endVisit(VariableDefinition const&) override;\n+\tvoid endVisit(ExpressionStatement const&) override;\n+\tvoid endVisit(Expression const&) override;\n+\tvoid endVisit(Assignment const&) override;\n+\tvoid endVisit(UnaryOperation const&) override;\n+\tvoid endVisit(BinaryOperation const&) override;\n+\tvoid endVisit(FunctionCall const&) override;\n+\tvoid endVisit(NewExpression const&) override;\n+\tvoid endVisit(MemberAccess const&) override;\n+\tvoid endVisit(IndexAccess const&) override;\n+\tvoid endVisit(PrimaryExpression const&) override;\n+\tvoid endVisit(Identifier const&) override;\n+\tvoid endVisit(ElementaryTypeNameExpression const&) override;\n+\tvoid endVisit(Literal const&) override;\n+\n+private:\n+\tvoid addKeyValue(Json::Value& _obj, std::string const& _key, std::string const& _val);\n+\tvoid addJsonNode(std::string const& _nodeName,\n+\t\t\t\t\t std::initializer_list<std::pair<std::string const, std::string const>> _list,\n+\t\t\t\t\t bool _hasChildren);\n+\tstd::string const getType(Expression const& _expression);","path":"libsolidity/ASTJsonConverter.h","position":121,"original_position":121,"commit_id":"50d3825f1f93cff7d8332b67269964eff4eaeaa6","original_commit_id":"50d3825f1f93cff7d8332b67269964eff4eaeaa6","user":{"login":"chriseth","id":9073706,"avatar_url":"https://avatars.githubusercontent.com/u/9073706?v=3","gravatar_id":"","url":"https://api.github.com/users/chriseth","html_url":"https://github.com/chriseth","followers_url":"https://api.github.com/users/chriseth/followers","following_url":"https://api.github.com/users/chriseth/following{/other_user}","gists_url":"https://api.github.com/users/chriseth/gists{/gist_id}","starred_url":"https://api.github.com/users/chriseth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chriseth/subscriptions","organizations_url":"https://api.github.com/users/chriseth/orgs","repos_url":"https://api.github.com/users/chriseth/repos","events_url":"https://api.github.com/users/chriseth/events{/privacy}","received_events_url":"https://api.github.com/users/chriseth/received_events","type":"User","site_admin":false},"body":"Do you really want to return a const string?","created_at":"2015-01-15T21:34:08Z","updated_at":"2015-01-15T21:34:08Z","html_url":"https://github.com/ethereum/cpp-ethereum/pull/813#discussion_r23045554","pull_request_url":"https://api.github.com/repos/ethereum/cpp-ethereum/pulls/813","_links":{"self":{"href":"https://api.github.com/repos/ethereum/cpp-ethereum/pulls/comments/23045554"},"html":{"href":"https://github.com/ethereum/cpp-ethereum/pull/813#discussion_r23045554"},"pull_request":{"href":"https://api.github.com/repos/ethereum/cpp-ethereum/pulls/813"}}},"pull_request":{"url":"https://api.github.com/repos/ethereum/cpp-ethereum/pulls/813","id":27438818,"html_url":"https://github.com/ethereum/cpp-ethereum/pull/813","diff_url":"https://github.com/ethereum/cpp-ethereum/pull/813.diff","patch_url":"https://github.com/ethereum/cpp-ethereum/pull/813.patch","issue_url":"https://api.github.com/repos/ethereum/cpp-ethereum/issues/813","number":813,"state":"open","locked":false,"title":"Exporting Solidity AST in a JSON format","user":{"login":"LefterisJP","id":1658405,"avatar_url":"https://avatars.githubusercontent.com/u/1658405?v=3","gravatar_id":"","url":"https://api.github.com/users/LefterisJP","html_url":"https://github.com/LefterisJP","followers_url":"https://api.github.com/users/LefterisJP/followers","following_url":"https://api.github.com/users/LefterisJP/following{/other_user}","gists_url":"https://api.github.com/users/LefterisJP/gists{/gist_id}","starred_url":"https://api.github.com/users/LefterisJP/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LefterisJP/subscriptions","organizations_url":"https://api.github.com/users/LefterisJP/orgs","repos_url":"https://api.github.com/users/LefterisJP/repos","events_url":"https://api.github.com/users/LefterisJP/events{/privacy}","received_events_url":"https://api.github.com/users/LefterisJP/received_events","type":"User","site_admin":false},"body":"This is a first version.\r\nActual content of the JSON may change as usage by outside tools becomes more clear.","created_at":"2015-01-15T15:59:59Z","updated_at":"2015-01-15T21:34:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"46a8cd8e1799c01d9cfff428c8abe6c1d6c59953","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ethereum/cpp-ethereum/pulls/813/commits","review_comments_url":"https://api.github.com/repos/ethereum/cpp-ethereum/pulls/813/comments","review_comment_url":"https://api.github.com/repos/ethereum/cpp-ethereum/pulls/comments/{number}","comments_url":"https://api.github.com/repos/ethereum/cpp-ethereum/issues/813/comments","statuses_url":"https://api.github.com/repos/ethereum/cpp-ethereum/statuses/50d3825f1f93cff7d8332b67269964eff4eaeaa6","head":{"label":"LefterisJP:sol_astJson","ref":"sol_astJson","sha":"50d3825f1f93cff7d8332b67269964eff4eaeaa6","user":{"login":"LefterisJP","id":1658405,"avatar_url":"https://avatars.githubusercontent.com/u/1658405?v=3","gravatar_id":"","url":"https://api.github.com/users/LefterisJP","html_url":"https://github.com/LefterisJP","followers_url":"https://api.github.com/users/LefterisJP/followers","following_url":"https://api.github.com/users/LefterisJP/following{/other_user}","gists_url":"https://api.github.com/users/LefterisJP/gists{/gist_id}","starred_url":"https://api.github.com/users/LefterisJP/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LefterisJP/subscriptions","organizations_url":"https://api.github.com/users/LefterisJP/orgs","repos_url":"https://api.github.com/users/LefterisJP/repos","events_url":"https://api.github.com/users/LefterisJP/events{/privacy}","received_events_url":"https://api.github.com/users/LefterisJP/received_events","type":"User","site_admin":false},"repo":{"id":25381518,"name":"cpp-ethereum","full_name":"LefterisJP/cpp-ethereum","owner":{"login":"LefterisJP","id":1658405,"avatar_url":"https://avatars.githubusercontent.com/u/1658405?v=3","gravatar_id":"","url":"https://api.github.com/users/LefterisJP","html_url":"https://github.com/LefterisJP","followers_url":"https://api.github.com/users/LefterisJP/followers","following_url":"https://api.github.com/users/LefterisJP/following{/other_user}","gists_url":"https://api.github.com/users/LefterisJP/gists{/gist_id}","starred_url":"https://api.github.com/users/LefterisJP/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LefterisJP/subscriptions","organizations_url":"https://api.github.com/users/LefterisJP/orgs","repos_url":"https://api.github.com/users/LefterisJP/repos","events_url":"https://api.github.com/users/LefterisJP/events{/privacy}","received_events_url":"https://api.github.com/users/LefterisJP/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/LefterisJP/cpp-ethereum","description":"Gavin Wood's C++ implementation of the Ethereum yellowpaper.","fork":true,"url":"https://api.github.com/repos/LefterisJP/cpp-ethereum","forks_url":"https://api.github.com/repos/LefterisJP/cpp-ethereum/forks","keys_url":"https://api.github.com/repos/LefterisJP/cpp-ethereum/keys{/key_id}","collaborators_url":"https://api.github.com/repos/LefterisJP/cpp-ethereum/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/LefterisJP/cpp-ethereum/teams","hooks_url":"https://api.github.com/repos/LefterisJP/cpp-ethereum/hooks","issue_events_url":"https://api.github.com/repos/LefterisJP/cpp-ethereum/issues/events{/number}","events_url":"https://api.github.com/repos/LefterisJP/cpp-ethereum/events","assignees_url":"https://api.github.com/repos/LefterisJP/cpp-ethereum/assignees{/user}","branches_url":"https://api.github.com/repos/LefterisJP/cpp-ethereum/branches{/branch}","tags_url":"https://api.github.com/repos/LefterisJP/cpp-ethereum/tags","blobs_url":"https://api.github.com/repos/LefterisJP/cpp-ethereum/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/LefterisJP/cpp-ethereum/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/LefterisJP/cpp-ethereum/git/refs{/sha}","trees_url":"https://api.github.com/repos/LefterisJP/cpp-ethereum/git/trees{/sha}","statuses_url":"https://api.github.com/repos/LefterisJP/cpp-ethereum/statuses/{sha}","languages_url":"https://api.github.com/repos/LefterisJP/cpp-ethereum/languages","stargazers_url":"https://api.github.com/repos/LefterisJP/cpp-ethereum/stargazers","contributors_url":"https://api.github.com/repos/LefterisJP/cpp-ethereum/contributors","subscribers_url":"https://api.github.com/repos/LefterisJP/cpp-ethereum/subscribers","subscription_url":"https://api.github.com/repos/LefterisJP/cpp-ethereum/subscription","commits_url":"https://api.github.com/repos/LefterisJP/cpp-ethereum/commits{/sha}","git_commits_url":"https://api.github.com/repos/LefterisJP/cpp-ethereum/git/commits{/sha}","comments_url":"https://api.github.com/repos/LefterisJP/cpp-ethereum/comments{/number}","issue_comment_url":"https://api.github.com/repos/LefterisJP/cpp-ethereum/issues/comments/{number}","contents_url":"https://api.github.com/repos/LefterisJP/cpp-ethereum/contents/{+path}","compare_url":"https://api.github.com/repos/LefterisJP/cpp-ethereum/compare/{base}...{head}","merges_url":"https://api.github.com/repos/LefterisJP/cpp-ethereum/merges","archive_url":"https://api.github.com/repos/LefterisJP/cpp-ethereum/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/LefterisJP/cpp-ethereum/downloads","issues_url":"https://api.github.com/repos/LefterisJP/cpp-ethereum/issues{/number}","pulls_url":"https://api.github.com/repos/LefterisJP/cpp-ethereum/pulls{/number}","milestones_url":"https://api.github.com/repos/LefterisJP/cpp-ethereum/milestones{/number}","notifications_url":"https://api.github.com/repos/LefterisJP/cpp-ethereum/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/LefterisJP/cpp-ethereum/labels{/name}","releases_url":"https://api.github.com/repos/LefterisJP/cpp-ethereum/releases{/id}","created_at":"2014-10-17T23:43:38Z","updated_at":"2015-01-15T16:04:16Z","pushed_at":"2015-01-15T16:11:28Z","git_url":"git://github.com/LefterisJP/cpp-ethereum.git","ssh_url":"git@github.com:LefterisJP/cpp-ethereum.git","clone_url":"https://github.com/LefterisJP/cpp-ethereum.git","svn_url":"https://github.com/LefterisJP/cpp-ethereum","homepage":"www.gavwood.com/Paper.pdf","size":10527,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"develop"}},"base":{"label":"ethereum:develop","ref":"develop","sha":"478fba3d8ab0cd995d5ceecbbd8edebfe4032101","user":{"login":"ethereum","id":6250754,"avatar_url":"https://avatars.githubusercontent.com/u/6250754?v=3","gravatar_id":"","url":"https://api.github.com/users/ethereum","html_url":"https://github.com/ethereum","followers_url":"https://api.github.com/users/ethereum/followers","following_url":"https://api.github.com/users/ethereum/following{/other_user}","gists_url":"https://api.github.com/users/ethereum/gists{/gist_id}","starred_url":"https://api.github.com/users/ethereum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ethereum/subscriptions","organizations_url":"https://api.github.com/users/ethereum/orgs","repos_url":"https://api.github.com/users/ethereum/repos","events_url":"https://api.github.com/users/ethereum/events{/privacy}","received_events_url":"https://api.github.com/users/ethereum/received_events","type":"Organization","site_admin":false},"repo":{"id":15460666,"name":"cpp-ethereum","full_name":"ethereum/cpp-ethereum","owner":{"login":"ethereum","id":6250754,"avatar_url":"https://avatars.githubusercontent.com/u/6250754?v=3","gravatar_id":"","url":"https://api.github.com/users/ethereum","html_url":"https://github.com/ethereum","followers_url":"https://api.github.com/users/ethereum/followers","following_url":"https://api.github.com/users/ethereum/following{/other_user}","gists_url":"https://api.github.com/users/ethereum/gists{/gist_id}","starred_url":"https://api.github.com/users/ethereum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ethereum/subscriptions","organizations_url":"https://api.github.com/users/ethereum/orgs","repos_url":"https://api.github.com/users/ethereum/repos","events_url":"https://api.github.com/users/ethereum/events{/privacy}","received_events_url":"https://api.github.com/users/ethereum/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ethereum/cpp-ethereum","description":"Gavin Wood's C++ implementation of the Ethereum yellowpaper.","fork":false,"url":"https://api.github.com/repos/ethereum/cpp-ethereum","forks_url":"https://api.github.com/repos/ethereum/cpp-ethereum/forks","keys_url":"https://api.github.com/repos/ethereum/cpp-ethereum/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ethereum/cpp-ethereum/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ethereum/cpp-ethereum/teams","hooks_url":"https://api.github.com/repos/ethereum/cpp-ethereum/hooks","issue_events_url":"https://api.github.com/repos/ethereum/cpp-ethereum/issues/events{/number}","events_url":"https://api.github.com/repos/ethereum/cpp-ethereum/events","assignees_url":"https://api.github.com/repos/ethereum/cpp-ethereum/assignees{/user}","branches_url":"https://api.github.com/repos/ethereum/cpp-ethereum/branches{/branch}","tags_url":"https://api.github.com/repos/ethereum/cpp-ethereum/tags","blobs_url":"https://api.github.com/repos/ethereum/cpp-ethereum/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ethereum/cpp-ethereum/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ethereum/cpp-ethereum/git/refs{/sha}","trees_url":"https://api.github.com/repos/ethereum/cpp-ethereum/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ethereum/cpp-ethereum/statuses/{sha}","languages_url":"https://api.github.com/repos/ethereum/cpp-ethereum/languages","stargazers_url":"https://api.github.com/repos/ethereum/cpp-ethereum/stargazers","contributors_url":"https://api.github.com/repos/ethereum/cpp-ethereum/contributors","subscribers_url":"https://api.github.com/repos/ethereum/cpp-ethereum/subscribers","subscription_url":"https://api.github.com/repos/ethereum/cpp-ethereum/subscription","commits_url":"https://api.github.com/repos/ethereum/cpp-ethereum/commits{/sha}","git_commits_url":"https://api.github.com/repos/ethereum/cpp-ethereum/git/commits{/sha}","comments_url":"https://api.github.com/repos/ethereum/cpp-ethereum/comments{/number}","issue_comment_url":"https://api.github.com/repos/ethereum/cpp-ethereum/issues/comments/{number}","contents_url":"https://api.github.com/repos/ethereum/cpp-ethereum/contents/{+path}","compare_url":"https://api.github.com/repos/ethereum/cpp-ethereum/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ethereum/cpp-ethereum/merges","archive_url":"https://api.github.com/repos/ethereum/cpp-ethereum/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ethereum/cpp-ethereum/downloads","issues_url":"https://api.github.com/repos/ethereum/cpp-ethereum/issues{/number}","pulls_url":"https://api.github.com/repos/ethereum/cpp-ethereum/pulls{/number}","milestones_url":"https://api.github.com/repos/ethereum/cpp-ethereum/milestones{/number}","notifications_url":"https://api.github.com/repos/ethereum/cpp-ethereum/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ethereum/cpp-ethereum/labels{/name}","releases_url":"https://api.github.com/repos/ethereum/cpp-ethereum/releases{/id}","created_at":"2013-12-26T21:26:06Z","updated_at":"2015-01-15T20:36:12Z","pushed_at":"2015-01-15T20:36:11Z","git_url":"git://github.com/ethereum/cpp-ethereum.git","ssh_url":"git@github.com:ethereum/cpp-ethereum.git","clone_url":"https://github.com/ethereum/cpp-ethereum.git","svn_url":"https://github.com/ethereum/cpp-ethereum","homepage":"www.gavwood.com/Paper.pdf","size":30270,"stargazers_count":387,"watchers_count":387,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":135,"mirror_url":null,"open_issues_count":101,"forks":135,"open_issues":101,"watchers":387,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/ethereum/cpp-ethereum/pulls/813"},"html":{"href":"https://github.com/ethereum/cpp-ethereum/pull/813"},"issue":{"href":"https://api.github.com/repos/ethereum/cpp-ethereum/issues/813"},"comments":{"href":"https://api.github.com/repos/ethereum/cpp-ethereum/issues/813/comments"},"review_comments":{"href":"https://api.github.com/repos/ethereum/cpp-ethereum/pulls/813/comments"},"review_comment":{"href":"https://api.github.com/repos/ethereum/cpp-ethereum/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/ethereum/cpp-ethereum/pulls/813/commits"},"statuses":{"href":"https://api.github.com/repos/ethereum/cpp-ethereum/statuses/50d3825f1f93cff7d8332b67269964eff4eaeaa6"}}}}