diff --git a/build-aux/bootstrap/prebirth.js b/build-aux/bootstrap/prebirth.js index 25d5492..8e9cbe2 100644 --- a/build-aux/bootstrap/prebirth.js +++ b/build-aux/bootstrap/prebirth.js @@ -319,7 +319,18 @@ class Compiler */ _cdfn( t ) { - this.assertApply( t, 'define' ); + // an application must be an s-expression + if ( !Array.isArray( t ) ) { + throw Error( + `\`${name}' application expected, found symbol \`${t.value}'` + ); + } + + // if it's not a definition, then it's a top-level application + if ( t[ 0 ].value !== 'define' ) + { + return this._sexpToEs( t ) + ';'; + } // e.g. (define (foo ...) body) const [ , [ { value: name }, ...params ], ...body ] = t; @@ -441,34 +452,6 @@ class Compiler // final function application return `${idfn}(${argstr})`; } - - - /** - * Determine whether T is an application of a symbol NAME, or error - * - * @param {*} t hopefully a token or token list - * @param {string} name function name to assert against - */ - assertApply( t, name ) - { - // an application must be an s-expression - if ( !Array.isArray( t ) ) { - throw Error( - `\`${name}' application expected, found symbol \`${t.value}'` - ); - } - - // if there's a match, we can stop here - if ( t[ 0 ].value === name ) { - return; - } - - // otherwise, provide an informative error of what we found and what - // we should have found - throw Error( - `\`${name}' expected, found \`${t[ 0 ].value}'` - ); - } }