You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We're printing all expressions still when we execute a file, this works how we expect when we're actively typing in the REPL, but when run from a file output is not what we expect.
this was a challenge implementation from an earlier chapter
need a mechanism to know whether or not we're executing from a file. (runFile() method is a good candidate)
Closer to an implementation that works with this commit, we detect when we're called from a file and set a public static var in the interpreter before we execute. b077953
HOWEVER...
that doesn't get us all the way, we don't print anything for statements, consider JS console will print undefined for var statements, and we still print twice in the example loop above. We should consider extending this to only print the resulting expression or last expression instead of every expression, OR no printing when you're inside a block statement. I think the former is what most interpreters do.
We're printing all expressions still when we execute a file, this works how we expect when we're actively typing in the REPL, but when run from a file output is not what we expect.
java com/craftinginterpreters/lox/Lox tests/while
testfile prints numbers 1-10
The text was updated successfully, but these errors were encountered: