Repository navigation
SmaCC: Returning part of a token value in the scanner #4129
|
I have a hex number rule that looks like this My token value will then become How can I make my token value become everything BUT the |
Answered by
j-brant
Oct 24, 2024
Replies: 1 comment
|
You can't using the standard code. You could create a |
0 replies
Answer selected by
joelreymont
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can't using the standard code. You could create a
hex_intmethod in the scanner that created the token without the0x, but I would recommend having the tokens have the whole value. If I just needed the value without the0x, 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 the0xand another for theAA. The problem with that approach is that if you have awhitespaceorcommenttokens that are ignored, then you can have a comment or whitespace between the0xandAA.