{"action":"created","comment":{"url":"https://api.github.com/repos/ttsiodras/asn1scc/pulls/comments/69991720","id":69991720,"diff_hunk":"@@ -411,64 +411,26 @@ public static int CheckSuccess(IEnumerable<string> args)\n         }\r\n \r\n \r\n-        public static List<Tuple<ITree, string, IToken[]>> ParseAsn1InputFiles(IEnumerable<string> inputFiles)\r\n+        public static Tuple<ITree, string, IToken[]> Parse<L, P>(string filename, Func<ANTLRFileStream, L> lexer, Func<ITokenStream, P> parser, Func<P, ITree> root)\n+            where L : Lexer where P : Parser\r\n         {\r\n-            var parsedInputFiles = new List<Tuple<ITree, string, IToken[]>>();\r\n-\r\n-            foreach (var inFileName in inputFiles)\r\n-            {\r\n-                ICharStream input = new ANTLRFileStream(inFileName);\r\n-                asn1Lexer lexer = new asn1Lexer(input);\r\n-                CommonTokenStream tokens = new CommonTokenStream(lexer);\r\n-\r\n-                List<IToken> tokenslst = new List<IToken>();\r\n-                foreach (IToken token in tokens.GetTokens())\r\n-                {\r\n-                    tokenslst.Add(token);\r\n-                }\r\n-\r\n-                asn1Parser parser = new asn1Parser(tokens);\r\n-                asn1Parser.moduleDefinitions_return result = parser.moduleDefinitions();\r\n-\r\n-                ITree tree = (CommonTree)result.Tree;\r\n-                CommonTreeNodeStream nodes = new CommonTreeNodeStream(tree);\r\n-                nodes.TokenStream = tokens;\r\n-                parsedInputFiles.Add(Tuple.Create(tree, inFileName, tokenslst.ToArray() ));\r\n-            }\r\n-\r\n-            return parsedInputFiles;\r\n+            var stream = new CommonTokenStream(lexer(new ANTLRFileStream(filename)));\r\n+            var tokens = stream.GetTokens().Cast<IToken>().ToArray();\r\n+            var tree = root(parser(stream));\r\n+            return Tuple.Create(tree, filename, tokens);\r\n         }\r\n \r\n+        public static List<Tuple<ITree, string, IToken[]>> ParseAsn1InputFiles(IEnumerable<string> inputFiles)\r\n+        {\r\n+            return inputFiles.Select(f => Parse(f, fs => new asn1Lexer(fs), ts => new asn1Parser(ts), p => (CommonTree)p.moduleDefinitions().Tree)).ToList();\r\n+        }\n+\n         public static List<Tuple<ITree, string, IToken[]>> ParseAcnInputFiles(IEnumerable<string> inputFiles)\r\n         {\r\n-            var parsedInputFiles = new List<Tuple<ITree, string, IToken[]>>();\r\n-\r\n-            foreach (var inFileName in inputFiles)\r\n-            {\r\n-                ICharStream input = new ANTLRFileStream(inFileName);\r\n-                acnLexer lexer = new acnLexer(input);\r\n-                CommonTokenStream tokens = new CommonTokenStream(lexer);\r\n-\r\n-                List<IToken> tokenslst = new List<IToken>();\r\n-                foreach (IToken token in tokens.GetTokens())\r\n-                {\r\n-                    tokenslst.Add(token);\r\n-                }\r\n-\r\n-                acnParser parser = new acnParser(tokens);\r\n-                acnParser.moduleDefinitions_return result = parser.moduleDefinitions();\r\n-\r\n-                ITree tree = (CommonTree)result.Tree;\r\n-                CommonTreeNodeStream nodes = new CommonTreeNodeStream(tree);\r\n-                nodes.TokenStream = tokens;\r\n-                parsedInputFiles.Add(Tuple.Create(tree, inFileName, tokenslst.ToArray()));\r\n-            }\r\n-\r\n-            return parsedInputFiles;\r\n+            return inputFiles.Select(f => Parse(f, fs => new acnLexer(fs), ts => new acnParser(ts), p => (CommonTree)p.moduleDefinitions().Tree)).ToList();\r","path":"Asn1f2/Program.cs","position":69,"original_position":69,"commit_id":"99cff3f9e427f900d47681ccd8da92b42c3d1905","original_commit_id":"99cff3f9e427f900d47681ccd8da92b42c3d1905","user":{"login":"ttsiodras","id":181293,"avatar_url":"https://avatars.githubusercontent.com/u/181293?v=3","gravatar_id":"","url":"https://api.github.com/users/ttsiodras","html_url":"https://github.com/ttsiodras","followers_url":"https://api.github.com/users/ttsiodras/followers","following_url":"https://api.github.com/users/ttsiodras/following{/other_user}","gists_url":"https://api.github.com/users/ttsiodras/gists{/gist_id}","starred_url":"https://api.github.com/users/ttsiodras/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ttsiodras/subscriptions","organizations_url":"https://api.github.com/users/ttsiodras/orgs","repos_url":"https://api.github.com/users/ttsiodras/repos","events_url":"https://api.github.com/users/ttsiodras/events{/privacy}","received_events_url":"https://api.github.com/users/ttsiodras/received_events","type":"User","site_admin":false},"body":"Hi Alexandre.\r\n\r\nIt's clear there's a lot of repetition in that C# \"gateway\" code - I imagine George wrote it before he immersed himself in functional style (and F# in particular). The violation of DRY in some parts of the compiler (including Costas's testing Python script) is something I really wish I had time to dive in and fix - but my workload is not allowing me to do so. \r\n\r\nAt least CircleCI shows that your patch doesn't seem to break any tests. If it were up to me, I'd merge it; but since I am not the author of this code I better let George decide.","created_at":"2016-07-07T21:34:23Z","updated_at":"2016-07-07T21:34:23Z","html_url":"https://github.com/ttsiodras/asn1scc/pull/63#discussion_r69991720","pull_request_url":"https://api.github.com/repos/ttsiodras/asn1scc/pulls/63","_links":{"self":{"href":"https://api.github.com/repos/ttsiodras/asn1scc/pulls/comments/69991720"},"html":{"href":"https://github.com/ttsiodras/asn1scc/pull/63#discussion_r69991720"},"pull_request":{"href":"https://api.github.com/repos/ttsiodras/asn1scc/pulls/63"}}},"pull_request":{"url":"https://api.github.com/repos/ttsiodras/asn1scc/pulls/63","id":76651332,"html_url":"https://github.com/ttsiodras/asn1scc/pull/63","diff_url":"https://github.com/ttsiodras/asn1scc/pull/63.diff","patch_url":"https://github.com/ttsiodras/asn1scc/pull/63.patch","issue_url":"https://api.github.com/repos/ttsiodras/asn1scc/issues/63","number":63,"state":"open","locked":false,"title":"Refactor parse functions","user":{"login":"afesteves","id":2335822,"avatar_url":"https://avatars.githubusercontent.com/u/2335822?v=3","gravatar_id":"","url":"https://api.github.com/users/afesteves","html_url":"https://github.com/afesteves","followers_url":"https://api.github.com/users/afesteves/followers","following_url":"https://api.github.com/users/afesteves/following{/other_user}","gists_url":"https://api.github.com/users/afesteves/gists{/gist_id}","starred_url":"https://api.github.com/users/afesteves/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/afesteves/subscriptions","organizations_url":"https://api.github.com/users/afesteves/orgs","repos_url":"https://api.github.com/users/afesteves/repos","events_url":"https://api.github.com/users/afesteves/events{/privacy}","received_events_url":"https://api.github.com/users/afesteves/received_events","type":"User","site_admin":false},"body":"I will need to add a **ParseSDLInputFiles** eventually, and would rather not copy paste 25 lines.","created_at":"2016-07-07T19:26:18Z","updated_at":"2016-07-07T21:34:23Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c666bec163a7b50d19cdb51d471e1eb5f37aeb0e","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/ttsiodras/asn1scc/pulls/63/commits","review_comments_url":"https://api.github.com/repos/ttsiodras/asn1scc/pulls/63/comments","review_comment_url":"https://api.github.com/repos/ttsiodras/asn1scc/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ttsiodras/asn1scc/issues/63/comments","statuses_url":"https://api.github.com/repos/ttsiodras/asn1scc/statuses/99cff3f9e427f900d47681ccd8da92b42c3d1905","head":{"label":"afesteves:refactor/parse-functions","ref":"refactor/parse-functions","sha":"99cff3f9e427f900d47681ccd8da92b42c3d1905","user":{"login":"afesteves","id":2335822,"avatar_url":"https://avatars.githubusercontent.com/u/2335822?v=3","gravatar_id":"","url":"https://api.github.com/users/afesteves","html_url":"https://github.com/afesteves","followers_url":"https://api.github.com/users/afesteves/followers","following_url":"https://api.github.com/users/afesteves/following{/other_user}","gists_url":"https://api.github.com/users/afesteves/gists{/gist_id}","starred_url":"https://api.github.com/users/afesteves/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/afesteves/subscriptions","organizations_url":"https://api.github.com/users/afesteves/orgs","repos_url":"https://api.github.com/users/afesteves/repos","events_url":"https://api.github.com/users/afesteves/events{/privacy}","received_events_url":"https://api.github.com/users/afesteves/received_events","type":"User","site_admin":false},"repo":{"id":61164174,"name":"asn1scc","full_name":"afesteves/asn1scc","owner":{"login":"afesteves","id":2335822,"avatar_url":"https://avatars.githubusercontent.com/u/2335822?v=3","gravatar_id":"","url":"https://api.github.com/users/afesteves","html_url":"https://github.com/afesteves","followers_url":"https://api.github.com/users/afesteves/followers","following_url":"https://api.github.com/users/afesteves/following{/other_user}","gists_url":"https://api.github.com/users/afesteves/gists{/gist_id}","starred_url":"https://api.github.com/users/afesteves/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/afesteves/subscriptions","organizations_url":"https://api.github.com/users/afesteves/orgs","repos_url":"https://api.github.com/users/afesteves/repos","events_url":"https://api.github.com/users/afesteves/events{/privacy}","received_events_url":"https://api.github.com/users/afesteves/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/afesteves/asn1scc","description":"ASN1SCC: An open source ASN.1 compiler for embedded systems","fork":true,"url":"https://api.github.com/repos/afesteves/asn1scc","forks_url":"https://api.github.com/repos/afesteves/asn1scc/forks","keys_url":"https://api.github.com/repos/afesteves/asn1scc/keys{/key_id}","collaborators_url":"https://api.github.com/repos/afesteves/asn1scc/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/afesteves/asn1scc/teams","hooks_url":"https://api.github.com/repos/afesteves/asn1scc/hooks","issue_events_url":"https://api.github.com/repos/afesteves/asn1scc/issues/events{/number}","events_url":"https://api.github.com/repos/afesteves/asn1scc/events","assignees_url":"https://api.github.com/repos/afesteves/asn1scc/assignees{/user}","branches_url":"https://api.github.com/repos/afesteves/asn1scc/branches{/branch}","tags_url":"https://api.github.com/repos/afesteves/asn1scc/tags","blobs_url":"https://api.github.com/repos/afesteves/asn1scc/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/afesteves/asn1scc/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/afesteves/asn1scc/git/refs{/sha}","trees_url":"https://api.github.com/repos/afesteves/asn1scc/git/trees{/sha}","statuses_url":"https://api.github.com/repos/afesteves/asn1scc/statuses/{sha}","languages_url":"https://api.github.com/repos/afesteves/asn1scc/languages","stargazers_url":"https://api.github.com/repos/afesteves/asn1scc/stargazers","contributors_url":"https://api.github.com/repos/afesteves/asn1scc/contributors","subscribers_url":"https://api.github.com/repos/afesteves/asn1scc/subscribers","subscription_url":"https://api.github.com/repos/afesteves/asn1scc/subscription","commits_url":"https://api.github.com/repos/afesteves/asn1scc/commits{/sha}","git_commits_url":"https://api.github.com/repos/afesteves/asn1scc/git/commits{/sha}","comments_url":"https://api.github.com/repos/afesteves/asn1scc/comments{/number}","issue_comment_url":"https://api.github.com/repos/afesteves/asn1scc/issues/comments{/number}","contents_url":"https://api.github.com/repos/afesteves/asn1scc/contents/{+path}","compare_url":"https://api.github.com/repos/afesteves/asn1scc/compare/{base}...{head}","merges_url":"https://api.github.com/repos/afesteves/asn1scc/merges","archive_url":"https://api.github.com/repos/afesteves/asn1scc/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/afesteves/asn1scc/downloads","issues_url":"https://api.github.com/repos/afesteves/asn1scc/issues{/number}","pulls_url":"https://api.github.com/repos/afesteves/asn1scc/pulls{/number}","milestones_url":"https://api.github.com/repos/afesteves/asn1scc/milestones{/number}","notifications_url":"https://api.github.com/repos/afesteves/asn1scc/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/afesteves/asn1scc/labels{/name}","releases_url":"https://api.github.com/repos/afesteves/asn1scc/releases{/id}","deployments_url":"https://api.github.com/repos/afesteves/asn1scc/deployments","created_at":"2016-06-15T00:03:20Z","updated_at":"2016-06-15T00:03:23Z","pushed_at":"2016-07-07T19:25:43Z","git_url":"git://github.com/afesteves/asn1scc.git","ssh_url":"git@github.com:afesteves/asn1scc.git","clone_url":"https://github.com/afesteves/asn1scc.git","svn_url":"https://github.com/afesteves/asn1scc","homepage":null,"size":6880,"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":"master"}},"base":{"label":"ttsiodras:master","ref":"master","sha":"a5fb4a514f68eec1e1fdbc264dc5c9aab1ee03f7","user":{"login":"ttsiodras","id":181293,"avatar_url":"https://avatars.githubusercontent.com/u/181293?v=3","gravatar_id":"","url":"https://api.github.com/users/ttsiodras","html_url":"https://github.com/ttsiodras","followers_url":"https://api.github.com/users/ttsiodras/followers","following_url":"https://api.github.com/users/ttsiodras/following{/other_user}","gists_url":"https://api.github.com/users/ttsiodras/gists{/gist_id}","starred_url":"https://api.github.com/users/ttsiodras/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ttsiodras/subscriptions","organizations_url":"https://api.github.com/users/ttsiodras/orgs","repos_url":"https://api.github.com/users/ttsiodras/repos","events_url":"https://api.github.com/users/ttsiodras/events{/privacy}","received_events_url":"https://api.github.com/users/ttsiodras/received_events","type":"User","site_admin":false},"repo":{"id":10936997,"name":"asn1scc","full_name":"ttsiodras/asn1scc","owner":{"login":"ttsiodras","id":181293,"avatar_url":"https://avatars.githubusercontent.com/u/181293?v=3","gravatar_id":"","url":"https://api.github.com/users/ttsiodras","html_url":"https://github.com/ttsiodras","followers_url":"https://api.github.com/users/ttsiodras/followers","following_url":"https://api.github.com/users/ttsiodras/following{/other_user}","gists_url":"https://api.github.com/users/ttsiodras/gists{/gist_id}","starred_url":"https://api.github.com/users/ttsiodras/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ttsiodras/subscriptions","organizations_url":"https://api.github.com/users/ttsiodras/orgs","repos_url":"https://api.github.com/users/ttsiodras/repos","events_url":"https://api.github.com/users/ttsiodras/events{/privacy}","received_events_url":"https://api.github.com/users/ttsiodras/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ttsiodras/asn1scc","description":"ASN1SCC: An open source ASN.1 compiler for embedded systems","fork":false,"url":"https://api.github.com/repos/ttsiodras/asn1scc","forks_url":"https://api.github.com/repos/ttsiodras/asn1scc/forks","keys_url":"https://api.github.com/repos/ttsiodras/asn1scc/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ttsiodras/asn1scc/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ttsiodras/asn1scc/teams","hooks_url":"https://api.github.com/repos/ttsiodras/asn1scc/hooks","issue_events_url":"https://api.github.com/repos/ttsiodras/asn1scc/issues/events{/number}","events_url":"https://api.github.com/repos/ttsiodras/asn1scc/events","assignees_url":"https://api.github.com/repos/ttsiodras/asn1scc/assignees{/user}","branches_url":"https://api.github.com/repos/ttsiodras/asn1scc/branches{/branch}","tags_url":"https://api.github.com/repos/ttsiodras/asn1scc/tags","blobs_url":"https://api.github.com/repos/ttsiodras/asn1scc/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ttsiodras/asn1scc/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ttsiodras/asn1scc/git/refs{/sha}","trees_url":"https://api.github.com/repos/ttsiodras/asn1scc/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ttsiodras/asn1scc/statuses/{sha}","languages_url":"https://api.github.com/repos/ttsiodras/asn1scc/languages","stargazers_url":"https://api.github.com/repos/ttsiodras/asn1scc/stargazers","contributors_url":"https://api.github.com/repos/ttsiodras/asn1scc/contributors","subscribers_url":"https://api.github.com/repos/ttsiodras/asn1scc/subscribers","subscription_url":"https://api.github.com/repos/ttsiodras/asn1scc/subscription","commits_url":"https://api.github.com/repos/ttsiodras/asn1scc/commits{/sha}","git_commits_url":"https://api.github.com/repos/ttsiodras/asn1scc/git/commits{/sha}","comments_url":"https://api.github.com/repos/ttsiodras/asn1scc/comments{/number}","issue_comment_url":"https://api.github.com/repos/ttsiodras/asn1scc/issues/comments{/number}","contents_url":"https://api.github.com/repos/ttsiodras/asn1scc/contents/{+path}","compare_url":"https://api.github.com/repos/ttsiodras/asn1scc/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ttsiodras/asn1scc/merges","archive_url":"https://api.github.com/repos/ttsiodras/asn1scc/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ttsiodras/asn1scc/downloads","issues_url":"https://api.github.com/repos/ttsiodras/asn1scc/issues{/number}","pulls_url":"https://api.github.com/repos/ttsiodras/asn1scc/pulls{/number}","milestones_url":"https://api.github.com/repos/ttsiodras/asn1scc/milestones{/number}","notifications_url":"https://api.github.com/repos/ttsiodras/asn1scc/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ttsiodras/asn1scc/labels{/name}","releases_url":"https://api.github.com/repos/ttsiodras/asn1scc/releases{/id}","deployments_url":"https://api.github.com/repos/ttsiodras/asn1scc/deployments","created_at":"2013-06-25T11:58:00Z","updated_at":"2016-06-18T19:25:54Z","pushed_at":"2016-07-07T19:26:18Z","git_url":"git://github.com/ttsiodras/asn1scc.git","ssh_url":"git@github.com:ttsiodras/asn1scc.git","clone_url":"https://github.com/ttsiodras/asn1scc.git","svn_url":"https://github.com/ttsiodras/asn1scc","homepage":null,"size":6989,"stargazers_count":74,"watchers_count":74,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":16,"mirror_url":null,"open_issues_count":2,"forks":16,"open_issues":2,"watchers":74,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ttsiodras/asn1scc/pulls/63"},"html":{"href":"https://github.com/ttsiodras/asn1scc/pull/63"},"issue":{"href":"https://api.github.com/repos/ttsiodras/asn1scc/issues/63"},"comments":{"href":"https://api.github.com/repos/ttsiodras/asn1scc/issues/63/comments"},"review_comments":{"href":"https://api.github.com/repos/ttsiodras/asn1scc/pulls/63/comments"},"review_comment":{"href":"https://api.github.com/repos/ttsiodras/asn1scc/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ttsiodras/asn1scc/pulls/63/commits"},"statuses":{"href":"https://api.github.com/repos/ttsiodras/asn1scc/statuses/99cff3f9e427f900d47681ccd8da92b42c3d1905"}}}}
{"actor":{"display_login":"ttsiodras"}}