![](/img/trans.png)
[英]How to match any terminal string with a regex in the Python Lark Parser and the meaning of /.+/>?
[英]How can I parse a string with unicode characters in lark-parser in python
我正在嘗試在 Python 中使用 Lark 解析器來解析一些 sql 字符串。 一些語句中包含 unicode 字符,導致解析器拋出錯誤(帶有 ó,é 的字符串)。 我使用以下幾行在我的 .lark 文件中定義字符串
LATIN_LETTER: /[u"\u00a1-\u02af"]/
STRING: (LATIN_LETTER|LETTER|DIGIT|PUNCTUATION)+
拋出錯誤
E UnexpectedCharacters: No terminal defined for '�' at line 154 col 126
E
E jillo', 'Owner', 'Avda. de la Constitución 2222', 'México D.F.', NULL, '05021'
我是否在 .lark 文件中錯誤地指定了 unicode 字母? 這樣做的正確方法是什么?
改變
LATIN_LETTER: /[u"\u00a1-\u02af"]/
至
LATIN_LETTER: ("¡".."ʯ")
工作過
CHINESE_LETTER: ("\u4e00".."\u9fff") | ("\u3000".."\u303f")
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.