samples/JavaScript/ccalc-lex.js
// consumes and returns one char from the input
consumes and returns one char from the input
consumes and returns one char from the input
function lexer_input() {
        if (!this._input) {
            this.done = true;
            return null;
        }
        var ch = this._input[0];
        this.yytext += ch;
        this.yyleng++;
        this.offset++;
        this.match += ch;
        this.matched += ch;
        var slice_len = 1;
        var lines = false;
        if (ch === '\n') {
            lines = true;
        } else if (ch === '\r') {
            lines = true;
            var ch2 = this._input[1];
            if (ch2 === '\n') {
                slice_len++;
                ch += ch2;
                this.yytext += ch2;
                this.yyleng++;
                this.offset++;
                this.match += ch2;
                this.matched += ch2;
                if (this.options.ranges) {
                    this.yylloc.range[1]++;
                }
            }
        }
        if (lines) {
            this.yylineno++;
            this.yylloc.last_line++;
        } else {
            this.yylloc.last_column++;
        }
        if (this.options.ranges) {
            this.yylloc.range[1]++;
        }
        this._input = this._input.slice(slice_len);
        return ch;
    }
function lexer_input ( ) { if ( ! this . _input ) { this . done = true ; return null ; } var ch = this . _input [ 0 ] ; this . yytext += ch ; this . yyleng ++ ; this . offset ++ ; this . match += ch ; this . matched += ch ; var slice_len = 1 ; var lines = false ; if ( ch === '\n' ) { lines = true ; } else if ( ch === '\r' ) { lines = true ; var ch2 = this . _input [ 1 ] ; if ( ch2 === '\n' ) { slice_len ++ ; ch += ch2 ; this . yytext += ch2 ; this . yyleng ++ ; this . offset ++ ; this . match += ch2 ; this . matched += ch2 ; if ( this . options . ranges ) { this . yylloc . range [ 1 ] ++ ; } } } if ( lines ) { this . yylineno ++ ; this . yylloc . last_line ++ ; } else { this . yylloc . last_column ++ ; } if ( this . options . ranges ) { this . yylloc . range [ 1 ] ++ ; } this . _input = this . _input . slice ( slice_len ) ; return ch ; }
consumes and returns one char from the input
consumes and returns one char from the input
// Count the linenumber up when we hit the LF (or a stand-alone CR). // On CRLF, the linenumber is incremented when you fetch the CR or the CRLF combo // and we advance immediately past the LF as well, returning both together as if // it was all a single 'character' only.