more useful parse errors

This commit is contained in:
2026-02-10 06:08:15 -06:00
parent cef5c50169
commit 3f7e34cd7a
2 changed files with 30 additions and 0 deletions

View File

@@ -1196,6 +1196,36 @@ var parse = function(tokens, src, filename, tokenizer) {
}
if (k == "name") {
if (tok.value == "try" || tok.value == "catch" || tok.value == "finally") {
parse_error(start, "'" + tok.value + "' is not supported; use disrupt/disruption instead")
sync_to_statement()
return null
}
if (tok.value == "throw") {
parse_error(start, "'throw' is not supported; use disrupt instead")
sync_to_statement()
return null
}
if (tok.value == "class") {
parse_error(start, "'class' is not supported; use meme()/proto() instead")
sync_to_statement()
return null
}
if (tok.value == "new") {
parse_error(start, "'new' is not supported; use meme()/proto() instead")
sync_to_statement()
return null
}
if (tok.value == "switch" || tok.value == "case") {
parse_error(start, "'" + tok.value + "' is not supported; use if/else instead")
sync_to_statement()
return null
}
if (tok.value == "let" || tok.value == "const") {
parse_error(start, "'" + tok.value + "' is not supported; use var/def instead")
sync_to_statement()
return null
}
p1_tok = peek_ahead(1)
if (p1_tok.kind == ":") {
node = ast_node("label", start)

Binary file not shown.