Add while statements

edge_only_predecessors
Max Brunsfeld 2014-10-28 08:10:28 +07:00
parent 9e566ff055
commit 11ce0da541
2 changed files with 22 additions and 0 deletions

@ -72,6 +72,7 @@ module.exports = grammar
@return_statement,
@if_statement,
@for_statement,
@while_statement,
@expression_statement,
@statement_block),
@ -99,6 +100,11 @@ module.exports = grammar
")",
@statement)
while_statement: -> seq(
keyword("while"),
"(", @expression, ")",
@statement)
type: -> seq(
optional(keyword("const")),
choice(

@ -77,3 +77,19 @@ int main() {
(function_call (identifier))
(function_call (identifier))
(expression_statement (identifier)))))
============================================
While loops
============================================
int main() {
while (x)
printf("hi");
}
---
(function_declaration (identifier) (identifier) (formal_parameters)
(statement_block
(while_statement (identifier)
(expression_statement (function_call (identifier) (string))))))