Skip to content

Can't figure out why Lexer doesn't match a defined token and throws error "unexpected character..." #1910

Answered by msujew
lichrot asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @yohgen,

The lexer errors are expected, since - and = characters cannot be lexed with the given tokens. Even if you assign your token a category, you still need to explicitly add the token type to the lexer. They can later be used in the parser using the correct category (for example: CONSUME(AddOp)), but the lexer doesn't care about categories at all.

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@lichrot
Comment options

Answer selected by lichrot
Comment options

You must be logged in to vote
1 reply
@lichrot
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants