js: Take the script file as a command-line argument

Now that we have the beginnings of a parser, let's take the script to
run as a command-line argument and move all the test scripts into
/home/anon/js :^)

To run a script, simply use "js":

$ js my-script.js

To get an AST dump before execution, you can use "js -A"
This commit is contained in:
Andreas Kling 2020-03-12 10:51:41 +01:00
commit 4d942cc1d0
Notes: sideshowbarker 2024-07-19 08:45:51 +09:00
7 changed files with 56 additions and 141 deletions

View file

@ -0,0 +1,9 @@
function foo() {
function bar() {
var y = 6;
}
bar()
return y;
}
foo(); //I should return `undefined` because y is bound to the inner-most enclosing function, i.e the nested one (bar()), therefore, it's undefined in the scope of foo()