fix syntax hightlight for vcm

This commit is contained in:
MihailRis 2025-07-19 11:47:05 +03:00
parent 73d6d530f2
commit 411f0e53a6
2 changed files with 13 additions and 5 deletions

View File

@ -1,6 +1,6 @@
language = "VCM" language = "VCM"
extensions = ["vcm"] extensions = ["vcm"]
line-comment-start = "#" line-comment = "#"
keywords = [ keywords = [
"on", "off" "on", "off"
] ]

View File

@ -151,6 +151,12 @@ public:
return std::wstring(source.substr(start, pos - start)); return std::wstring(source.substr(start, pos - start));
} }
void emitLineComment(devtools::Location start) {
auto string = readUntilEOL();
emitToken(TokenTag::COMMENT, std::wstring(string), start);
skipLine();
}
std::vector<Token> tokenize() { std::vector<Token> tokenize() {
skipWhitespace(); skipWhitespace();
while (hasNext()) { while (hasNext()) {
@ -229,16 +235,18 @@ public:
} }
if (is_lua_operator_start(c)) { if (is_lua_operator_start(c)) {
auto text = parseOperator(); auto text = parseOperator();
if (text == L"--") { if (text == syntax.lineComment) {
auto string = readUntilEOL(); emitLineComment(start);
emitToken(TokenTag::COMMENT, std::wstring(string), start);
skipLine();
continue; continue;
} }
emitToken(TokenTag::OPERATOR, std::move(text), start); emitToken(TokenTag::OPERATOR, std::move(text), start);
continue; continue;
} }
auto text = readUntilWhitespace(); auto text = readUntilWhitespace();
if (text.find(syntax.lineComment) == 0) {
emitLineComment(start);
continue;
}
emitToken(TokenTag::UNEXPECTED, std::wstring(text), start); emitToken(TokenTag::UNEXPECTED, std::wstring(text), start);
} }
return std::move(tokens); return std::move(tokens);