[Ur] Parsing xml fragments.

Adam Chlipala adamc at csail.mit.edu
Thu Oct 18 11:30:39 EDT 2012


On 10/16/2012 07:27 AM, Alexei Golovko wrote:
> Can someone suggest some parser generator, suitable for pure strict 
> lambda calculus?
> For example, does it make sense to try PEG like in 
> http://www.impredicative.com/pipermail/ur/2011-February/000520.html ?

I don't think any parser generators have been written for Ur yet.  
Personally, I would just write a direct recursive descent parser for XML 
(and that is what I did in the Feed library).

If you run into performance problems with a direct recursive descent 
parser, then probably it's a fundamental limitation with 
optimization/code generation to JavaScript in the Ur/Web compiler.

> 12.10.2012, 17:12, "Alexei Golovko" <m-lj at yandex.ru 
> <mailto:m-lj at yandex.ru>>:
>>  I parse them to list of elements:
>> datatype myXml =
>>     Text of string
>>     | Open of string * list { N : string, V : string } * option string
>>     | Close of string
>>     | Other
>>
>> I've attached related modules, but the main problem is that I don't 
>> want to write full XML parser (dealing with entities, for example). 
>> Current code does not cover all cases (it is dirty and seems to have 
>> a silly bugs even with escaping; I have used it for two test files 
>> only for work with UI part). Probably, it is better do not invest 
>> time to optimization...
>> 12.10.2012, 16:53, "Adam Chlipala" <adamc at csail.mit.edu 
>> <mailto:adamc at csail.mit.edu>>:
>>>
>>> OK, then I'd expect to parse fragments into a simple tree datatype.
>>>
>>> Maybe if you point us to an example of your parsing code, I can give 
>>> some advice on making it faster.  (Linear-time/space parsing of 
>>> strings in pure Ur code should be pretty easy, if you use the right 
>>> standard library functions.)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.impredicative.com/pipermail/ur/attachments/20121018/9b1c09c6/attachment.html>


More information about the Ur mailing list