What is actually state-of-the-art in parsing? When I, as an Amateur, last looked into it, PEG[1] and extensions like OMeta[2] seemed to be the best options. I've heard good things about Parsec[3], too. [1]( http://en.wikipedia.org/wiki/Parsing_expression_grammar ) [2]( http://www.tinlizzie.org/ometa/ ) [3]( http://legacy.cs.uu.nl/daan/parsec.html )
Yacc is dead
11–20 of 45 posts
Re: Yacc is dead
#12Why was it rejected by ESOP?
Re: Yacc is dead
#13What is actually state-of-the-art in parsing? When I, as an Amateur, last looked into it, PEG[1] and extensions like OMeta[2] seemed to be the best options. I've heard good things about Parsec[3], too. [1]( http://en.wikipedia.org/wiki/Parsing_expression_grammar ) [2]( http://www.tinlizzie.org/ometa/ ) [3]( http://legacy.cs.uu.nl/daan/parsec.html )
State of the art in parsing is SGLR ( http://strategoxt.org/Sdf/SGLR ) and GLL parsing
I also found the GLL paper at p. 113 [123] of http://ldta.info/2009/ldta2009proceedings.pdf
Re: Yacc is dead
#14 // The Nodes in the parse tree
abstract class Exp
case object One extends Exp
case class Sum(e1 : Exp, e2 : Exp) extends Exp
// Terminals
lazy val S : Parser[Char,Char] = new EqT[Char] ('s')
lazy val X : Parser[Char,Char] = new EqT[Char] ('x')
// Definition of an expression
// I'm pretty sure all the asInstanceOfs are avoidable/unnecessary.
lazy val EXP : Parser[Char,Exp] =
rule(X) ==> { case x => One.asInstanceOf[Exp] } ||
rule(EXP ~ S ~ EXP) ==> { case e1 ~ s ~ e2 => Sum(e1,e2).asInstanceOf[Exp] } ||
rule(EXP ~ S ~ X) ==> { case e1 ~ s ~ e2 => Sum(e1,One).asInstanceOf[Exp] } ||
rule(X ~ S ~ EXP) ==> { case e1 ~ s ~ e2 => Sum(One,e2).asInstanceOf[Exp] } ||
rule(X) ==> { case x => One.asInstanceOf[Exp] } ||
rule(EXP) ==> { case e => e } ||
rule(Epsilon[Char]) ==> { case () => One }
// Actually run the rule
val xin = Stream.fromIterator("xsxsxsxsx".elements)
EXP.parseFull(xin)
// return value => Stream(Sum(One,Sum(Sum(One,One),Sum(One,One))), ?)Re: Yacc is dead
#15Earlier quoted context omitted.
You mean something like this?: http://blog.sigfpe.com/2009/01/fast-incremental-regular-expr... Note that the post has 'prerequisites' at the beginning, which you will need to read, but they are actually pretty cool. Also I am not saying this is exactly what you mean, I'm just suggesting it as a possible connection. This sort of thing is one of the admittedly-rare exceptions where computer science is actually making s…
regular expressions are always the wrong tool for the job of parsing languages with recursive syntax. See, for instance, http://stackoverflow.com/questions/1732348/regex-match-open-...
Re: Yacc is dead
#16What is actually state-of-the-art in parsing? When I, as an Amateur, last looked into it, PEG[1] and extensions like OMeta[2] seemed to be the best options. I've heard good things about Parsec[3], too. [1]( http://en.wikipedia.org/wiki/Parsing_expression_grammar ) [2]( http://www.tinlizzie.org/ometa/ ) [3]( http://legacy.cs.uu.nl/daan/parsec.html )
I think from a user's perspective, e.g. someone wanting to design a DSL, it would be nice to be able to write down arbitrary CFGs and not necessarily have to know lots of technical parsing details ("what are all these shift-reduce conflicts!?"). Maybe PEGs aren't the best choice for this (no left recursion)-- MetaBorg's SGLR is probably state-of-the-art then like Zef said.
Though one of the nice things about PEGs is no ambiguity; MetaBorg will do type-based disambiguation but only after parsing finishes. I'm working on an undergraduate thesis on 'extensible syntax' right now, trying to jump off from some of their stuff (but using a variation on Earley parsing) in particular to see if we could use types to help disambiguate incrementally during parsing.
Re: Yacc is dead
#17What is actually state-of-the-art in parsing? When I, as an Amateur, last looked into it, PEG[1] and extensions like OMeta[2] seemed to be the best options. I've heard good things about Parsec[3], too. [1]( http://en.wikipedia.org/wiki/Parsing_expression_grammar ) [2]( http://www.tinlizzie.org/ometa/ ) [3]( http://legacy.cs.uu.nl/daan/parsec.html )
State of the art in parsing is SGLR ( http://strategoxt.org/Sdf/SGLR ) and GLL parsing
Re: Yacc is dead
#18Fascinating. I don't understand it all yet - I'm reading it carefully but it'll be weeks before I really get it. However ... I'm getting the feeling that this encompasses properly a feeling I've had about parsing for some time, that there should be a way of parsing the entire text, with the parse settling onto the text all at the same time. I don't know if this is what it's saying, but that's the sense I get from it.…
You mean something like this?: http://blog.sigfpe.com/2009/01/fast-incremental-regular-expr... Note that the post has 'prerequisites' at the beginning, which you will need to read, but they are actually pretty cool. Also I am not saying this is exactly what you mean, I'm just suggesting it as a possible connection. This sort of thing is one of the admittedly-rare exceptions where computer science is actually making s…
Suppose you have the ability to take a chunk of text and construct a partial parse state from it. In the case of regexp matching, these partial parse states are functions mapping one state of the regexp matching automaton to another. You need one more thing: the ability to append two of these partial parse states, combining them into one. In the regexp example, this is just function composition. The key here is that this operation must be associative, and there must be an identity element: some partial parse state such that combining it with another state doesn't change anything. And its result must also be a partial parse state. This combination of parse states and an associative binary operation is called a monoid.
Once you have these conditions fulfilled, you can do all sorts of fun stuff. For instance, you can represent a string as a tree of chunks, and cache partial parse states at the nodes in the tree. That way, when you change the string, you can recompute the changed parse states in something like O(lg n) time, rather than going through and re-parsing the entire string. Or you can almost trivially parallelize your parser.
A week ago, I did exactly this: I had a language that needed parsing, and I wanted to incrementally reparse when I changed the (potentially very long) string, so I used a finger tree and wrote an incremental parser. It works beautifully.
Re: Yacc is dead
#19Why was it rejected by ESOP?
and the response to these reviews here: http://phlegmaticprogrammer.wordpress.com/2010/11/21/respons...
Re: Yacc is dead
#20Earlier quoted context omitted.
regular expressions are always the wrong tool for the job of parsing languages with recursive syntax. See, for instance, http://stackoverflow.com/questions/1732348/regex-match-open-...
Did you actually read the linked stuff, or did you just trigger on the keywords "parse" and "regular expression"? I did say it wasn't exactly what was looked for, but it would be interesting to see if someone could extend the results in the linked post from a regular expression to a parse tree. It isn't immediately obvious to me whether you could or could not.
http://comonad.com/reader/2009/iteratees-parsec-and-monoid/
This guy figured out how to turn parsers written with Parsec (an excellent collection of parser combinators; truly a pleasure to use) into monoidal parsers that you can use for incremental and/or parallel parsing.