我正在爲python編寫一個編譯器腳本。我有這樣的錯誤格式運用於是正確分析回溯:爲什麼在這個vim errorformat中需要額外的轉義?
CompilerSet errorformat=
\%A\ \ File\ \"%f\"\\,\ line\ %l%.%#,
\%Z\ \ \ \ %m
我不明白爲什麼我需要額外的逃生逗號前:爲什麼不能\"%f\"\\,
是\"%f\"\,
?我知道逗號需要被轉義,因爲它用於分隔錯誤格式的部分,但爲什麼使用兩個反斜槓?
這裏有一個回溯其中單逃逸不起作用的例子,但雙作用:
Traceback (most recent call last):
File "test.py", line 9, in <module>
g()
File "test.py", line 7, in g
f()
File "test.py", line 4, in f
raise IndexError()
IndexError
另一個類似的例子是this python compiler script使用三個反斜槓!
(我希望問理解爲什麼會更容易編寫更多efm
設置。)