Skip to content

SmaCC: Returning part of a token value in the scanner #4129

Closed Answered by j-brant
joelreymont asked this question in Q&A
Discussion options

You must be logged in to vote

You can't using the standard code. You could create a hex_int method in the scanner that created the token without the 0x, but I would recommend having the tokens have the whole value. If I just needed the value without the 0x, then I'd probably create a method on the node that stripped the first two characters. Another approach would be to define two tokens: one for the 0x and another for the AA. The problem with that approach is that if you have a whitespace or comment tokens that are ignored, then you can have a comment or whitespace between the 0x and AA.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by joelreymont
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants