[Ur] Combinator Parsing in Ur: Anonymous function remains at code generation

orchidaceae phalaenopsis orchid.hybrid at gmail.com
Wed Jul 23 18:19:46 EDT 2014


It is unintuitive that Ur/Web doesn't currently accept code when it
cannot optimize out all anonymous functions. I hope that there will be
some way to fully support higher order functions in future, would you
be able to comment on this please? It would also be nice if it was
pointed out more loudly that this is the case in manuals and such.

Of course if you can do first-order programming you can implement an
interpreter for a higher order language, so I got the idea of
embedding a language that lets one write parsers into Ur/Web:

I have prototyped an interpreter for Prolog-DCG-style language* that
allows one to do parsing in Ur. Here is the source code
https://github.com/enn/urweb-dcg and an example that matches brackets.

(* N.B. it commits to the first success/leftmost parse the same way as
PEG, prolog DCGs are slightly more nondeterministic)

This is carefully implemented to be
* Pure functional
* Not use monads
* Not use higher order functions

I aim to use this to parse BBCode for a discussion forum and Markup
for a wiki we are implementing in Ur/Web. I will extend it a bit and
add a tool to automatically generate the code from Prolog syntax
(because it's horrible to type it out manually). I hope it's
interesting! It is alpha but I welcome any any feedback, bugs and
contributions!



More information about the Ur mailing list