4 ms·
Skipping to "Glush, the algorithm" can be helpful if you already know the history of parsing. TL;DR: Glush grammars consist of "rules" that are regexes + recur
by sshine 7y ago
Skipping to "Glush, the algorithm" can be helpful if you already know the history of parsing.
TL;DR: Glush grammars consist of "rules" that are regexes + recursion of rule calls. Compiles to NFAs.
I'm not sure I see the point in declaring precedence levels inside rules -- maybe it's just a preference thing, but I like having operator precedences in a separate section of the grammar. Yacc does this. Megaparsec for Haskell does this.
This reminds me of two things:
1. How syntax highlighting is implemented in Vim and GEdit (which is to say GtkSourceView). See for example how "contexts" can be nested here: https://github.com/rubencaro/gedit_hacks/blob/master/.local/share/gtksourceview-3.0/language-specs/ruby.lang#L469 https://github.com/rubencaro/gedit_hacks/blob/master/.local/...
2. Kleenex: https://kleenexlang.org https://kleenexlang.org - https://github.com/diku-kmc/kleenexlang https://github.com/diku-kmc/kleenexlang - a silly example: https://github.com/athas/EggsML/blob/master/concieggs/compiled/makeDanish.kex https://github.com/athas/EggsML/blob/master/concieggs/compil...
I am tempted to classify this as "regex extended with recursion" rather than "an alternative to CFGs", since I cannot decipher from the article the exact expressive power.
- tom_mellior 7y ago> Compiles to NFAs. No. It cannot, since NFAs cannot parse languages that are not regular. Rather, the algorithm executes like a pushdown automaton. I don't think it's correct to call this compilation. > I cannot decipher from the article the exact expressive power. To me it seems to suggest being able to parse (exactly) all context-free languages.