Lines Matching full:operator
73 The "operator overloading" that we will add to Kaleidoscope is more general than
83 operator precedence parsing for the expressions. See <a
84 href="OCamlLangImpl2.html">Chapter 2</a> for details. Without using operator
184 of whether it was an operator, and if it was, what precedence level the operator
187 the prototype for a user-defined operator, we need to parse it:</p>
216 'Token.Kwd op ?? "expected an operator";
225 (* Verify right number of arguments for operator. *)
227 then raise (Stream.Error "invalid number of operands for operator")
241 names like "binary@" for a newly defined "@" operator. This then takes
247 case for our existing binary operator node:</p>
266 (* If it wasn't a builtin binary operator, it must be a user defined
272 | None -> raise (Error "binary operator not found!")
280 a lookup for the appropriate operator in the symbol table and generates a
294 <b>(* If this is an operator, install it. *)
309 <p>Basically, before codegening a function, if it is a user-defined operator, we
310 register it in the precedence table. This allows the binary operator parsing
312 fully-general operator precedence parser, this is all we need to do to "extend
337 (* variant for a unary operator. *)
344 binary operator AST node, except that it only has one child. With this, we
345 need to add the parsing logic. Parsing a unary operator is pretty simple: we'll
354 (* If this is a unary operator, read it. *)
358 (* If the current token is not an operator, it must be a primary expr. *)
364 operator when parsing a primary operator, we eat the operator as a prefix and
365 parse the remaining piece as another unary operator. This allows us to handle
380 <b>(* Parse the unary expression after the binary operator. *)
395 the unary operator prototype. We extend the binary operator code above
425 'Token.Kwd op ?? "expected an operator";
434 (* Verify right number of arguments for operator. *)
436 then raise (Stream.Error "invalid number of operands for operator")
448 the operator character. This assists us at code generation time. Speaking of,
462 | None -> raise (Error "unknown unary operator")
483 things. For example, we can now add a nice sequencing operator (printd is
490 ready> <b>def binary : 1 (x y) 0; # Low-precedence operator that ignores operands.</b>
937 (* variant for a unary operator. *)
940 (* variant for a binary operator. *)
971 (* binop_precedence - This holds the precedence for each binary operator that is
975 (* precedence - Get the precedence of the pending binary operator token. *)
1055 (* If this is a unary operator, read it. *)
1059 (* If the current token is not an operator, it must be a primary expr. *)
1076 (* Parse the unary expression after the binary operator. *)
1083 (* If BinOp binds less tightly with rhs than the operator after
1084 * rhs, let the pending operator take rhs as its lhs. *)
1128 'Token.Kwd op ?? "expected an operator";
1137 (* Verify right number of arguments for operator. *)
1139 then raise (Stream.Error "invalid number of operands for operator")
1193 | None -> raise (Error "unknown unary operator")
1209 (* If it wasn't a builtin binary operator, it must be a user defined
1215 | None -> raise (Error "binary operator not found!")
1391 (* If this is an operator, install it. *)