Add error recovery to javascript if statements
This commit is contained in:
parent
6d84e71ceb
commit
2226234924
4 changed files with 823 additions and 785 deletions
|
|
@ -29,7 +29,7 @@ namespace tree_sitter {
|
|||
{ "if_statement", seq({
|
||||
sym("_if"),
|
||||
str("("),
|
||||
sym("expression"),
|
||||
err(sym("expression")),
|
||||
str(")"),
|
||||
sym("statement"),
|
||||
optional(seq({
|
||||
|
|
@ -37,7 +37,7 @@ namespace tree_sitter {
|
|||
sym("statement") })) }) },
|
||||
{ "statement_block", seq({
|
||||
str("{"),
|
||||
repeat(sym("statement")),
|
||||
err(repeat(sym("statement"))),
|
||||
str("}") }) },
|
||||
{ "assignment", seq({
|
||||
sym("_var"),
|
||||
|
|
@ -95,13 +95,13 @@ namespace tree_sitter {
|
|||
{ "_if", str("if") },
|
||||
{ "_function", str("function") },
|
||||
{ "_else", str("else") },
|
||||
{ "null", str("null") },
|
||||
{ "true", str("true") },
|
||||
{ "false", str("false") },
|
||||
|
||||
{ "string", pattern("\"([^\"]|\\\\\")+\"") },
|
||||
{ "identifier", pattern("[\\w_$]+") },
|
||||
{ "number", pattern("\\d+(.\\d+)?") },
|
||||
{ "null", str("null") },
|
||||
{ "true", str("true") },
|
||||
{ "false", str("false") },
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
14
spec/runtime/languages/javascript/errors.txt
Normal file
14
spec/runtime/languages/javascript/errors.txt
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
==========================================
|
||||
recovers from errors in if statements
|
||||
==========================================
|
||||
stuff();
|
||||
if (*nonsense*) {
|
||||
*more-nonsense*;
|
||||
}
|
||||
moreStuff();
|
||||
---
|
||||
(program
|
||||
(statement (function_call (identifier)))
|
||||
(if_statement (ERROR)
|
||||
(statement_block (ERROR)))
|
||||
(statement (function_call (identifier))))
|
||||
|
|
@ -18,8 +18,7 @@ if (isReady()) {
|
|||
}
|
||||
---
|
||||
(program
|
||||
(if_statement
|
||||
(function_call (identifier))
|
||||
(if_statement (function_call (identifier))
|
||||
(statement_block (statement (function_call (property_access (identifier) (identifier)) (identifier))))))
|
||||
|
||||
==========================================
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue