The XL programming language ( http://xlr.sf.net ) has a rather unique approach to parsing. There is a short article about it here: http://grenouille-bouillie.blogspot.fr/2010/06/xl-axioms-rec... . XL features 8 simple node types, 4 leafs (integer, real, text, name/symbol) and 4 inner nodes (infix, prefix, postfix and block). With that, you can use a rather standard looking syntax, yet have an inner parse tree structu…
Judging from the article, if you parsed "if 3", you'd get back out (prefix if 3) instead of an error, since `if` is just a regular prefix operator. So, presumably there's some sort of well-formedness checking that goes on after parsing? Does anyone know more? The website says very little.
Parsing: The Solved Problem That Isn't (2011)
51–60 of 71 posts
Re: Parsing: The Solved Problem That Isn't (2011)
#52Earlier quoted context omitted.
Judging from the article, if you parsed "if 3", you'd get back out (prefix if 3) instead of an error, since `if` is just a regular prefix operator. So, presumably there's some sort of well-formedness checking that goes on after parsing? Does anyone know more? The website says very little.
Yeah that puzzles me a bit too. Multifix operators are not more complicated than prefix/postfix/infix (well, only marginally). For instance, you can give each operator a left priority and a right priority and merge them when they meet with the same priority. Then `if x then y else z` would become (if/then/else x y z) or something like that. I think that's saner and easier to handle than what he does.
Re: Parsing: The Solved Problem That Isn't (2011)
#53It is nice to see someone summarizing this kind of information. However, really this is a continuation of the academic attitude toward parsers making them MUCH harder than they have to be. If you want to study grammars in an abstract sense, then think of them this way, and that's fine. If you want to build a parser for a programming language, don't use any of this stuff. Just write code to parse the language in a str…
Re: Parsing: The Solved Problem That Isn't (2011)
#54Earlier quoted context omitted.
The more generic term for a lot of the stuff he talks about in that post falls under projectional editors and programming language workbenches. JetBrains MPS is one of the tools among many that help with building such editors. Here's a good talk by Markus Völter on using tools like JetBrains MPS.
I think you forgot to put in the link :)
Re: Parsing: The Solved Problem That Isn't (2011)
#55Earlier quoted context omitted.
I was and also when scanning/lexing. My limited PEG parsing experience is with peg/leg by http://piumarta.com/software/peg/ and http://pegjs.majda.cz which is a Javascript PEG parser. Both very cool projects.
Looks like they do not include the optimisations I mentioned. But for this sort of use cases that would have been an overkill anyway.
Re: Parsing: The Solved Problem That Isn't (2011)
#56It is nice to see someone summarizing this kind of information. However, really this is a continuation of the academic attitude toward parsers making them MUCH harder than they have to be. If you want to study grammars in an abstract sense, then think of them this way, and that's fine. If you want to build a parser for a programming language, don't use any of this stuff. Just write code to parse the language in a str…
This approach is why many consider parsing to be a solved problem, so it's certainly a valid approach. However, it's not the only valid approach.
For example, "straightforward" parsers often give terrible error messages: when the intended branch (eg. if/then/else) fails, the parser will backtrack and try a more general alternative (eg. a function call). Not only does this give an incorrect error (eg. "no such function 'esle'"), but it might actually succeed! In which case, the parser will be in the wrong state to parse the following text, and gives a non-sensical message (eg. "unexpected '('" several lines later).
This is an important problem, since these messages can only be decyphered by those who know enough about the syntax to avoid hitting them very often! Inexperienced users will see error messages over and over again, and have no idea that they're being asked to fix non-existent errors in incorrect positions.
Re: Parsing: The Solved Problem That Isn't (2011)
#57It is nice to see someone summarizing this kind of information. However, really this is a continuation of the academic attitude toward parsers making them MUCH harder than they have to be. If you want to study grammars in an abstract sense, then think of them this way, and that's fine. If you want to build a parser for a programming language, don't use any of this stuff. Just write code to parse the language in a str…
That's horrible advice. Some problems are really complex and can't be solved just by working from A to B. Your parser will probably not end up being able to handle the problems outlined in the article unless you take that theory into account before starting to program.
Re: Parsing: The Solved Problem That Isn't (2011)
#58Earlier quoted context omitted.
Looks like they do not include the optimisations I mentioned. But for this sort of use cases that would have been an overkill anyway.
So do you have an example of a PEG parser that uses these so called memorisation optimisation techniques then?
Re: Parsing: The Solved Problem That Isn't (2011)
#59Re: Parsing: The Solved Problem That Isn't (2011)
#60Jeffrey Kegler's work on Marpa is pretty exciting, but hasn't got much traction (maybe due to the implementation languages: Perl and Knuth's Literate Programming). https://metacpan.org/pod/Marpa::R2#A-simple-calculator