function parse_terminal(tokenList) {
    if (tokenList.current === "(") {
        tokenList.advance();
        const expr = parse_binary0(tokenList);
        if (tokenList.current != ")") {
            throw new Error(
                `Expected a matching ")" after "${tokenList.previous}".`
            );
        }
        tokenList.advance();
        return expr;
    }

    if (!Number.isNaN(Number(tokenList.current))) {
        return [Number(tokenList.advance())];
    }

    if (tokenList.current === undefined) {
        throw new Error(
            `Expected token after "${tokenList.previous}", got none.`
        );
    } else {
        throw new Error(
            `Unexpected token "${tokenList.current}" after "${tokenList.previous}".`
        );
    }
}
/**
 * Parses a numeric value or sub-expression (enclosed in parentheses)
 *
 * @throws {Error} If an unexpected token is encountered, or if there are no further tokens.
 */
Parses a numeric value or sub-expression (enclosed in parentheses)
@throws {Error} If an unexpected token is encountered, or if there are no further tokens.
Parses a numeric value or sub - expression ( enclosed in parentheses ) @throws { Error } If an unexpected token is encountered or if there are no further tokens .
function parse_terminal(tokenList) {
    if (tokenList.current === "(") {
        tokenList.advance();
        const expr = parse_binary0(tokenList);
        if (tokenList.current != ")") {
            throw new Error(
                `Expected a matching ")" after "${tokenList.previous}".`
            );
        }
        tokenList.advance();
        return expr;
    }
    if (!Number.isNaN(Number(tokenList.current))) {
        return [Number(tokenList.advance())];
    }
    if (tokenList.current === undefined) {
        throw new Error(
            `Expected token after "${tokenList.previous}", got none.`
        );
    } else {
        throw new Error(
            `Unexpected token "${tokenList.current}" after "${tokenList.previous}".`
        );
    }
}
function parse_terminal ( tokenList ) { if ( tokenList . current === "(" ) { tokenList . advance ( ) ; const expr = parse_binary0 ( tokenList ) ; if ( tokenList . current != ")" ) { throw new Error ( ` ${ tokenList . previous } ` ) ; } tokenList . advance ( ) ; return expr ; } if ( ! Number . isNaN ( Number ( tokenList . current ) ) ) { return [ Number ( tokenList . advance ( ) ) ] ; } if ( tokenList . current === undefined ) { throw new Error ( ` ${ tokenList . previous } ` ) ; } else { throw new Error ( ` ${ tokenList . current } ${ tokenList . previous } ` ) ; } }
Parses a numeric value or sub-expression (enclosed in parentheses)
 @throws {Error} If an unexpected token is encountered, or if there are no further tokens.
Parses a numeric value or sub - expression ( enclosed in parentheses ) @throws { Error } If an unexpected token is encountered or if there are no further tokens .