samples/JavaScript/ccalc-lex.js
// unshifts one char (or a string) into the input
unshifts one char (or a string) into the input
unshifts one char ( or a string ) into the input
function lexer_unput(ch) {
        var len = ch.length;
        var lines = ch.split(/(?:\r\n?|\n)/g);
        this._input = ch + this._input;
        this.yytext = this.yytext.substr(0, this.yytext.length - len);
        this.offset -= len;
        var oldLines = this.match.split(/(?:\r\n?|\n)/g);
        this.match = this.match.substr(0, this.match.length - len);
        this.matched = this.matched.substr(0, this.matched.length - len);
        if (lines.length - 1) {
            this.yylineno -= lines.length - 1;
        }
        this.yylloc.last_line = this.yylineno + 1;
        this.yylloc.last_column = (lines ?
                (lines.length === oldLines.length ? this.yylloc.first_column : 0)
                + oldLines[oldLines.length - lines.length].length - lines[0].length :
                this.yylloc.first_column - len);
        if (this.options.ranges) {
            this.yylloc.range[1] = this.yylloc.range[0] + this.yyleng - len;
        }
        this.yyleng = this.yytext.length;
        this.done = false;
        return this;
    }
function lexer_unput ( ch ) { var len = ch . length ; var lines = ch . split ( / (?:\r\n?|\n) / g ) ; this . _input = ch + this . _input ; this . yytext = this . yytext . substr ( 0 , this . yytext . length - len ) ; this . offset -= len ; var oldLines = this . match . split ( / (?:\r\n?|\n) / g ) ; this . match = this . match . substr ( 0 , this . match . length - len ) ; this . matched = this . matched . substr ( 0 , this . matched . length - len ) ; if ( lines . length - 1 ) { this . yylineno -= lines . length - 1 ; } this . yylloc . last_line = this . yylineno + 1 ; this . yylloc . last_column = ( lines ? ( lines . length === oldLines . length ? this . yylloc . first_column : 0 ) + oldLines [ oldLines . length - lines . length ] . length - lines [ 0 ] . length : this . yylloc . first_column - len ) ; if ( this . options . ranges ) { this . yylloc . range [ 1 ] = this . yylloc . range [ 0 ] + this . yyleng - len ; } this . yyleng = this . yytext . length ; this . done = false ; return this ; }
unshifts one char (or a string) into the input
unshifts one char ( or a string ) into the input
//this.yyleng -= len;