lib/lexer.js
function() {
    var captures, re;

    // we have established the indentation regexp
    if (this.indentRe){
      captures = this.indentRe.exec(this.str);
    // figure out if we are using tabs or spaces
    } else {
      // try tabs
      re = /^\n([\t]*)[ \t]*/;
      captures = re.exec(this.str);

      // nope, try spaces
      if (captures && !captures[1].length) {
        re = /^\n([ \t]*)/;
        captures = re.exec(this.str);
      }

      // established
      if (captures && captures[1].length) this.indentRe = re;
    }


    if (captures) {
      var tok
        , indents = captures[1].length;

      this.skip(captures);
      if (this.str[0] === ' ' || this.str[0] === '\t') {
        throw new errors.SyntaxError('Invalid indentation. You can use tabs or spaces to indent, but not both.');
      }

      // Blank line
      if ('\n' == this.str[0]) return this.advance();

      // Outdent
      if (this.indentStack.length && indents < this.indentStack[0]) {
        while (this.indentStack.length && this.indentStack[0] > indents) {
          this.stash.push(new Token('outdent'));
          this.indentStack.shift();
        }
        tok = this.stash.pop();
      // Indent
      } else if (indents && indents != this.indentStack[0]) {
        this.indentStack.unshift(indents);
        tok = new Token('indent');
      // Newline
      } else {
        tok = new Token('newline');
      }

      return tok;
    }
  }
function() {
    var captures, re;

    // we have established the indentation regexp
    if (this.indentRe){
      captures = this.indentRe.exec(this.str);
    // figure out if we are using tabs or spaces
    } else {
      // try tabs
      re = /^\n([\t]*)[ \t]*/;
      captures = re.exec(this.str);

      // nope, try spaces
      if (captures && !captures[1].length) {
        re = /^\n([ \t]*)/;
        captures = re.exec(this.str);
      }

      // established
      if (captures && captures[1].length) this.indentRe = re;
    }


    if (captures) {
      var tok
        , indents = captures[1].length;

      this.skip(captures);
      if (this.str[0] === ' ' || this.str[0] === '\t') {
        throw new errors.SyntaxError('Invalid indentation. You can use tabs or spaces to indent, but not both.');
      }

      // Blank line
      if ('\n' == this.str[0]) return this.advance();

      // Outdent
      if (this.indentStack.length && indents < this.indentStack[0]) {
        while (this.indentStack.length && this.indentStack[0] > indents) {
          this.stash.push(new Token('outdent'));
          this.indentStack.shift();
        }
        tok = this.stash.pop();
      // Indent
      } else if (indents && indents != this.indentStack[0]) {
        this.indentStack.unshift(indents);
        tok = new Token('indent');
      // Newline
      } else {
        tok = new Token('newline');
      }

      return tok;
    }
  }
function ( ) { var captures , re ; // we have established the indentation regexp if ( this . indentRe ) { captures = this . indentRe . exec ( this . str ) ; // figure out if we are using tabs or spaces } else { // try tabs re = / ^\n([\t]*)[ \t]* / ; captures = re . exec ( this . str ) ; // nope, try spaces if ( captures && ! captures [ 1 ] . length ) { re = / ^\n([ \t]*) / ; captures = re . exec ( this . str ) ; } // established if ( captures && captures [ 1 ] . length ) this . indentRe = re ; } if ( captures ) { var tok , indents = captures [ 1 ] . length ; this . skip ( captures ) ; if ( this . str [ 0 ] === ' ' || this . str [ 0 ] === '\t' ) { throw new errors . SyntaxError ( 'Invalid indentation. You can use tabs or spaces to indent, but not both.' ) ; } // Blank line if ( '\n' == this . str [ 0 ] ) return this . advance ( ) ; // Outdent if ( this . indentStack . length && indents < this . indentStack [ 0 ] ) { while ( this . indentStack . length && this . indentStack [ 0 ] > indents ) { this . stash . push ( new Token ( 'outdent' ) ) ; this . indentStack . shift ( ) ; } tok = this . stash . pop ( ) ; // Indent } else if ( indents && indents != this . indentStack [ 0 ] ) { this . indentStack . unshift ( indents ) ; tok = new Token ( 'indent' ) ; // Newline } else { tok = new Token ( 'newline' ) ; } return tok ; } }
'\n' ' '+
\ n +