Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

9. Top Down Operator Precedence > 9.6. Infix Operators

Infix Operators

The + operator is an infix operator, so it will have a led method that makes the token object into a tree, where the two branches are the operand to the left of the + and the operand to the right. The left operand is passed into the led, and the right is obtained by calling the expression method.

The number 60 is the binding power of +. Operators that bind tighter or have higher precedence have greater binding powers. In the course of mutating the stream of tokens into a parse tree, we will use the operator tokens as containers of operand nodes:

	symbol("+", 60).led = function (left) {
	    this.first = left;
	    this.second = expression(60);
	    this.arity = "binary";
	    return this;
	};

  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint