author | Alan Dipert
<alan@dipert.org> 2019-10-31 03:58:31 UTC |
committer | Alan Dipert
<alan@dipert.org> 2019-10-31 03:58:31 UTC |
parent | 75d348a14d2a428833f03e787afc248ecd34e96a |
jacl.js | +17 | -4 |
diff --git a/jacl.js b/jacl.js index e73c87c..96d1d27 100644 --- a/jacl.js +++ b/jacl.js @@ -904,7 +904,7 @@ const parseLambdaList = list => { case 'optional': if (eqClSym(x, '&OPTIONAL')) { throw new Error(`Repeated &OPTIONAL`); - } else if (eqClSym(x, '&KEY') + } else if (eqClSym(x, '&KEY') || eqClSym(x, '&REST') || eqClSym(x, '&AUX')) { state = x.name.substring(1).toLowerCase(); @@ -916,7 +916,7 @@ const parseLambdaList = list => { }); } else if (Cons.isProperList(x)) { const len = Cons.length(x); - if (len === 0 || len > 3) + if (len === 0 || len > 3) throw new Error(`&OPTIONAL parameter list wrong size`); sections.optional.push({ name: checkValidLocal(x.car), @@ -949,6 +949,7 @@ const parseLambdaList = list => { } break; case 'key': + // TODO (keyword var) e.g. ((:foo foo)) if (eqClSym(x, '&KEY')) { throw new Error(`Repeated &KEY`); } else if (eqClSym(x, '&OPTIONAL') || eqClSym(x, '&REST')) { @@ -963,7 +964,7 @@ const parseLambdaList = list => { }); } else if (Cons.isProperList(x)) { const len = Cons.length(x); - if (len === 0 || len > 3) + if (len === 0 || len > 3) throw new Error(`&KEY parameter list wrong size`); sections.key.push({ name: checkValidLocal(x.car), @@ -986,7 +987,7 @@ const parseLambdaList = list => { } else if (Cons.isProperList(x)) { if (Cons.length(x) !== 2) throw new Error(`&AUX parameter list wrong size`); - sections.key.push({ + sections.aux.push({ name: checkValidLocal(x.car), initform: x.cdr.car }); @@ -999,6 +1000,18 @@ const parseLambdaList = list => { return sections; }; + +const analyzeLambdaList = (env, parent, sections) => { + // https://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node64.html + // Whenever any initform is evaluated for any parameter specifier, that form + // may refer to any parameter variable to the left of the specifier in which + // the initform appears, including any supplied-p variables, and may rely on + // the fact that no other parameter variable has yet been bound (including + // its own parameter variable). + // TODO Thread env through names/initforms and return a new `sections` with + // every initform replaced with its analysis +}; + const stringy = x => x instanceof String || typeof x === 'string' || x instanceof LispString; const isTag = x => x instanceof LispSymbol || typeof x === 'number'