-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
18b Logical operators #48
Conversation
Operator precedenceNOT has the same precedence as unary AND and OR have lower precedence than |
Resolving logical operatorsNext, we've got to resolve these new operators so that appropriate types are returned. First, the unary NOT: Then the binary AND & OR: |
Interpreting logical operatorsOkay, nothing to change here; our operators take in the )type-checked) input, and return their output. But a slightly horrifying discovery: For unary Fix - we overload |
And we have working logical operators 👍 |
Now that our interpreter can understand TRUE and FALSE, let's implement AND, OR, and NOT operators.
We start with scanning. First let's add the operators in
builtin.py
and have them recognised as operators:https://github.com/nyjc-computing/pseudo/blob/4241f231018f605311a67ad762c9db3e4cf5e8cb/builtin.py#L71-L78
https://github.com/nyjc-computing/pseudo/blob/4241f231018f605311a67ad762c9db3e4cf5e8cb/builtin.py#L105-L119
Then enable scanning them:
https://github.com/nyjc-computing/pseudo/blob/4241f231018f605311a67ad762c9db3e4cf5e8cb/scanner.py#L98-L100