Instaparse可以向REPL pprint好的错误消息
=> (negative-lookahead-example "abaaaab")
Parse error at line 1, column 1:
abaaaab
^
Expected:
NOT "ab"
但是我找不到内置函数来将消息作为字符串获取。怎么做?
您始终可以使用with-out-str
以下命令包装它:
(with-out-str
(negative-lookahead-example "abaaaab"))
您可能也有兴趣使用with-err-str
此处记录的内容。
(with-err-str
(negative-lookahead-example "abaaaab"))
我不记得是instaparse
写到stdout还是stderr,但是其中之一可以满足您的要求。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句