keon-dev / monkey-interpreter

A language interpreter written in Go. (Reference: "Writing an Interpreter In Go" by Thorsten Ball)
0 stars 0 forks source link

Add functionality to parse expressions #7

Closed keon-dev closed 1 week ago

keon-dev commented 2 weeks ago

Expressions in monkey

keon-dev commented 2 weeks ago

Each token type will have up to two parsing functions associated with is, depending on whether the token is found in a prefix or an infix position.

type (
    prefixParseFn func() ast.Expression
    infixParseFn  func(ast.Expression) ast.Expression .
)

Both functions return an ast.Expression, but infixParseFn takes another ast.Expression which is the left side of the operator being parsed.