2023
October
31

31th October

Evaluating Infix Expressions

This one is fairly simple, as we can use the underlying methods of the language we are writing monkey in, in this case Golang.

There are two sets of infix operators:

  1. Arithmatic Operators

These are +, -, /, *. This implies that the reuturned object type should be an integer.

  1. Boolean Operators

These are >, <, !=, ==. The returned object type should be of type boolean.

Both 1 & 2 deal with integer operands. That meant having to support != & == for boolean operands. Which is fairly straight forward as interfaces can be compared to each other in Go.

That completes evaluating expressions in monkey. The next step is Conditionals! :)

Commit:f5568ee (opens in a new tab)

Subscribe to my newsletter

The latest news, articles, and resources, sent to your inbox weekly.

© 2024 Seagin, Inc. All rights reserved.