On Saturday, 3 July 2021 at 09:28:32 UTC, user1234 wrote:
On Saturday, 3 July 2021 at 09:05:28 UTC, vnr wrote:
Hello,
I am trying to make a small generic lexer that bases its token
analysis on regular expressions. The principle I have in mind
is to define a token type table with its corresponding regular
expression, here is the code I currently have:
[...]
storing the regex in a token is an antipattern.
Thank you for the answer,
I know it's not clean, I'll modify my code to define a token type
table with their regular expression and define a token type table
with what has match; the former defining the lexer, the latter
being the result of the latter.
But for now and to keep it simple, I did everything in one.