{"action":"closed","issue":{"url":"https://api.github.com/repos/pegjs/pegjs/issues/321","labels_url":"https://api.github.com/repos/pegjs/pegjs/issues/321/labels{/name}","comments_url":"https://api.github.com/repos/pegjs/pegjs/issues/321/comments","events_url":"https://api.github.com/repos/pegjs/pegjs/issues/321/events","html_url":"https://github.com/pegjs/pegjs/issues/321","id":58266932,"number":321,"title":"Performance terrible - what can I do? ","user":{"login":"ZiCog","id":2519277,"avatar_url":"https://avatars.githubusercontent.com/u/2519277?v=3","gravatar_id":"","url":"https://api.github.com/users/ZiCog","html_url":"https://github.com/ZiCog","followers_url":"https://api.github.com/users/ZiCog/followers","following_url":"https://api.github.com/users/ZiCog/following{/other_user}","gists_url":"https://api.github.com/users/ZiCog/gists{/gist_id}","starred_url":"https://api.github.com/users/ZiCog/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ZiCog/subscriptions","organizations_url":"https://api.github.com/users/ZiCog/orgs","repos_url":"https://api.github.com/users/ZiCog/repos","events_url":"https://api.github.com/users/ZiCog/events{/privacy}","received_events_url":"https://api.github.com/users/ZiCog/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-02-19T20:43:13Z","updated_at":"2015-02-19T22:23:42Z","closed_at":"2015-02-19T22:23:42Z","body":"I have a rather complex expression syntax to deal with. It has a lot of operators, 13 levels of operator precedence and a bunch of number types to deal with.\r\n\r\nI have grown my attempt at a parser for this from the example on pegjs/online. \r\n\r\nIt works very well but seems to suffer from an exponential slow down as my expressions get more complex. \r\n\r\nHaving not included any white space checking I can parse this \"1AND(3)AND6\" well enough. But this \"1AND((((3))))AND6\" takes forever. Having an actual syntax error like this \"1AND(((())))AND6\" seems to be even worse. If I start to add parsing of symbols and white space skipping it gets even worse.\r\n\r\nIs there a trick I am missing to speed this up or  is that just how it is?\r\n\r\nAnyway here is my grammar:\r\n\r\n    start\r\n      = level11\r\n\r\n    level11\r\n      = l:level10 o:\"OR\"i  r:level11\r\n      / level10\r\n    \r\n    level10\r\n      = l:level9 o:\"AND\"i r:level10\r\n      / level9\r\n    \r\n    level9\r\n      /* TODO: */\r\n      = level8\r\n    \r\n    level8\r\n      = l:level7 o:(\"<\" / \">\" / \"<>\" / \"==\" / \"=<\" / \">\") r:level8\r\n      / level7\r\n    \r\n    level7\r\n      = l:level6 o:(\"#>\" / \"<#\") r:level7\r\n      / level6\r\n    \r\n    level6\r\n      = l:level5 o:[+-]  r:level6\r\n      / level5\r\n    \r\n    level5\r\n      = l:level4 o:[*/] r:level5\r\n      / level4\r\n    \r\n    level4\r\n      = l:level3 o:[|^] r:level4\r\n      / level3\r\n\r\n    level3\r\n      = l:level2 o:\"&\" r:level3\r\n      / level2\r\n\r\n    level2\r\n      = l:primary o:(\"->\" / \"<-\" / \">>\" / \"<<\" / \"~>\" / \"><\") r:level2\r\n      / primary\r\n    \r\n    primary\r\n       = \"(\" e:level11 \")\" { return e; }\r\n      / number\r\n    \r\n    number\r\n      = QuaternaryNumber\r\n      / binaryNumber\r\n      / hexNumber\r\n      / decimalNumber\r\n    \r\n    binaryNumber\r\n      = \"%\" d:[0-1]+\r\n    \r\n    QuaternaryNumber\r\n      = \"%%\" d:[0-3]+\r\n    \r\n    decimalNumber\r\n      = d:[0-9]+\r\n    \r\n    hexNumber\r\n      = \"$\" d:[0-9a-fA-F]+\r\n"}}