3 ms·
Ho ly cow I just skimmed the oil source tree, trying to see how you generate the regex based lexers and how you combine them with a parser generator, or a hand
by froh 6y ago
Ho ly cow I just skimmed the oil source tree, trying to see how you generate the regex based lexers and how you combine them with a parser generator, or a hand crafted stack machine? which depending on its current state would presumably switch between the different regex DFAs?
The eggex approach looks very interesting, stand alone, independent from oil. I appreciate they are separate!
- chubot 6y agoI call the technique "lexer modes" but it's trivial: When Are Lexer Modes Useful? http://www.oilshell.org/blog/2017/12/17.html http://www.oilshell.org/blog/2017/12/17.html Overview of the parser: How to Parse Shell Like a Programming Language http://www.oilshell.org/blog/2019/02/07.html http://www.oilshell.org/blog/2019/02/07.html You could look at the architecture like this: reader -> matcher (generated regular languages) -> lexer -> multiple parsers The lexer takes the mode parameter and has extra logic for disambiguation. There are multiple parsers for multiple dialects, and they're both hand-written and generated. Feel free to follow up if this catches your interest. I'm looking for feedback on both Eggex and Oil! more posts: http://www.oilshell.org/blog/tags.html?tag=eggex#eggex http://www.oilshell.org/blog/tags.html?tag=eggex#eggex http://www.oilshell.org/blog/tags.html?tag=parsing-shell#parsing-shell http://www.oilshell.org/blog/tags.html?tag=parsing-shell#par...