{"action":"created","comment":{"url":"https://api.github.com/repos/mathics/Mathics/pulls/comments/67626078","id":67626078,"diff_hunk":"@@ -0,0 +1,665 @@\n+#!/usr/bin/env python\n+# -*- coding: utf-8 -*-\n+\n+from __future__ import absolute_import\n+from __future__ import unicode_literals\n+\n+import sys\n+import random\n+import unittest\n+\n+from mathics.core.parser.errors import ScanError, IncompleteSyntaxError, InvalidSyntaxError\n+from mathics.core.parser.ast import Node, Symbol, Number, String, Filename\n+from mathics.core.parser.feed import SingleLineFeeder\n+from mathics.core.parser.parser import Parser\n+\n+import six\n+\n+\n+class ParserTests(unittest.TestCase):\n+    def setUp(self):\n+        self.parser = Parser()\n+\n+    def parse(self, s):\n+        return self.parser.parse(SingleLineFeeder(s))\n+\n+    def check(self, expr1, expr2):\n+        if isinstance(expr1, six.string_types):\n+            expr1 = self.parse(expr1)\n+        if isinstance(expr2, six.string_types):\n+            expr2 = self.parse(expr2)\n+\n+        if expr1 is None:\n+            self.assertIsNone(expr2)\n+        else:\n+            self.assertEqual(repr(expr1), repr(expr2))\n+            self.assertEqual(expr1, expr2)\n+\n+    def scan_error(self, string):\n+        self.assertRaises(ScanError, self.parse, string)\n+\n+    def incomplete_error(self, string):\n+        self.assertRaises(IncompleteSyntaxError, self.parse, string)\n+\n+    def invalid_error(self, string):\n+        self.assertRaises(InvalidSyntaxError, self.parse, string)\n+\n+\n+class PrecedenceTests(ParserTests):\n+    def test_minuslike(self):\n+        self.check('a * + b', 'Times[a, Plus[b]]')\n+        self.check('- a . b', 'Times[-1, Dot[a, b]]'),\n+        self.check('- a / b', 'Times[-1, a, Power[b, -1]]'),\n+        self.check('- a / - b', 'Times[-1, a, Power[Times[-1, b], -1]]')\n+        self.check('- a / - b', 'Times[-1, a, Power[Times[-1, b], -1]]')\n+        self.check('a + b!', 'Plus[a, Factorial[b]]')\n+        self.check('!a!', 'Not[Factorial[a]]')\n+\n+\n+class AssocTests(ParserTests):\n+    def test_right(self):\n+        self.check('a ^ b ^ c', 'a ^ (b ^ c)')\n+\n+    def test_flat(self):\n+        self.check('a + b + c', 'Plus[a, b, c]')\n+\n+    def test_left(self):\n+        self.check('a /; b /; c', '(a /; b) /; c')\n+\n+    def test_Subtract(self):\n+        self.check('a - b - c', 'Plus[a, Times[-1, b], Times[-1, c]]')","path":"test/test_parser/test_parser.py","position":70,"original_position":70,"commit_id":"95db173ad2414cf1db425df3873034cfea9d61dd","original_commit_id":"95db173ad2414cf1db425df3873034cfea9d61dd","user":{"login":"wolfv","id":885054,"avatar_url":"https://avatars.githubusercontent.com/u/885054?v=3","gravatar_id":"","url":"https://api.github.com/users/wolfv","html_url":"https://github.com/wolfv","followers_url":"https://api.github.com/users/wolfv/followers","following_url":"https://api.github.com/users/wolfv/following{/other_user}","gists_url":"https://api.github.com/users/wolfv/gists{/gist_id}","starred_url":"https://api.github.com/users/wolfv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wolfv/subscriptions","organizations_url":"https://api.github.com/users/wolfv/orgs","repos_url":"https://api.github.com/users/wolfv/repos","events_url":"https://api.github.com/users/wolfv/events{/privacy}","received_events_url":"https://api.github.com/users/wolfv/received_events","type":"User","site_admin":false},"body":"Just curious as to why `-` is parsed as plus-times-minus :) ","created_at":"2016-06-19T23:53:07Z","updated_at":"2016-06-19T23:53:07Z","html_url":"https://github.com/mathics/Mathics/pull/416#discussion_r67626078","pull_request_url":"https://api.github.com/repos/mathics/Mathics/pulls/416","_links":{"self":{"href":"https://api.github.com/repos/mathics/Mathics/pulls/comments/67626078"},"html":{"href":"https://github.com/mathics/Mathics/pull/416#discussion_r67626078"},"pull_request":{"href":"https://api.github.com/repos/mathics/Mathics/pulls/416"}}},"pull_request":{"url":"https://api.github.com/repos/mathics/Mathics/pulls/416","id":74058523,"html_url":"https://github.com/mathics/Mathics/pull/416","diff_url":"https://github.com/mathics/Mathics/pull/416.diff","patch_url":"https://github.com/mathics/Mathics/pull/416.patch","issue_url":"https://api.github.com/repos/mathics/Mathics/issues/416","number":416,"state":"open","locked":false,"title":"Recursive descent parser","user":{"login":"sn6uv","id":1217643,"avatar_url":"https://avatars.githubusercontent.com/u/1217643?v=3","gravatar_id":"","url":"https://api.github.com/users/sn6uv","html_url":"https://github.com/sn6uv","followers_url":"https://api.github.com/users/sn6uv/followers","following_url":"https://api.github.com/users/sn6uv/following{/other_user}","gists_url":"https://api.github.com/users/sn6uv/gists{/gist_id}","starred_url":"https://api.github.com/users/sn6uv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sn6uv/subscriptions","organizations_url":"https://api.github.com/users/sn6uv/orgs","repos_url":"https://api.github.com/users/sn6uv/repos","events_url":"https://api.github.com/users/sn6uv/events{/privacy}","received_events_url":"https://api.github.com/users/sn6uv/received_events","type":"User","site_admin":false},"body":"### Fixes:\r\n - #365\r\n - #260 (but not #381)\r\n - `Optional`/`Pattern` parsing\r\n - many other minor parser bugs\r\n - no more 15mins of silence when rebuilding the tables (when upgrading ply).\r\n\r\n`O(lines)` runtime for multi-line input, previously `O(lines^2)` with 'add a line and retry' approach.\r\n\r\n### Dependencies\r\nDrops `ply` as a requirement.\r\n\r\n### Benchmarks\r\n| test | `master` | `parser` | MMA\r\n|------|------------|------------|------ \r\n`1+2+...+300` | 11.8ms | 8.01ms |\r\n`1;2;...;300` | 10.5ms | 7.47ms |\r\n`1/2/.../300` | 24.2ms | 14.9ms |\r\n`1^2^...^300` | 16.9ms | 11.0ms |\r\n`! ! ... ! expr` | 10.4ms | 6.63ms |\r\n` expr & & ... &` | 11.1ms | 6.03ms |\r\n` Sin[Sin[...]]` | 29.6ms | 15.1ms |\r\n``Needs[\"Combinatorica`\"]`` | 34.4s | 3.81s | 0.243s\r\nLaunch kernel | 2.20s | 1.97s | 0.450s\r\nMathics test suite | 516s | 294s |\r\n\r\nPerformance is marginally better but the main gains are for multi-line input. ","created_at":"2016-06-16T10:40:28Z","updated_at":"2016-06-19T23:53:07Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3df298ce75c6377efd45de17fd8e84adaef202ba","assignee":null,"milestone":{"url":"https://api.github.com/repos/mathics/Mathics/milestones/5","html_url":"https://github.com/mathics/Mathics/milestones/1.0","labels_url":"https://api.github.com/repos/mathics/Mathics/milestones/5/labels","id":1614979,"number":5,"title":"1.0","description":"","creator":{"login":"sn6uv","id":1217643,"avatar_url":"https://avatars.githubusercontent.com/u/1217643?v=3","gravatar_id":"","url":"https://api.github.com/users/sn6uv","html_url":"https://github.com/sn6uv","followers_url":"https://api.github.com/users/sn6uv/followers","following_url":"https://api.github.com/users/sn6uv/following{/other_user}","gists_url":"https://api.github.com/users/sn6uv/gists{/gist_id}","starred_url":"https://api.github.com/users/sn6uv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sn6uv/subscriptions","organizations_url":"https://api.github.com/users/sn6uv/orgs","repos_url":"https://api.github.com/users/sn6uv/repos","events_url":"https://api.github.com/users/sn6uv/events{/privacy}","received_events_url":"https://api.github.com/users/sn6uv/received_events","type":"User","site_admin":false},"open_issues":4,"closed_issues":0,"state":"open","created_at":"2016-03-01T12:54:32Z","updated_at":"2016-06-17T10:57:25Z","due_on":"2016-08-14T22:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/mathics/Mathics/pulls/416/commits","review_comments_url":"https://api.github.com/repos/mathics/Mathics/pulls/416/comments","review_comment_url":"https://api.github.com/repos/mathics/Mathics/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mathics/Mathics/issues/416/comments","statuses_url":"https://api.github.com/repos/mathics/Mathics/statuses/95db173ad2414cf1db425df3873034cfea9d61dd","head":{"label":"sn6uv:parser","ref":"parser","sha":"95db173ad2414cf1db425df3873034cfea9d61dd","user":{"login":"sn6uv","id":1217643,"avatar_url":"https://avatars.githubusercontent.com/u/1217643?v=3","gravatar_id":"","url":"https://api.github.com/users/sn6uv","html_url":"https://github.com/sn6uv","followers_url":"https://api.github.com/users/sn6uv/followers","following_url":"https://api.github.com/users/sn6uv/following{/other_user}","gists_url":"https://api.github.com/users/sn6uv/gists{/gist_id}","starred_url":"https://api.github.com/users/sn6uv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sn6uv/subscriptions","organizations_url":"https://api.github.com/users/sn6uv/orgs","repos_url":"https://api.github.com/users/sn6uv/repos","events_url":"https://api.github.com/users/sn6uv/events{/privacy}","received_events_url":"https://api.github.com/users/sn6uv/received_events","type":"User","site_admin":false},"repo":{"id":4579327,"name":"Mathics","full_name":"sn6uv/Mathics","owner":{"login":"sn6uv","id":1217643,"avatar_url":"https://avatars.githubusercontent.com/u/1217643?v=3","gravatar_id":"","url":"https://api.github.com/users/sn6uv","html_url":"https://github.com/sn6uv","followers_url":"https://api.github.com/users/sn6uv/followers","following_url":"https://api.github.com/users/sn6uv/following{/other_user}","gists_url":"https://api.github.com/users/sn6uv/gists{/gist_id}","starred_url":"https://api.github.com/users/sn6uv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sn6uv/subscriptions","organizations_url":"https://api.github.com/users/sn6uv/orgs","repos_url":"https://api.github.com/users/sn6uv/repos","events_url":"https://api.github.com/users/sn6uv/events{/privacy}","received_events_url":"https://api.github.com/users/sn6uv/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sn6uv/Mathics","description":"a general-purpose computer algebra system","fork":true,"url":"https://api.github.com/repos/sn6uv/Mathics","forks_url":"https://api.github.com/repos/sn6uv/Mathics/forks","keys_url":"https://api.github.com/repos/sn6uv/Mathics/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sn6uv/Mathics/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sn6uv/Mathics/teams","hooks_url":"https://api.github.com/repos/sn6uv/Mathics/hooks","issue_events_url":"https://api.github.com/repos/sn6uv/Mathics/issues/events{/number}","events_url":"https://api.github.com/repos/sn6uv/Mathics/events","assignees_url":"https://api.github.com/repos/sn6uv/Mathics/assignees{/user}","branches_url":"https://api.github.com/repos/sn6uv/Mathics/branches{/branch}","tags_url":"https://api.github.com/repos/sn6uv/Mathics/tags","blobs_url":"https://api.github.com/repos/sn6uv/Mathics/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sn6uv/Mathics/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sn6uv/Mathics/git/refs{/sha}","trees_url":"https://api.github.com/repos/sn6uv/Mathics/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sn6uv/Mathics/statuses/{sha}","languages_url":"https://api.github.com/repos/sn6uv/Mathics/languages","stargazers_url":"https://api.github.com/repos/sn6uv/Mathics/stargazers","contributors_url":"https://api.github.com/repos/sn6uv/Mathics/contributors","subscribers_url":"https://api.github.com/repos/sn6uv/Mathics/subscribers","subscription_url":"https://api.github.com/repos/sn6uv/Mathics/subscription","commits_url":"https://api.github.com/repos/sn6uv/Mathics/commits{/sha}","git_commits_url":"https://api.github.com/repos/sn6uv/Mathics/git/commits{/sha}","comments_url":"https://api.github.com/repos/sn6uv/Mathics/comments{/number}","issue_comment_url":"https://api.github.com/repos/sn6uv/Mathics/issues/comments{/number}","contents_url":"https://api.github.com/repos/sn6uv/Mathics/contents/{+path}","compare_url":"https://api.github.com/repos/sn6uv/Mathics/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sn6uv/Mathics/merges","archive_url":"https://api.github.com/repos/sn6uv/Mathics/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sn6uv/Mathics/downloads","issues_url":"https://api.github.com/repos/sn6uv/Mathics/issues{/number}","pulls_url":"https://api.github.com/repos/sn6uv/Mathics/pulls{/number}","milestones_url":"https://api.github.com/repos/sn6uv/Mathics/milestones{/number}","notifications_url":"https://api.github.com/repos/sn6uv/Mathics/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sn6uv/Mathics/labels{/name}","releases_url":"https://api.github.com/repos/sn6uv/Mathics/releases{/id}","deployments_url":"https://api.github.com/repos/sn6uv/Mathics/deployments","created_at":"2012-06-06T23:51:57Z","updated_at":"2016-02-15T10:13:23Z","pushed_at":"2016-06-19T13:47:03Z","git_url":"git://github.com/sn6uv/Mathics.git","ssh_url":"git@github.com:sn6uv/Mathics.git","clone_url":"https://github.com/sn6uv/Mathics.git","svn_url":"https://github.com/sn6uv/Mathics","homepage":"http://www.mathics.org","size":11264,"stargazers_count":9,"watchers_count":9,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":0,"forks":2,"open_issues":0,"watchers":9,"default_branch":"master"}},"base":{"label":"mathics:master","ref":"master","sha":"f37a56abe9d8c5931c3dfe78387f9276262eb37f","user":{"login":"mathics","id":655749,"avatar_url":"https://avatars.githubusercontent.com/u/655749?v=3","gravatar_id":"","url":"https://api.github.com/users/mathics","html_url":"https://github.com/mathics","followers_url":"https://api.github.com/users/mathics/followers","following_url":"https://api.github.com/users/mathics/following{/other_user}","gists_url":"https://api.github.com/users/mathics/gists{/gist_id}","starred_url":"https://api.github.com/users/mathics/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mathics/subscriptions","organizations_url":"https://api.github.com/users/mathics/orgs","repos_url":"https://api.github.com/users/mathics/repos","events_url":"https://api.github.com/users/mathics/events{/privacy}","received_events_url":"https://api.github.com/users/mathics/received_events","type":"Organization","site_admin":false},"repo":{"id":1341741,"name":"Mathics","full_name":"mathics/Mathics","owner":{"login":"mathics","id":655749,"avatar_url":"https://avatars.githubusercontent.com/u/655749?v=3","gravatar_id":"","url":"https://api.github.com/users/mathics","html_url":"https://github.com/mathics","followers_url":"https://api.github.com/users/mathics/followers","following_url":"https://api.github.com/users/mathics/following{/other_user}","gists_url":"https://api.github.com/users/mathics/gists{/gist_id}","starred_url":"https://api.github.com/users/mathics/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mathics/subscriptions","organizations_url":"https://api.github.com/users/mathics/orgs","repos_url":"https://api.github.com/users/mathics/repos","events_url":"https://api.github.com/users/mathics/events{/privacy}","received_events_url":"https://api.github.com/users/mathics/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mathics/Mathics","description":"a general-purpose computer algebra system","fork":false,"url":"https://api.github.com/repos/mathics/Mathics","forks_url":"https://api.github.com/repos/mathics/Mathics/forks","keys_url":"https://api.github.com/repos/mathics/Mathics/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mathics/Mathics/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mathics/Mathics/teams","hooks_url":"https://api.github.com/repos/mathics/Mathics/hooks","issue_events_url":"https://api.github.com/repos/mathics/Mathics/issues/events{/number}","events_url":"https://api.github.com/repos/mathics/Mathics/events","assignees_url":"https://api.github.com/repos/mathics/Mathics/assignees{/user}","branches_url":"https://api.github.com/repos/mathics/Mathics/branches{/branch}","tags_url":"https://api.github.com/repos/mathics/Mathics/tags","blobs_url":"https://api.github.com/repos/mathics/Mathics/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mathics/Mathics/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mathics/Mathics/git/refs{/sha}","trees_url":"https://api.github.com/repos/mathics/Mathics/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mathics/Mathics/statuses/{sha}","languages_url":"https://api.github.com/repos/mathics/Mathics/languages","stargazers_url":"https://api.github.com/repos/mathics/Mathics/stargazers","contributors_url":"https://api.github.com/repos/mathics/Mathics/contributors","subscribers_url":"https://api.github.com/repos/mathics/Mathics/subscribers","subscription_url":"https://api.github.com/repos/mathics/Mathics/subscription","commits_url":"https://api.github.com/repos/mathics/Mathics/commits{/sha}","git_commits_url":"https://api.github.com/repos/mathics/Mathics/git/commits{/sha}","comments_url":"https://api.github.com/repos/mathics/Mathics/comments{/number}","issue_comment_url":"https://api.github.com/repos/mathics/Mathics/issues/comments{/number}","contents_url":"https://api.github.com/repos/mathics/Mathics/contents/{+path}","compare_url":"https://api.github.com/repos/mathics/Mathics/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mathics/Mathics/merges","archive_url":"https://api.github.com/repos/mathics/Mathics/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mathics/Mathics/downloads","issues_url":"https://api.github.com/repos/mathics/Mathics/issues{/number}","pulls_url":"https://api.github.com/repos/mathics/Mathics/pulls{/number}","milestones_url":"https://api.github.com/repos/mathics/Mathics/milestones{/number}","notifications_url":"https://api.github.com/repos/mathics/Mathics/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mathics/Mathics/labels{/name}","releases_url":"https://api.github.com/repos/mathics/Mathics/releases{/id}","deployments_url":"https://api.github.com/repos/mathics/Mathics/deployments","created_at":"2011-02-08T11:53:13Z","updated_at":"2016-06-17T19:22:37Z","pushed_at":"2016-06-19T13:47:03Z","git_url":"git://github.com/mathics/Mathics.git","ssh_url":"git@github.com:mathics/Mathics.git","clone_url":"https://github.com/mathics/Mathics.git","svn_url":"https://github.com/mathics/Mathics","homepage":"https://mathics.github.io","size":11762,"stargazers_count":1041,"watchers_count":1041,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":130,"mirror_url":null,"open_issues_count":63,"forks":130,"open_issues":63,"watchers":1041,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mathics/Mathics/pulls/416"},"html":{"href":"https://github.com/mathics/Mathics/pull/416"},"issue":{"href":"https://api.github.com/repos/mathics/Mathics/issues/416"},"comments":{"href":"https://api.github.com/repos/mathics/Mathics/issues/416/comments"},"review_comments":{"href":"https://api.github.com/repos/mathics/Mathics/pulls/416/comments"},"review_comment":{"href":"https://api.github.com/repos/mathics/Mathics/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mathics/Mathics/pulls/416/commits"},"statuses":{"href":"https://api.github.com/repos/mathics/Mathics/statuses/95db173ad2414cf1db425df3873034cfea9d61dd"}}}}
{"actor":{"display_login":"wolfv"}}