basic expression interpreter

This commit is contained in:
basil 2025-06-08 16:03:02 -04:00
parent eebaadc16e
commit b244f7e3b2
Signed by: basil
SSH key fingerprint: SHA256:y04xIFL/yqNaG9ae9Vl95vELtHfApGAIoOGLeVLP/fE
5 changed files with 186 additions and 16 deletions

6
run.go
View file

@ -4,10 +4,10 @@ import (
"errors"
"os"
"git.red-panda.pet/pandaware/lox-go/ast"
"git.red-panda.pet/pandaware/lox-go/lexer"
"git.red-panda.pet/pandaware/lox-go/parser"
"git.red-panda.pet/pandaware/lox-go/reporter"
"git.red-panda.pet/pandaware/lox-go/runtime"
)
func RunFile(filename string) error {
@ -36,8 +36,8 @@ func Run(source string) error {
return errors.New("parser error")
}
printer := &ast.Printer{}
reporter.Debug(0, "astPrinter", "stdin", printer.Print(expr))
interpreter := runtime.NewInterpreter()
reporter.Debug(0, "interpreter", "stdin", interpreter.Evaluate(expr).Debug())
return nil
}