internal ConstantListItem(Object term, ConstantListItem prev){ this.prev = prev; this.term = term; }
private object PPScanExpr() { object obj2; OpListItem prev = new OpListItem(JSToken.None, OpPrec.precNone, null); ConstantListItem item2 = new ConstantListItem(this.PPScanConstant(), null); while (true) { this.GetNextToken(); if (!IsPPOperator(this.currentToken.token)) { goto Label_00E4; } OpPrec pPOperatorPrecedence = GetPPOperatorPrecedence(this.currentToken.token); while (pPOperatorPrecedence < prev._prec) { obj2 = this.PPGetValue(prev._operator, item2.prev.term, item2.term); prev = prev._prev; item2 = item2.prev.prev; item2 = new ConstantListItem(obj2, item2); } prev = new OpListItem(this.currentToken.token, pPOperatorPrecedence, prev); item2 = new ConstantListItem(this.PPScanConstant(), item2); } Label_00AB: obj2 = this.PPGetValue(prev._operator, item2.prev.term, item2.term); prev = prev._prev; item2 = item2.prev.prev; item2 = new ConstantListItem(obj2, item2); Label_00E4: if (prev._operator != JSToken.None) { goto Label_00AB; } this.currentPos = this.currentToken.startPos; return item2.term; }
private Object PPScanExpr(){ OpListItem opsStack = new OpListItem(JSToken.None, OpPrec.precNone, null); // dummy element ConstantListItem termStack = new ConstantListItem(PPScanConstant(), null); Object value; for (;;){ GetNextToken(); if (JSScanner.IsPPOperator(this.currentToken.token)){ OpPrec prec = JSScanner.GetPPOperatorPrecedence(this.currentToken.token); while (prec < opsStack._prec){ //Console.Out.WriteLine("lower prec or same and left assoc"); value = PPGetValue(opsStack._operator, termStack.prev.term, termStack.term); // pop the operator stack opsStack = opsStack._prev; // pop the term stack twice termStack = termStack.prev.prev; // push node onto the stack termStack = new ConstantListItem(value, termStack); } // the current operator has higher precedence that every scanned operators on the stack, or // it has the same precedence as the one at the top of the stack and it is right associative // push the operator onto the operators stack opsStack = new OpListItem(this.currentToken.token, prec, opsStack); // push new term termStack = new ConstantListItem(PPScanConstant(), termStack); }else{ //Console.Out.WriteLine("unwinding stack"); // there are still operators to be processed while (opsStack._operator != JSToken.None){ // make the ast operator node value = PPGetValue(opsStack._operator, termStack.prev.term, termStack.term); // pop the operator stack opsStack = opsStack._prev; // pop the term stack twice termStack = termStack.prev.prev; // push node onto the stack termStack = new ConstantListItem(value, termStack); } // reset position into stream this.currentPos = this.currentToken.startPos; break; // done } } Debug.Assert(termStack.prev == null); return termStack.term; }
internal ConstantListItem(object term, ConstantListItem prev) { this.prev = prev; this.term = term; }