git » jacl.git » commit 3d28e6d

WIP &REST parsing

author Alan Dipert
2019-10-26 18:55:52 UTC
committer Alan Dipert
2019-10-26 18:55:52 UTC
parent fd5ea55ae96af046f61fc7bfd0bf66bc0d683ca9

WIP &REST parsing

jacl.js +5 -1

diff --git a/jacl.js b/jacl.js
index 28d5e9f..b9aaed6 100644
--- a/jacl.js
+++ b/jacl.js
@@ -848,6 +848,7 @@ const analyzeBlock = (env, parent, forms) => {
 };
 
 const parseLambdaList = list => {
+  const isKw = x => (x instanceof LispSymbol) && x.name[0] === '&';
   let arr = Cons.toArray(list),
     section = 'required',
     sections = {
@@ -855,7 +856,8 @@ const parseLambdaList = list => {
       optional: [],
       keyword: [],
       rest: null
-    };
+    },
+    expectingKw = false;
   scan: for (let i = 0; i < arr.length; i++) {
     const x = list[i];
     if (x instanceof LispSymbol) {
@@ -865,6 +867,8 @@ const parseLambdaList = list => {
           section = x.name.substring(1).toLowerCase();
           continue scan;
         case '&REST':
+          if (section.rest !== null) throw new Error(`Multiple &REST`);
+          if (i == arr.length-1) throw new Error(`Nothing after &REST`);
           if (arr.length-i !== 2)
             throw new Error(`One argument name must follow &REST`);
           sections.rest = arr[i+1];