Lines Matching refs:unary

49 The two specific features we'll add are programmable unary operators
50 (right now, Kaleidoscope has no unary operators at all) as well as
55 # Logical unary not.
56 def unary!(v)
84 implementing support for user-defined binary operators and adding unary
91 our current framework. We'll first add support for the unary/binary
108 | "unary" -> [< 'Token.Unary; stream >]
110 This just adds lexer support for the unary and binary keywords, like we
137 operators (as you'll see below, it just doesn't apply for unary
146 * ::= unary LETTER number? (id) *)
153 | [< 'Token.Unary >] -> "unary", 1
263 the previous framework we built for other operators. Adding unary
270 Since we don't currently support unary operators in the Kaleidoscope
272 simple support for the 'unary' keyword to the lexer. In addition to
279 (* variant for a unary operator. *)
285 we need to add the parsing logic. Parsing a unary operator is pretty
290 (* unary
292 * ::= '!' unary *)
294 (* If this is a unary operator, read it. *)
301 The grammar we add is pretty straightforward here. If we see a unary
303 prefix and parse the remaining piece as another unary operator. This
304 allows us to handle multiple unary operators (e.g. "!!x"). Note that
305 unary operators can't have ambiguous parses like binary operators can,
318 (* Parse the unary expression after the binary operator. *)
329 With these two simple changes, we are now able to parse unary operators
331 prototypes, to parse the unary operator prototype. We extend the binary
339 * ::= unary LETTER number? (id) *)
346 | [< 'Token.Unary >] -> "unary", 1
381 As with binary operators, we name unary operators with a name that
384 unary operators. It looks like this:
392 let callee = "unary" ^ (String.make 1 op) in
396 | None -> raise (Error "unknown unary operator")
430 # Logical unary not.
431 def unary!(v)
438 def unary-(v)
810 | "unary" -> [< 'Token.Unary; stream >]
833 (* variant for a unary operator. *)
945 (* unary
947 * ::= '!' unary *)
949 (* If this is a unary operator, read it. *)
970 (* Parse the unary expression after the binary operator. *)
1000 * ::= unary LETTER number? (id) *)
1007 | [< 'Token.Unary >] -> "unary", 1
1081 let callee = "unary" ^ (String.make 1 op) in
1085 | None -> raise (Error "unknown unary operator")