From 9d9325f8f91e7567b23c97e523805993354a86ca Mon Sep 17 00:00:00 2001 From: Martin Jambon Date: Sat, 16 Oct 2021 01:44:38 -0700 Subject: [PATCH] Add support for 'until' loops --- corpus/statements.txt | 20 ++++++++++++++++++++ grammar.js | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/corpus/statements.txt b/corpus/statements.txt index 8ed98aa..d80f49b 100644 --- a/corpus/statements.txt +++ b/corpus/statements.txt @@ -53,6 +53,26 @@ done --- +(program + (while_statement + condition: (command + name: (command_name (word)) + argument: (word)) + body: (do_group + (command name: (command_name (word)) argument: (word)) + (command name: (command_name (word)) argument: (word))))) + +==================================== +Until statements +==================================== + +until something happens; do + echo a + echo b +done + +--- + (program (while_statement condition: (command diff --git a/grammar.js b/grammar.js index 92036a0..a2e2f87 100644 --- a/grammar.js +++ b/grammar.js @@ -141,7 +141,7 @@ module.exports = grammar({ ), while_statement: $ => seq( - 'while', + choice('while', 'until'), field('condition', $._terminated_statement), field('body', $.do_group) ),