Azul @typeswitch·Mar 26What's your favorite approach to lexical analysis (i.e. turning a stream of bytes/characters into a stream of tokens)?14315
wen@wenkokke·Mar 26I was raised in the @UniUtrecht school of parser combinators, which, among other things, means "No lexer, only parse."26
Azul @typeswitch·Mar 26I used to skip lexing too. In my experience, parsing with tokens is a lot nicer than parsing with characters, so I tend not to skip it anymore.25
Azul @typeswitch·Mar 26That said, parser combinators make it easy to do both in a single step, and it's not hard to keep the "token rules" separate from the "parser rules" conceptually. So it's good :)33
Brendan Zabarauskas@brendanzabReplying to @typeswitch @wenkokke and @UniUtrechtIIRC some parser combinator libs let you parse custom streams too? So you can feed a token string->token parser to a token->ast parser?9:14 PM · Mar 26, 2022·Twitter Web App1 Like
wen@wenkokke·Mar 26Replying to @brendanzab @typeswitch and @UniUtrechtTotally! Might be @UniUtrecht speaking through me, but I thought that was the standard way of implementing lexers when you're already using parser combinators!1