I have a problem with ambiguity on tokens level.
The problem looks like this. My code looks like this so token t_UN1 has higher precedence.
t_ignore = ' \t\v\r' # whitespace
....
def t_UN1(t): #NS_
r'NS\_'
return t
def t_IDENTIFIER(t):
r'[a-zA-Z][a-zA-Z0-9_]*'
return t
....
I would like to achieve that eg. string: NS_XYZ is identified as "IDENTIFIER" and single NS_ surrounded by white spaces is identified as "UN_1".
How shall I handle that ? Currently string NS_XYZ is simply splited into two tokens UN1 and IDENTIFIER