ฉันกำลังทำงานกับการเน้นไวยากรณ์สำหรับภาษาการเขียนโปรแกรมที่ไม่รองรับโดย Visual Studio Code การไฮไลต์ทำงานได้ดี แต่ฉันประสบปัญหาในการเน้นโค้ดต่อไปนี้:
pool[] Test1 t1;
pool[1] Test2 t2;
pool[10] Test3 t3;
ฉันกำลังเน้นคำว่า "พูล" โดยใช้:
"storages": {
"patterns": [{
"name": "storage.type.ceu",
"match": "\\bpool\\b"
}]
},
และมันก็ใช้งานได้ แต่ฉันต้องการเน้นคำว่า Test1, Test2 และ Test3 ด้วยเช่นกัน
ความคิดเดียวของฉันคือการใช้การมองด้านหลังในแง่ลบ เช่นนี้:
(?<=pool\[\d*\]\s+)([A-Z])\w+
ฉันสร้างลิงก์ออนไลน์ด้วยแนวคิดนี้: https://regexr.com/4793u
แต่ oniguruma (regex ที่ใช้โดย TextMate - และ Ruby) ไม่อนุญาตให้ใช้ lookaround จาก doc:
(?=subexp) look-ahead
(?!subexp) negative look-ahead
(?<=subexp) look-behind
(?<!subexp) negative look-behind
Subexp of look-behind must be fixed-width.
But top-level alternatives can be of various lengths.
ex. (?<=a|bc) is OK. (?<=aaa(?:b|cd)) is not allowed.
In negative look-behind, capturing group isn't allowed,
but non-capturing group (?:) is allowed.
ไม่มีใครรู้ทางเลือกอื่นเพื่อเน้นไวยากรณ์นี้หรือไม่