2 ms·
I rarely use DCGs because they suffer from completeness syndrome, i.e. you either define full DCG or you crash on first error. For such tasks I prefer quasi-qu
by xlii 2y ago
I rarely use DCGs because they suffer from completeness syndrome, i.e. you either define full DCG or you crash on first error.
For such tasks I prefer quasi-quotation [0] or a simple format with goal expansion [1]. As for readers I rarely need ones, because XML, YAML, JSON are already included.
In order to do code analysis I first pulled pieces using Regex (mostly headers) and only then parsed them over with DCG. Which is also neat when creating own DSLs - one can ask people on meeting to decorate lightly notes and get - semantic linking almost for free.
[0]: https://www.swi-prolog.org/pldoc/man?section=quasiquotations https://www.swi-prolog.org/pldoc/man?section=quasiquotations
[1]: https://www.swi-prolog.org/pldoc/man?section=format-predicates https://www.swi-prolog.org/pldoc/man?section=format-predicat...
- i_don_t_know 2y agoThanks! I didn't know about quasiquotation.