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 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
You can't using the standard code. You could create a |
Beta Was this translation helpful? Give feedback.
You can't using the standard code. You could create a
hex_int
method 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 the0x
and another for theAA
. The problem with that approach is that if you have awhitespace
orcomment
tokens that are ignored, then you can have a comment or whitespace between the0x
andAA
.