|
![](/i/fill.gif) |
>> Given that I'm the only person here who knows how to read Haskell
>> syntax, a link to the Parsec user manual seemed... a little pointless.
>
> Oh. I *highly* suggest you put this up on your blog or your web site or
> something like that, for public consumption. Get comments from a lot of
> people, find jobs in Haskell and/or teaching because you can write like
> this, etc.
Heh. I could add it to my blog. Nobody on earth will ever actually read
it, but sure, I can add it. ;-)
>> Heh. What do *I* know about parser theory? ;-)
>
> I don't know. It seemed like a fair amount. :-) This is all stuff you
> learn in the first semester of compiler construction class.
Now there's a class that sounds interesting... Pity my "Computer
Science" degree didn't involve anything remotely like that. ;-)
> Yes. I'm just saying it "works best" because LALR(1) parses without ever
> needing to use P_Try(). I.e., you don't need anything like exceptions
> or input buffers to parse an LALR(1) grammar using the programming
> language's stack - you need enough memory to hold one token, and you can
> output results as soon as any production is recognised, and you only
> need stack space proportional to the most nested expression in your
> input, and you don't need any memory to outlast the parsing of the
> productions you're currently parsing.
>
> Of course, once you add arbitrary function calls and arbitrary buffering
> (via P_Try and SuperCombiner) then you can parse lots more; it just
> takes more code and more memory and potentially global data structures.
Fair enough. ;-)
Figuring out when to use P_Try() is actually quite subtle by the way -
especially where you have a language where variable names can't be
resurved words. Parsec actually provides a small module to automatically
build parsers for common types of expression and language grammars based
on the options you supply (automates things like reversed word
recognition, operator precidence, operator associativity, etc.)
--
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*
Post a reply to this message
|
![](/i/fill.gif) |