Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我尝试解析十六进制数: hex_number : "0x" HEXDIGIT+ 并使用 0xA 作为输入,它总是给我一个错误,A 是意外标记。
这是一个不会给您带来任何错误的小示例:
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 ")