From 0a7e051ab577ac9242b32e7873c2fe96fc7375cb Mon Sep 17 00:00:00 2001 From: Tangent Wantwight Date: Thu, 3 Aug 2023 23:15:14 -0400 Subject: [PATCH] Match entire script from a top level grammar symbol --- notcl.js | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/notcl.js b/notcl.js index 726b71c..c1f2308 100644 --- a/notcl.js +++ b/notcl.js @@ -47,10 +47,16 @@ var Notcl = (() => { Choose(/** @type {Peg.Pattern} */ (Regex(/[\n;]/y)), End) ); + /** @type {Peg.Pattern} */ const Command = Sequence(PreCommand, AtLeast(0, Word), CommandTerminator).map( ([_padding, words, _end]) => words ); + /** @type {Peg.Pattern} */ + const Script = Sequence(AtLeast(0, Command), End).map( + ([commands, _eof]) => commands + ); + return { /** * Parse out a Notcl script into an easier-to-interpret representation. @@ -64,19 +70,10 @@ var Notcl = (() => { // fold line endings code = code.replace(/(?