
How to succeed at parsing without really trying - luu
http://jamesporter.me/2013/11/27/how-to-succeed-at-parsing.html
======
codelion
Also, recursive descent parsing can be used to generate extensible parsers
using frameworks like Campl4.
[http://www.reddit.com/r/ocaml/comments/1gx71p/building_exten...](http://www.reddit.com/r/ocaml/comments/1gx71p/building_extensible_parsers_with_camlp4/)

------
barrkel
The syntax shown is completely trivial, it should be parseable with about a
dozen lines without using any generators, frameworks, libraries, string
replacements, or anything else.

Unless I missed something.

~~~
jmmcd
You didn't miss anything. The point (or "the only point") is that he was able
to reuse the language's own parser rather than writing any parsing code of his
own. For anyone who hasn't seen that technique, it's worth seeing. Whether
it's a win depends on taste maybe.

------
draegtun
For reference, a parser for Newick string/format comes with the Bio::Phylo
Perl CPAN module - [https://metacpan.org/release/Bio-
Phylo](https://metacpan.org/release/Bio-Phylo)

------
lucian1900
I've done this before with Python, making AST literals directly out of tokens.
It's potentially dangerous however, similar to eval-ing input. It can be done
safely with care.

~~~
icebraining
You can use ast.literal_eval[1] which is supposedly safe (only accepts literal
values, not code).

[1]
[http://docs.python.org/2/library/ast.html#ast.literal_eval](http://docs.python.org/2/library/ast.html#ast.literal_eval)

