samples/JavaScript/ccalc-lex.js
// INTERNAL USE: construct a suitable error info hash object instance for `parseError`.
INTERNAL USE: construct a suitable error info hash object instance for `parseError`.
INTERNAL USE : construct a suitable error info hash object instance for ` parseError ` .
function lexer_constructLexErrorInfo(msg, recoverable) {
        var pei = {
            errStr: msg,
            recoverable: !!recoverable,
            text: this.match,           
            token: null,
            line: this.yylineno,
            loc: this.yylloc,
            yy: this.yy,
            lexer: this,
             Note that only array and object references are nuked as those
             constitute the set of elements which can produce a cyclic ref.
             The rest of the members is kept intact as they are harmless.
            destroy: function destructLexErrorInfo() {
                 remove cyclic references added to error info:
                 info.yy = null;
                 info.lexer = null;
                 ...
                var rec = !!this.recoverable;
                for (var key in this) {
                    if (this.hasOwnProperty(key) && typeof key === 'object') {
                        this[key] = undefined;
                    }
                }
                this.recoverable = rec;
            }
        };
         track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection!
        this.__error_infos.push(pei);
        return pei;
    }
function lexer_constructLexErrorInfo ( msg , recoverable ) { var pei = { errStr : msg , recoverable : ! ! recoverable , text : this . match , token : null , line : this . yylineno , loc : this . yylloc , yy : this . yy , lexer : this , destroy : function destructLexErrorInfo ( ) { var rec = ! ! this . recoverable ; for ( var key in this ) { if ( this . hasOwnProperty ( key ) && typeof key === 'object' ) { this [ key ] = undefined ; } } this . recoverable = rec ; } } ; this . __error_infos . push ( pei ) ; return pei ; }
INTERNAL USE: construct a suitable error info hash object instance for `parseError`.
INTERNAL USE : construct a suitable error info hash object instance for ` parseError ` .
// This one MAY be empty; userland code should use the `upcomingInput` API to obtain more text which follows the 'lexer cursor position'... // and make sure the error info doesn't stay due to potential // ref cycle via userland code manipulations. // These would otherwise all be memory leak opportunities! // // Note that only array and object references are nuked as those // constitute the set of elements which can produce a cyclic ref. // The rest of the members is kept intact as they are harmless. // remove cyclic references added to error info: // info.yy = null; // info.lexer = null; // ... // track this instance so we can `destroy()` it once we deem it superfluous and ready for garbage collection!