{"status":"ok","message-type":"work","message-version":"1.0.0","message":{"indexed":{"date-parts":[[2026,7,23]],"date-time":"2026-07-23T20:12:30Z","timestamp":1784837550500,"version":"3.55.0"},"reference-count":19,"publisher":"Association for Computing Machinery (ACM)","issue":"ICFP","license":[{"start":{"date-parts":[[2020,8,2]],"date-time":"2020-08-02T00:00:00Z","timestamp":1596326400000},"content-version":"vor","delay-in-days":0,"URL":"https:\/\/creativecommons.org\/licenses\/by\/4.0\/"}],"content-domain":{"domain":["dl.acm.org"],"crossmark-restriction":true},"short-container-title":["Proc. ACM Program. Lang."],"published-print":{"date-parts":[[2020,8,2]]},"abstract":"<jats:p>Parsing with Derivatives (PwD) is an elegant approach to parsing context-free grammars (CFGs). It takes the equational theory behind Brzozowski's derivative for regular expressions and augments that theory with laziness, memoization, and fixed points. The result is a simple parser for arbitrary CFGs. Although recent work improved the performance of PwD, it remains inefficient due to the algorithm repeatedly traversing some parts of the grammar.<\/jats:p>\n          <jats:p>In this functional pearl, we show how to avoid this inefficiency by suspending the state of the traversal in a zipper. When subsequent derivatives are taken, we can resume the traversal from where we left off without retraversing already traversed parts of the grammar.<\/jats:p>\n          <jats:p>However, the original zipper is designed for use with trees, and we want to parse CFGs. CFGs can include shared regions, cycles, and choices between alternates, which makes them incompatible with the traditional tree model for zippers. This paper develops a generalization of zippers to properly handle these additional features. Just as PwD generalized Brzozowski's derivatives from regular expressions to CFGs, we generalize Huet's zippers from trees to CFGs.<\/jats:p>\n          <jats:p>Abstract The resulting parsing algorithm is concise and efficient: it takes only 31\u00a0lines of OCaml code to implement the derivative function but performs 6,500\u00a0times faster than the original PwD and 3.24\u00a0times faster than the optimized implementation of PwD.<\/jats:p>","DOI":"10.1145\/3408990","type":"journal-article","created":{"date-parts":[[2020,8,3]],"date-time":"2020-08-03T13:48:02Z","timestamp":1596462482000},"page":"1-28","update-policy":"https:\/\/doi.org\/10.1145\/crossmark-policy","source":"Crossref","is-referenced-by-count":6,"title":["Parsing with zippers (functional pearl)"],"prefix":"10.1145","volume":"4","author":[{"ORCID":"https:\/\/orcid.org\/0000-0002-6490-3466","authenticated-orcid":false,"given":"Pierce","family":"Darragh","sequence":"first","affiliation":[{"name":"University of Utah, USA"}],"role":[{"vocabulary":"crossref","role":"author"}]},{"ORCID":"https:\/\/orcid.org\/0000-0003-3160-6972","authenticated-orcid":false,"given":"Michael D.","family":"Adams","sequence":"additional","affiliation":[{"name":"University of Michigan, USA"}],"role":[{"vocabulary":"crossref","role":"author"}]}],"member":"320","published-online":{"date-parts":[[2020,8,3]]},"reference":[{"key":"e_1_2_2_1_1","doi-asserted-by":"publisher","DOI":"10.1145\/2908080.2908128"},{"key":"e_1_2_2_2_1","doi-asserted-by":"publisher","DOI":"10.1145\/321239.321249"},{"key":"e_1_2_2_3_1","doi-asserted-by":"publisher","DOI":"10.1145\/1863543.1863585"},{"key":"e_1_2_2_4_1","doi-asserted-by":"publisher","DOI":"10.1145\/362007.362035"},{"key":"e_1_2_2_5_1","doi-asserted-by":"publisher","DOI":"10.1145\/3385412.3385992"},{"key":"e_1_2_2_6_1","doi-asserted-by":"publisher","DOI":"10.1017\/S0956796897002864"},{"key":"e_1_2_2_7_1","unstructured":"Jane Street. 2014. core_bench. https:\/\/github.com\/janestreet\/core_bench version 109.58.01.  Jane Street. 2014. core_bench. https:\/\/github.com\/janestreet\/core_bench version 109.58.01."},{"key":"e_1_2_2_8_1","first-page":"3","article-title":"Memoization in top-down parsing","volume":"21","author":"Johnson Mark","year":"1995","unstructured":"Mark Johnson . 1995 . Memoization in top-down parsing . Computational Linguistics 21 , 3 (Sept. 1995 ), 405-417. http:\/\/dl.acm.org\/citation.cfm?id= 216261. 216269 Mark Johnson. 1995. Memoization in top-down parsing. Computational Linguistics 21, 3 (Sept. 1995 ), 405-417. http:\/\/dl.acm.org\/citation.cfm?id= 216261. 216269","journal-title":"Computational Linguistics"},{"key":"e_1_2_2_9_1","unstructured":"Xavier Leroy Damien Doligez Alain Frisch Jacques Garrigue Didier R\u00e9my and J\u00e9r\u00f4me Vouillon. 2020. The OCaml system: release 4.10. https:\/\/ocaml.org\/releases\/4.10\/htmlman\/  Xavier Leroy Damien Doligez Alain Frisch Jacques Garrigue Didier R\u00e9my and J\u00e9r\u00f4me Vouillon. 2020. The OCaml system: release 4.10. https:\/\/ocaml.org\/releases\/4.10\/htmlman\/"},{"key":"e_1_2_2_10_1","unstructured":"Conor McBride. 2001. The Derivative of a Regular Type is its Type of One-Hole Contexts. strictlypositive.org\/diff.pdf  Conor McBride. 2001. The Derivative of a Regular Type is its Type of One-Hole Contexts. strictlypositive.org\/diff.pdf"},{"key":"e_1_2_2_11_1","doi-asserted-by":"publisher","DOI":"10.1145\/1328438.1328474"},{"key":"e_1_2_2_12_1","doi-asserted-by":"publisher","DOI":"10.1145\/2034773.2034801"},{"key":"e_1_2_2_13_1","unstructured":"Emmanuel Onzon. 2012. dypgen: Self-extensible parsers and lexers for OCaml. http:\/\/dypgen.free.fr\/ version 20120619.  Emmanuel Onzon. 2012. dypgen: Self-extensible parsers and lexers for OCaml. http:\/\/dypgen.free.fr\/ version 20120619."},{"key":"e_1_2_2_14_1","doi-asserted-by":"publisher","DOI":"10.1017\/S0956796808007090"},{"key":"e_1_2_2_15_1","unstructured":"Fran\u00e7ois Potier and Yann R\u00e9gis-Gianas. 2019. Menhir. http:\/\/gallium.inria.fr\/~fpottier\/menhir\/ version 20190626.  Fran\u00e7ois Potier and Yann R\u00e9gis-Gianas. 2019. Menhir. http:\/\/gallium.inria.fr\/~fpottier\/menhir\/ version 20190626."},{"key":"e_1_2_2_16_1","unstructured":"Python Software Foundation. 2015a. Python 3.4.3. https:\/\/www.python.org\/downloads\/release\/python-343\/  Python Software Foundation. 2015a. Python 3.4.3. https:\/\/www.python.org\/downloads\/release\/python-343\/"},{"key":"e_1_2_2_17_1","unstructured":"Python Software Foundation. 2015b. The Python Language Reference: Full Grammar specification. https:\/\/docs.python.org\/ 3\/reference\/grammar.html  Python Software Foundation. 2015b. The Python Language Reference: Full Grammar specification. https:\/\/docs.python.org\/ 3\/reference\/grammar.html"},{"key":"e_1_2_2_18_1","doi-asserted-by":"publisher","DOI":"10.1016\/j.entcs.2010.08.041"},{"key":"e_1_2_2_19_1","doi-asserted-by":"publisher","DOI":"10.1016\/j.scico.2012.03.005"}],"container-title":["Proceedings of the ACM on Programming Languages"],"original-title":[],"language":"en","link":[{"URL":"https:\/\/dl.acm.org\/doi\/10.1145\/3408990","content-type":"unspecified","content-version":"vor","intended-application":"text-mining"},{"URL":"https:\/\/dl.acm.org\/doi\/pdf\/10.1145\/3408990","content-type":"unspecified","content-version":"vor","intended-application":"similarity-checking"}],"deposited":{"date-parts":[[2025,6,17]],"date-time":"2025-06-17T20:47:59Z","timestamp":1750193279000},"score":1,"resource":{"primary":{"URL":"https:\/\/dl.acm.org\/doi\/10.1145\/3408990"}},"subtitle":[],"short-title":[],"issued":{"date-parts":[[2020,8,2]]},"references-count":19,"journal-issue":{"issue":"ICFP","published-print":{"date-parts":[[2020,8,2]]}},"alternative-id":["10.1145\/3408990"],"URL":"https:\/\/doi.org\/10.1145\/3408990","relation":{},"ISSN":["2475-1421"],"issn-type":[{"value":"2475-1421","type":"electronic"}],"subject":[],"published":{"date-parts":[[2020,8,2]]},"assertion":[{"value":"2020-08-03","order":2,"name":"published","label":"Published","group":{"name":"publication_history","label":"Publication History"}}]}}