I am writing a program and python and want to use the match-case statement allowed in python 3.10 to be able to switch on 'enum' values i.e:
match token.type:
case TOK_INT: #0
# do stuff
case TOK_STRING: #1
# do stuff
etc...
however trying to do this causes python to throw a SyntaxError: name capture 'TOK_INT' makes remaining patterns unreachable
error. I know I can fix it by manually typing the number associated with each 'enum' variable but I am wondering if there is a better way of going about this?