{"action":"created","issue":{"url":"https://api.github.com/repos/antlr/antlr4/issues/866","labels_url":"https://api.github.com/repos/antlr/antlr4/issues/866/labels{/name}","comments_url":"https://api.github.com/repos/antlr/antlr4/issues/866/comments","events_url":"https://api.github.com/repos/antlr/antlr4/issues/866/events","html_url":"https://github.com/antlr/antlr4/issues/866","id":72804056,"number":866,"title":"Precedence and Left-recursion Bug?","user":{"login":"twodee","id":1939462,"avatar_url":"https://avatars.githubusercontent.com/u/1939462?v=3","gravatar_id":"","url":"https://api.github.com/users/twodee","html_url":"https://github.com/twodee","followers_url":"https://api.github.com/users/twodee/followers","following_url":"https://api.github.com/users/twodee/following{/other_user}","gists_url":"https://api.github.com/users/twodee/gists{/gist_id}","starred_url":"https://api.github.com/users/twodee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/twodee/subscriptions","organizations_url":"https://api.github.com/users/twodee/orgs","repos_url":"https://api.github.com/users/twodee/repos","events_url":"https://api.github.com/users/twodee/events{/privacy}","received_events_url":"https://api.github.com/users/twodee/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":11,"created_at":"2015-05-03T13:15:09Z","updated_at":"2015-05-03T20:33:47Z","closed_at":"2015-05-03T19:10:57Z","body":"I'm trying to write a grammar that supports functions calls without using parentheses:\r\n\r\n    f x, y\r\n\r\nAs in Haskell, I'd like function calls to minimally slurp up their parameters. That is, I want\r\n\r\n    g 5 + 3\r\n\r\nto mean\r\n\r\n    (g 5) + 3\r\n\r\ninstead of\r\n\r\n    g (5 + 3)\r\n\r\nUnfortunately, I'm getting the second parse with this grammar:\r\n\r\n    grammar Parameters;\r\n    \r\n    expr\r\n      : '(' expr ')'\r\n      | expr MULTIPLICATIVE_OPERATOR expr\r\n      | expr ADDITIVE_OPERATOR expr\r\n      | ID (expr (',' expr)*?)??\r\n      | INT\r\n      ;\r\n    \r\n    MULTIPLICATIVE_OPERATOR: [*/%];\r\n    ADDITIVE_OPERATOR: [-+];\r\n    \r\n    ID: [a..z]+;\r\n    INT: '-'? [0-9]+;\r\n    WHITESPACE: [ \\t\\n\\r]+ -> skip;\r\n\r\nThe parse tree I'm getting is this:\r\n\r\n![Not the parse tree I want][1]\r\n\r\nI had thought that the subrule listed first would get attempted first. In this case, `expr ADDITIVE_OPERATOR expr` appears before the `ID` subrule, so why is the `ID` subrule taking higher precedence?\r\n\r\nI'm running ANTLR 4.5. Thanks for any help!\r\n\r\n  [1]: http://i.stack.imgur.com/qSQkZ.png"},"comment":{"url":"https://api.github.com/repos/antlr/antlr4/issues/comments/98541112","html_url":"https://github.com/antlr/antlr4/issues/866#issuecomment-98541112","issue_url":"https://api.github.com/repos/antlr/antlr4/issues/866","id":98541112,"user":{"login":"sharwell","id":1408396,"avatar_url":"https://avatars.githubusercontent.com/u/1408396?v=3","gravatar_id":"","url":"https://api.github.com/users/sharwell","html_url":"https://github.com/sharwell","followers_url":"https://api.github.com/users/sharwell/followers","following_url":"https://api.github.com/users/sharwell/following{/other_user}","gists_url":"https://api.github.com/users/sharwell/gists{/gist_id}","starred_url":"https://api.github.com/users/sharwell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sharwell/subscriptions","organizations_url":"https://api.github.com/users/sharwell/orgs","repos_url":"https://api.github.com/users/sharwell/repos","events_url":"https://api.github.com/users/sharwell/events{/privacy}","received_events_url":"https://api.github.com/users/sharwell/received_events","type":"User","site_admin":false},"created_at":"2015-05-03T20:33:46Z","updated_at":"2015-05-03T20:33:46Z","body":"I can't believe I didn't realize this earlier. While I have not tested the outcome, I believe the problem stems from not treating the implicit operator and the `,` operator separately. The following items should be separate alternatives in `expr` (I am not certain which order they should appear in):\r\n\r\n1. `ID expr`\r\n2. `expr ',' expr`"}}