lib/parser.js
function() {
    var parens = 1
      , i = 2
      , tok;

    // Lookahead and determine if we are dealing
    // with a function call or definition. Here
    // we pair parens to prevent false negatives
    out:
    while (tok = this.lookahead(i++)) {
      switch (tok.type) {
        case 'function':
        case '(':
          ++parens;
          break;
        case ')':
          if (!--parens) break out;
          break;
        case 'eos':
          this.error('failed to find closing paren ")"');
      }
    }

    // Definition or call
    switch (this.currentState()) {
      case 'expression':
        return this.functionCall();
      default:
        return this.looksLikeFunctionDefinition(i)
          ? this.functionDefinition()
          : this.expression();
    }
  }
function() {
    var parens = 1
      , i = 2
      , tok;

    // Lookahead and determine if we are dealing
    // with a function call or definition. Here
    // we pair parens to prevent false negatives
    out:
    while (tok = this.lookahead(i++)) {
      switch (tok.type) {
        case 'function':
        case '(':
          ++parens;
          break;
        case ')':
          if (!--parens) break out;
          break;
        case 'eos':
          this.error('failed to find closing paren ")"');
      }
    }

    // Definition or call
    switch (this.currentState()) {
      case 'expression':
        return this.functionCall();
      default:
        return this.looksLikeFunctionDefinition(i)
          ? this.functionDefinition()
          : this.expression();
    }
  }
function ( ) { var parens = 1 , i = 2 , tok ; // Lookahead and determine if we are dealing // with a function call or definition. Here // we pair parens to prevent false negatives out : while ( tok = this . lookahead ( i ++ ) ) { switch ( tok . type ) { case 'function' : case '(' : ++ parens ; break ; case ')' : if ( ! -- parens ) break out ; break ; case 'eos' : this . error ( 'failed to find closing paren ")"' ) ; } } // Definition or call switch ( this . currentState ( ) ) { case 'expression' : return this . functionCall ( ) ; default : return this . looksLikeFunctionDefinition ( i ) ? this . functionDefinition ( ) : this . expression ( ) ; } }
definition
| call
definition | call