4 ms·
Using DCGs (https://en.wikipedia.org/wiki/Definite_clause_grammar https://en.wikipedia.org/wiki/Definite_clause_grammar), you can easily create grammars for aut
by justusw 10y ago
Using DCGs (https://en.wikipedia.org/wiki/Definite_clause_grammar https://en.wikipedia.org/wiki/Definite_clause_grammar), you can easily create grammars for automated document parsing and generation.
You could even write a compiler (http://comjnl.oxfordjournals.org/content/34/1/64.full.pdf http://comjnl.oxfordjournals.org/content/34/1/64.full.pdf) or disassembler (http://www.dtic.mil/dtic/tr/fulltext/u2/a242987.pdf http://www.dtic.mil/dtic/tr/fulltext/u2/a242987.pdf) in Prolog fairly easy. All thanks to the really smooth support of tree-like structures.
I do wonder why all this seems to be a little forgotten. Granted, the syntax and semantics are a bit unusual, but the expressive power can hardly be matched.
- agumonkey 10y agoThanks for these links. Another DCG tutorial http://www.pathwayslms.com/swipltuts/dcg/index.html http://www.pathwayslms.com/swipltuts/dcg/index.html
- dbcurtis 10y agoYour link lightly addresses one of my questions about using DCGs for parsing. How hard is it to get a sensible error message out of a DCG parser? I've basically written off LALR parsers because getting a reasonable error message out of them is about as much fun as repeatedly poking yourself in the eye with a sharp stick. Good old recursive decent using precedence climbing for expressions seems to be more maintainable in the long run for production parsers.