提示词:

对标 LinuxCNC,分阶段完善 Web 版数控系统仿真的 WASM 程序,继续补齐 G 代码语法并严格测试。

总结:
- 对齐 LinuxCNC 对同一行重复非 G/M 字的拒绝行为,覆盖 G1 X1 X2 等重复轴字错误。
- 将 smoke parser 字母字归一为大写,补充 lowercase 普通字和命名 O-word 回归覆盖。
- 已通过 ./test-native.sh 和 ./test-linuxcnc-source-link.sh。
This commit is contained in:
wangdequan
2026-05-23 17:50:37 +08:00
parent 3333ddb373
commit 575bcf24d8
2 changed files with 77 additions and 1 deletions

View File

@@ -354,13 +354,14 @@ bool looks_like_real_start(char ch) {
bool parse_word_list_impl(const std::string &line, std::vector<Word> *words, std::string *error, bool strict) {
words->clear();
std::array<bool, 26> seen_letters{};
const char *text = line.c_str();
for (size_t i = 0; text[i] != '\0';) {
if (std::isspace(static_cast<unsigned char>(text[i]))) {
++i;
continue;
}
char letter = text[i];
char letter = static_cast<char>(std::toupper(static_cast<unsigned char>(text[i])));
if (!std::isalpha(static_cast<unsigned char>(letter))) {
++i;
continue;
@@ -391,6 +392,16 @@ bool parse_word_list_impl(const std::string &line, std::vector<Word> *words, std
}
return false;
}
if (letter != 'G' && letter != 'M') {
const size_t letter_index = static_cast<size_t>(letter - 'A');
if (strict && seen_letters[letter_index]) {
if (error) {
*error = "multiple " + std::string(1, letter) + " words on one line";
}
return false;
}
seen_letters[letter_index] = true;
}
words->push_back({letter, value});
i = next;
}