Parser.prototype.evaluate = function()

in loader/lib/Parser.js [348:372]


Parser.prototype.evaluate = function(sym, strict) {
  if(debug) { console.log("Parser evaluate", this.describe(sym)); }
  var r = null;
  var t = this.tokens[this.index];
  if(t) {
    if(typeof sym === 'string') {  /* Terminal */
      if( ('{' + t.type + '}' === sym)   ||
            (t.value === sym)            || 
            (typeof t.value === 'string' && 
              (t.value.toUpperCase() === sym.toUpperCase())))         { r = t; }

      if(r !== null) {
        if(debug) { console.log("Parser Advance", t.value); }
        this.index += 1;   // advance to the next token
      }
    }
    else if(sym.isNonTerminal) {
      r = sym.evaluate();
    }
   if(strict === true && r === null) {
      this.fail("Expected " + this.describe(sym));
    }
  }
  return r;
};