Add try and while statements to js grammar

This commit is contained in:
Max Brunsfeld 2014-05-09 21:36:18 -07:00
parent e8760eee34
commit 2d0f90c7d5
2 changed files with 37 additions and 0 deletions

View file

@ -54,6 +54,31 @@ for (var i = 1; someCondition(i); i = next()) {
(assignment (identifier) (function_call (identifier)))
(statement_block (expression_statement (function_call (identifier))))))
==========================================
parses while loops
==========================================
while (someCondition(i)) {
doSomething();
}
---
(program (while_statement
(function_call (identifier) (identifier))
(statement_block (expression_statement (function_call (identifier))))))
==========================================
parses try/catch statements
==========================================
try {
doSomething();
} catch (e) {
logError(e);
}
---
(program (try_statement
(statement_block (expression_statement (function_call (identifier))))
(identifier)
(statement_block (expression_statement (function_call (identifier) (identifier))))))
===========================================
parses switch statements
===========================================