Mirinth / Plexiglass

A lexer generator, in the spirit of GNU Flex.
Other
0 stars 0 forks source link

Should tokens "produce" PLEXIGLASS_EOF when they don't produce anything? #144

Closed Mirinth closed 2 years ago

Mirinth commented 2 years ago

__eof__ is more likely to mask errors since hitting the end of the file is a normal occurrence. Ending early might result in the rest of the file being silently ignored and potentially lexing and parsing "successfully".

__jam__ is intended to only occur when the lexer can't actually process the file, and should usually only occur when there's a hole in the lexer, which is already a problem. __jam__ getting produced is usually a sign of an error, so this would be more appropriate.

That said, I think having a new one specifically for no production might be more appropriate. Rules wouldn't need a special Produces flag if there were a token specifically for that. But then there would be a null token, with all the fun that comes with null. Users might get nuisance warnings about not handling the error token.

I think I'll go with the __nothing__ token for now. If it turns out to be more trouble than it's worth, I can always take it out again later.