Guest User

Untitled

a guest
Sep 19th, 2024
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.25 KB | None | 0 0
  1. (*
  2. Parzek Parser Combinator Literate Program Source
  3. By Chubak Bidpaa
  4. *)
  5.  
  6.  
  7. (*p
  8. % Preamble
  9. \DocumentMetadata{}
  10. \documentclass[a4paper]{article}
  11. \usepackage{ocamlweb}
  12. \usepackage{amsmath,amsthm,amssymb}
  13. \usepackage{filecontents}
  14. \usepackage{imakeidx}
  15. \usepackage{epigraph}
  16. \usepackage[backend=biber]{biblatex}
  17. *)
  18.  
  19. (*
  20. % Settings and preliminary commands
  21.  
  22. \makeindex
  23. \addbibresource{references.bib}
  24. *)
  25.  
  26. (*
  27. % Macros and commands
  28. *)
  29.  
  30. (*
  31. % Begin document
  32.  
  33. \begin{document}
  34.  
  35. *)
  36.  
  37. (*
  38. % Introduction
  39. The program before you is \parzek, a \index{Parser combinator@\textit{Parser combinator}} library for the \ocaml\ language. This is not a textbook, nor is it a tutorial or an academic paper, this is merely a \index{Literate program@\textit{Literate program}}.
  40.  
  41.  
  42. There exist many different implementations of the basic \parsec: some use basic functions, whereas some use \index{Monadic formulation}\parencite{swiestra2001combinator}. In this \index{Literate program}, we present \parzek, a \parsez\ written in \ocaml; which is based more on the former, rather than the latter, as discussed in \parencite{fokker1995functional} --- and several other literature, which shall be discussed later.
  43. *)
  44.  
  45. (*
  46. % Parsec intro
  47.  
  48. \section{A brief, painless look at \parsec{}s}
  49. \label{sec:a_painless_look}
  50.  
  51. \epigraph{A parser may be viewed as a function from a string of symbols to a result value.}{Graham Hutton}
  52.  
  53. P
  54.  
  55.  
  56. *)
  57.  
  58.  
  59.  
  60. (*
  61. % References
  62.  
  63. \begin{filecontents}{references.bib}
  64. @article{grune2008introduction,
  65. title={Introduction to Parsing},
  66. author={Grune, Dick and Jacobs, Ceriel JH and Grune, Dick and Jacobs, Ceriel JH},
  67. journal={Parsing Techniques: A Practical Guide},
  68. pages={61--102},
  69. year={2008},
  70. publisher={Springer}
  71. }
  72. @inproceedings{king1960functions,
  73. title={Functions required of a translation system},
  74. author={King, Gilbert},
  75. booktitle={Proceedings of the National Symposium on Machine Translation},
  76. year={1960}
  77. }
  78. @article{chomsky1959certain,
  79. title={On certain formal properties of grammars},
  80. author={Chomsky, Noam},
  81. journal={Information and control},
  82. volume={2},
  83. number={2},
  84. pages={137--167},
  85. year={1959},
  86. publisher={Elsevier}
  87. }
  88. @inproceedings{wadler1985replace,
  89. title={How to replace failure by a list of successes a method for exception handling, backtracking, and pattern matching in lazy functional languages},
  90. author={Wadler, Philip},
  91. booktitle={Conference on Functional Programming Languages and Computer Architecture},
  92. pages={113--128},
  93. year={1985},
  94. organization={Springer}
  95. }
  96. @inproceedings{hutton1990parsing,
  97. title={Parsing using combinators},
  98. author={Hutton, Graham},
  99. booktitle={Functional Programming: Proceedings of the 1989 Glasgow Workshop 21--23 August 1989, Fraserburgh, Scotland},
  100. pages={353--370},
  101. year={1990},
  102. organization={Springer}
  103. }
  104. @misc{hutton1996monadic,
  105. title={Monadic parser combinators},
  106. author={Hutton, Graham and Meijer, Erik},
  107. year={1996}
  108. }
  109. @inproceedings{izmaylova2016practical,
  110. title={Practical, general parser combinators},
  111. author={Izmaylova, Anastasia and Afroozeh, Ali and Storm, Tijs van der},
  112. booktitle={Proceedings of the 2016 ACM SIGPLAN Workshop on Partial Evaluation and Program manipulation},
  113. pages={1--12},
  114. year={2016}
  115. }
  116. @incollection{swierstra2008combinator,
  117. title={Combinator parsing: A short tutorial},
  118. author={Swierstra, S Doaitse},
  119. booktitle={International LerNet ALFA Summer School on Language Engineering and Rigorous Software Development},
  120. pages={252--300},
  121. year={2008},
  122. publisher={Springer}
  123. }
  124. @inproceedings{koopman1998efficient,
  125. title={Efficient combinator parsers},
  126. author={Koopman, Pieter and Plasmeijer, Rinus},
  127. booktitle={Symposium on Implementation and Application of Functional Languages},
  128. pages={120--136},
  129. year={1998},
  130. organization={Springer}
  131. }
  132. @article{leijen2001parsec,
  133. title={Parsec, a fast combinator parser},
  134. author={Leijen, Daan},
  135. year={2001}
  136. }
  137. @inproceedings{kurvs2016optimizing,
  138. title={Optimizing parser combinators},
  139. author={Kur{\v{s}}, Jan and Vran{\`y}, Jan and Ghafari, Mohammad and Lungu, Mircea and Nierstrasz, Oscar},
  140. booktitle={Proceedings of the 11th edition of the International Workshop on Smalltalk Technologies},
  141. pages={1--13},
  142. year={2016}
  143. }
  144. @article{leijen2001parsec,
  145. title={Parsec: Direct style monadic parser combinators for the real world},
  146. author={Leijen, Daan and Meijer, Erik},
  147. year={2001}
  148. }
  149. @inproceedings{koopman2019new,
  150. title={A new view on parser combinators},
  151. author={Koopman, Pieter and Plasmeijer, Rinus},
  152. booktitle={Proceedings of the 31st Symposium on Implementation and Application of Functional Languages},
  153. pages={1--11},
  154. year={2019}
  155. }
  156. @article{jonnalagedda2014staged,
  157. title={Staged parser combinators for efficient data processing},
  158. author={Jonnalagedda, Manohar and Coppey, Thierry and Stucki, Sandro and Rompf, Tiark and Odersky, Martin},
  159. journal={Acm Sigplan Notices},
  160. volume={49},
  161. number={10},
  162. pages={637--653},
  163. year={2014},
  164. publisher={ACM New York, NY, USA}
  165. }
  166. @article{kurvs2018efficient,
  167. title={Efficient parsing with parser combinators},
  168. author={Kur{\v{s}}, Jan and Vran{\`y}, Jan and Ghafari, Mohammad and Lungu, Mircea and Nierstrasz, Oscar},
  169. journal={Science of computer programming},
  170. volume={161},
  171. pages={57--88},
  172. year={2018},
  173. publisher={Elsevier}
  174. }
  175. @article{willis2020staged,
  176. title={Staged selective parser combinators},
  177. author={Willis, Jamie and Wu, Nicolas and Pickering, Matthew},
  178. journal={Proceedings of the ACM on Programming Languages},
  179. volume={4},
  180. number={ICFP},
  181. pages={1--30},
  182. year={2020},
  183. publisher={ACM New York, NY, USA}
  184. }
  185. @article{hill1996combinators,
  186. title={Combinators for parsing expressions},
  187. author={Hill, Steve},
  188. journal={Journal of Functional Programming},
  189. volume={6},
  190. number={3},
  191. pages={445--464},
  192. year={1996},
  193. publisher={Cambridge University Press}
  194. }
  195. @incollection{swierstra1996deterministic,
  196. title={Deterministic, error-correcting combinator parsers},
  197. author={Swierstra, S Doaitse and Duponcheel, Luc},
  198. booktitle={International School on Advanced Functional Programming},
  199. pages={184--207},
  200. year={1996},
  201. publisher={Springer}
  202. }
  203. @inproceedings{beguet2014accelerating,
  204. title={Accelerating parser combinators with macros},
  205. author={B{\'e}guet, Eric and Jonnalagedda, Manohar},
  206. booktitle={Proceedings of the Fifth Annual Scala Workshop},
  207. pages={7--17},
  208. year={2014}
  209. }
  210. @incollection{swierstra1996deterministic,
  211. title={Deterministic, error-correcting combinator parsers},
  212. author={Swierstra, S Doaitse and Duponcheel, Luc},
  213. booktitle={International School on Advanced Functional Programming},
  214. pages={184--207},
  215. year={1996},
  216. publisher={Springer}
  217. }
  218. @inproceedings{van2018gll,
  219. title={GLL parsing with flexible combinators},
  220. author={van Binsbergen, L Thomas and Scott, Elizabeth and Johnstone, Adrian},
  221. booktitle={Proceedings of the 11th ACM SIGPLAN International Conference on Software Language Engineering},
  222. pages={16--28},
  223. year={2018}
  224. }
  225. @article{leijen2001parsec,
  226. title={Parsec: A practical parser library},
  227. author={Leijen, Daan and Meijer, Erik},
  228. journal={Electronic Notes in Theoretical Computer Science},
  229. volume={41},
  230. number={1},
  231. pages={1--20},
  232. year={2001}
  233. }
  234. @inproceedings{mazanek2008graph,
  235. title={Graph parser combinators},
  236. author={Mazanek, Steffen and Minas, Mark},
  237. booktitle={Implementation and Application of Functional Languages: 19th International Workshop, IFL 2007, Freiburg, Germany, September 27-29, 2007. Revised Selected Papers 19},
  238. pages={1--18},
  239. year={2008},
  240. organization={Springer}
  241. }
  242. @article{swierstra2001combinator,
  243. title={Combinator parsers: From toys to tools},
  244. author={Swierstra, S Doaitse},
  245. journal={Electronic Notes in Theoretical Computer Science},
  246. volume={41},
  247. number={1},
  248. pages={38--59},
  249. year={2001},
  250. publisher={Elsevier}
  251. }
  252. @inproceedings{fokker1995functional,
  253. title={Functional parsers},
  254. author={Fokker, Jeroen},
  255. booktitle={Advanced Functional Programming: First International Spring School on Advanced Functional Programming Techniques B{\aa}stad, Sweden, May 24--30, 1995 Tutorial Text 1},
  256. pages={1--23},
  257. year={1995},
  258. organization={Springer}
  259. }
  260. @techreport{jones1993composing,
  261. title={Composing monads},
  262. author={Jones, Mark P and Duponcheel, Luc},
  263. year={1993},
  264. institution={Technical Report YALEU/DCS/RR-1004, Department of Computer Science. Yale~…}
  265. }
  266. @inproceedings{willis2018garnishing,
  267. title={Garnishing parsec with parsley},
  268. author={Willis, Jamie and Wu, Nicolas},
  269. booktitle={Proceedings of the 9th ACM SIGPLAN International Symposium on Scala},
  270. pages={24--34},
  271. year={2018}
  272. }
  273. @inproceedings{hudak1984combinator,
  274. title={A combinator-based compiler for a functional language},
  275. author={Hudak, Paul and Kranz, David},
  276. booktitle={Proceedings of the 11th ACM SIGACT-SIGPLAN symposium on Principles of programming languages},
  277. pages={122--132},
  278. year={1984}
  279. }
  280. @inproceedings{wand1983loops,
  281. title={Loops in combinator-based compilers},
  282. author={Wand, Mitchell},
  283. booktitle={Proceedings of the 10th ACM SIGACT-SIGPLAN symposium on Principles of programming languages},
  284. pages={190--196},
  285. year={1983}
  286. }
  287.  
  288. \end{filecontents}
  289.  
  290. *)
  291.  
Add Comment
Please, Sign In to add comment