I try to parse hex number with: hex_number : "0x" HEXDIGIT+ and with 0xA as input, and it always throws me an error, A is unexpected token.
Asked
Active
Viewed 292 times
1 Answers
1
Here's a little example that won't throw you any error:
from lark import Lark
if __name__ == "__main__":
grammar = """
start: hex_number
hex_number : "0x" HEXDIGIT+
%import common.HEXDIGIT
%import common.WS
%ignore WS
"""
parser = Lark(grammar, start='start')
tree = parser.parse(" 0xA ")

BPL
- 9,632
- 9
- 59
- 117