Commit graph

1120 commits

Author SHA1 Message Date
0xtechnobabble
bc002f807a LibJS: Parse object expressions 2020-03-21 10:08:58 +01:00
Andreas Kling
bceabd7c4b LibJS: Add ArrayPrototype and implement Array.prototype.push()
This function is ultimately supposed to be generic and allow any |this|
that has a length property, but for now it only works on our own Array
object type.
2020-03-20 21:56:40 +01:00
Andreas Kling
8f7d4f67a4 LibJS: Support reading/writing elements in an Array via Object get/put
I'm not completely thrilled about Object::get() and Object::put() doing
special-case stuff for arrays, and we should probably come up with a
better abstraction for it.

But at least it works for now, which is really nice. :^)
2020-03-20 21:56:40 +01:00
Andreas Kling
a3d2e07446 LibJS: Parse computed MemberExpressions
MemberExpression comes in two flavors:

    computed: a[b]
non-computed: a.b

We can now parse both of the types. :^)
2020-03-20 21:56:40 +01:00
Andreas Kling
86642add2f LibJS: Allow default-constructing a JS::Value (undefined) 2020-03-20 21:56:40 +01:00
Andreas Kling
a82f64d3d6 LibJS: Parse ArrayExpression and start implementing Array objects
Note that property lookup is not functional yet.
2020-03-20 21:56:40 +01:00
Andreas Kling
5db8940c9e LibJS: Use StringBuilder::join() 2020-03-20 14:41:23 +01:00
Andreas Kling
218f082226 LibJS: Print a newline in each console.log() 2020-03-20 14:41:23 +01:00
Andreas Kling
73d28a0551 LibJS: Prefer FunctionDeclaration if a statement begins with "function" 2020-03-19 18:07:07 +01:00
Andreas Kling
1a10470c1d LibJS: Implement basic object property assignment
This is pretty naive, we just walk up the prototype chain and call any
NativeProperty setter that we find. If we don't find one, we put/set
the value as an own property of the object itself.
2020-03-19 17:44:06 +01:00
Andreas Kling
07679e347c LibJS: Parse FunctionExpressions
FunctionExpression is mostly like FunctionDeclaration, except the name
is optional. Share the parsing logic in parse_function_node<NodeType>.

This allows us to do nice things like:

    document.addEventListener("DOMContentLoaded", function() {
        alert("Hello friends!");
    });
2020-03-19 11:54:11 +01:00
Andreas Kling
b1b4c9844e LibJS: Add FunctionExpression AST node
Most of the code is shared with FunctionDeclaration, so the shared bits
are moved up into a common base called FunctionNode.
2020-03-19 11:12:08 +01:00
Andreas Kling
f0b49ae04b LibJS: Fix reference leak in ASTNode::append()
Using make<T> like this would create an unadopted object whose refcount
would never reach zero.
2020-03-19 11:02:20 +01:00
Andreas Kling
961b4f2577 LibJS: Add missing copyright headers 2020-03-18 20:21:06 +01:00
Andreas Kling
a119b61782 LibJS: Add Handle<T>, a strong C++ handle for keeping GC objects alive
This is pretty heavy and unoptimized, but it will do the trick for now.
Basically, Heap now has a HashTable<HandleImpl*> and you can call
JS::make_handle(T*) to construct a Handle<T> that guarantees that the
pointee will always survive GC until the Handle<T> is destroyed.
2020-03-18 20:03:17 +01:00
Andreas Kling
97674da502 LibJS: Tolerate NativeFunction::call() with non-object 'this' for now
I'm not exactly sure why we end up in this situation, we'll have to
look into it.
2020-03-18 17:13:22 +01:00
Andreas Kling
f64f7a4787 LibJS: Add Function to Forward.h 2020-03-18 17:13:22 +01:00
Andreas Kling
e96ef450f6 LibJS: Add Interpreter::call(Function*, this_value, arguments)
This helper function takes care of pushing/popping a call frame so you
don't need to worry about it.
2020-03-18 17:13:22 +01:00
Andreas Kling
ddd69e3660 LibJS: Make the AST reference-counted
This allows function objects to outlive the original parsed program
without their ScopeNode disappearing.
2020-03-18 11:23:53 +01:00
Conrad Pankoff
46a897b59b LibJS: Implement typeof operator 2020-03-17 21:28:02 +01:00
Andreas Kling
0a71533aff LibJS: Pass argument value vectors as const Vector<Value>&
Now that Interpreter keeps all arguments in the CallFrame stack, we can
just pass a const-reference to the CallFrame's argument vector to each
function handler (instead of copying it.)
2020-03-17 16:24:53 +01:00
Andreas Kling
bf9912cc59 LibJS: Protect function call "this" and arguments from GC
This patch adds a CallFrame stack to Interpreter, which keeps track of
the "this" value and all argument values passed in function calls.

Interpreter::gather_roots() scans the call stack, making sure that all
argument values get marked. :^)
2020-03-17 11:06:00 +01:00
Andreas Kling
cb2e7d1c5f LibJS+js: Add a debug option (js -g) to GC after every allocation
This is very useful for discovering collector bugs.
2020-03-16 19:18:46 +01:00
Andreas Kling
ab404a2f88 LibJS: Implement basic conservative garbage collection
We now scan the stack and CPU registers for potential pointers into the
GC heap, and include any valid Cell pointers in the set of roots.

This works pretty well but we'll also need to solve marking of things
passed to native functions, since those are currently in Vector<Value>
and the Vector storage is on the heap (not scanned.)
2020-03-16 19:14:09 +01:00
Andreas Kling
086f68e878 LibJS: Replace the global print() function with console.log() :^) 2020-03-16 14:58:20 +01:00
Andreas Kling
19452230cd LibJS: Add "Heap" and "Runtime" subdirectories
Let's try to keep LibJS tidy as it expands. :^)
2020-03-16 14:37:19 +01:00
0xtechnobabble
dfbaa8e543 LibJS: Implement abstract equality and inequality 2020-03-16 13:42:13 +01:00
0xtechnobabble
4d22a142f7 LibJS: Loosen type system
This commits makes effort towards tolerating some of javascript's quirks
when it comes to its type system, note that the interpreter's way of
handling type coercion is still not mature at all, for example, we still
have to implement NaN instead of just crashing when trying to parse a
string and failing.
2020-03-16 13:42:13 +01:00
0xtechnobabble
419d57e492 LibJS/Parser: Parse logical expressions 2020-03-16 13:42:13 +01:00
0xtechnobabble
94088640f1 LibJS: Specify overridden functions with 'override' 2020-03-16 13:42:13 +01:00
0xtechnobabble
cfd710eb31 LibJS: Implement null and undefined literals 2020-03-16 13:42:13 +01:00
0xtechnobabble
7aad10d984 LibJS: Fix assignment of const variable on declaration
We were previously assuming that we were reassigning a variable even
when we were not, oops, my bad. :/
2020-03-16 13:42:13 +01:00
Andreas Kling
731abd9978 LibJS: Add String.prototype.repeat() :^) 2020-03-15 21:17:38 +01:00
Andreas Kling
63b3cfdc73 LibJS: Pass "this" as an Object* to NativeFunction callbacks
Instead of every NativeFunction callback having to ask the Interpreter
for the current "this" value and then converting it to an Object etc,
just pass "this" as an Object* directly.
2020-03-15 20:51:36 +01:00
Andreas Kling
3163929990 LibJS: Add a mechanism for callback-based object properties
This patch adds NativeProperty, which can be used to implement object
properties that have C++ getters and/or setters.

Use this to move String.prototype.length to its correct place. :^)
2020-03-15 19:31:00 +01:00
Andreas Kling
bb57bc1b42 LibJS: Remove debug spam in Object::get() 2020-03-15 19:31:00 +01:00
Andreas Kling
23b1d97b0d LibJS: Add ObjectPrototype and implement hasOwnProperty()
All Objects will now have ObjectPrototype as their prototype, unless
overridden.
2020-03-15 15:25:43 +01:00
Andreas Kling
f1f14945cf LibJS: Rename collect_roots() => gather_roots()
Since this is about finding the things we should *not* garabge collect,
it seemed wrong to call it "collect_something" :^)
2020-03-15 15:13:24 +01:00
Andreas Kling
8dc6416bba LibJS: Use the same StringPrototype globally
To make sure that everyone has the same instance of StringPrototype,
hang a global prototype off of the Interpreter that can be fetched
when constructing new StringObjects.
2020-03-15 15:11:13 +01:00
Andreas Kling
9b4358e150 LibJS: Add Cell::interpreter() convenience helper
This allows you to go from any Cell* to the Interpreter.
2020-03-15 15:08:27 +01:00
Andreas Kling
fbefb19e10 LibJS: Interpreter should make sure that the "this" stack gets marked 2020-03-15 15:07:49 +01:00
Andreas Kling
2c5b9fb8f9 LibJS: Add StringPrototype and make it the prototype of StringObject
This patch adds String.prototype.charAt() to demonstrate that prototype
property lookup works, and that you can call a prototype function on an
object, and it will do what you expect. :^)
2020-03-15 15:02:49 +01:00
Andreas Kling
f7c15d00c9 LibJS: Add basic prototype support
Object will now traverse up the prototype chain when doing a get().
When a function is called on an object, that object will now also be
the "this" value inside the function. This stuff is probably not very
correct, but we will improve things as we go! :^)
2020-03-15 15:01:10 +01:00
Andreas Kling
d02c37f3e3 LibJS: Add Value::to_i32() helper function 2020-03-15 15:00:18 +01:00
0xtechnobabble
2e90a7eb2d LibJS/Parser: Implement the parsing of unary/prefixed update expressions 2020-03-14 20:02:53 +01:00
0xtechnobabble
db64f364f0 LibJS/AST: Implement prefixed update expressions 2020-03-14 20:02:53 +01:00
0xtechnobabble
20a0fc5576 LibJS: Rename BitNot -> BitwiseNot to match other bitwise operators 2020-03-14 20:02:53 +01:00
Stephan Unverwerth
3389021291 LibJS: Unescape strings in Token::string_value() 2020-03-14 16:00:28 +01:00
0xtechnobabble
644b4f4201 LibJS: Evaluate for statements in their own scope if necessary
We now evaluate for loops in their own scope if their init statement is
a lexical declaration.

Evaluating for loops in their own scope allow us to obtain expected
behaviour, which means for example, that the block-scoped variables
declared in a  for statement will be limited to the scope of the for
loop's body and  statement and not to that of the current scope (i.e the
one where the for statement was made)
2020-03-14 13:58:30 +01:00
0xtechnobabble
0659d07241 LibJS/Parser: Remove superfluous switch case 2020-03-14 13:58:30 +01:00
Andreas Kling
f94099f796 LibJS: Strip double-quote characters from StringLiteral tokens
This is very hackish since I'm just doing it to make progress on
something else. :^)
2020-03-14 12:40:06 +01:00
Stephan Unverwerth
c0e6234219 LibJS: Lex single quote strings, escaped chars and unterminated strings 2020-03-14 12:13:53 +01:00
Oriko
e273203d27 LibJS: Add missing tokens to name() 2020-03-14 11:30:31 +01:00
Stephan Unverwerth
15d5b2d29e LibJS: Add operator precedence parsing
Obey precedence and associativity rules when parsing expressions
with chained operators.
2020-03-14 00:11:24 +01:00
Oriko
2d7f4bea90 LibJS: Fix endless loop in string lexing 2020-03-13 22:53:13 +01:00
Stephan Unverwerth
ac524b632f LibJS: Fix lexing of the last character in a file
Before this commit the last character in a file would be swallowed.
This also fixes parsing of empty files which would previously ASSERT.
2020-03-13 21:47:57 +01:00
Linus Groh
0e04e2cff0 LibJS: Add parsed parameters to FunctionDeclaration 2020-03-13 20:16:01 +01:00
0xtechnobabble
83ea7bb9e7 LibJS: Don't allow the redeclaration of a var variable using let/const
Previously, we were allowing the redeclaration of a variable with `let`
or `const` if it was declared initially using `var`, we should not
tolerate any form of variable redeclaration using let/const.
2020-03-13 20:15:52 +01:00
Andreas Kling
9f38f4dbfb LibJS: Add Object::put_native_function() for convenience
This makes it a little bit nicer to add native function properties
to JavaScript objects.

Thanks to Sergey for suggesting it! :^)
2020-03-13 11:08:16 +01:00
Andreas Kling
6089d6566b LibJS: Make it possible to go from a Cell* to its Heap&
This patch makes all HeapBlock allocations aligned to their block size,
enabling us to find the HeapBlock* for a given Cell* by simply masking
bits off of the cell address.

Use this to make a simple Heap& getter for Cell, which lets us avoid
plumbing the Heap& everywhere.
2020-03-13 11:08:16 +01:00
Andreas Kling
d9c7009604 LibJS: Split Function into subclasses NativeFunction and ScriptFunction
Both types of functions are now Function and implement calling via:

    virtual Value call(Interpreter&, Vector<Value> arguments);

This removes the need for CallExpression::execute() to care about which
kind of function it's calling. :^)
2020-03-13 11:08:16 +01:00
Andreas Kling
1448f4384d LibJS: Move GlobalObject to its own Object subclass
This is mostly for tidiness at the moment.
2020-03-12 20:11:35 +01:00
Andreas Kling
d1d136b4e5 LibJS: Replace $gc() hack with a NativeFunction on the global object
To make this work, also start passing Interpreter& to native functions.
2020-03-12 20:04:54 +01:00
Andreas Kling
9ad17d4674 LibJS: Fix broken parsing of 0-argument CallExpression 2020-03-12 20:03:12 +01:00
Andreas Kling
32963cf74a LibJS: Allow implicit Value construction from GC-allocated things 2020-03-12 19:57:40 +01:00
Andreas Kling
7912f33ea0 LibJS: Add NativeFunction, a callable wrapper around a C++ lambda
This can be used to implement arbitrary functionality, callable from
JavaScript.

To make this work, I had to change the way CallExpression passes
arguments to the callee. Instead of a HashMap<String, Value>, we now
pass an ordered list of Argument { String name; Value value; }.

This patch includes a native "print(argument)" function. :^)
2020-03-12 19:54:47 +01:00
Andreas Kling
cc8e3048bc LibJS: Fix NumericLiteral::dump() output 2020-03-12 19:36:24 +01:00
Andreas Kling
92d1014051 LibJS: Parse CallExpression arguments 2020-03-12 19:35:23 +01:00
Andreas Kling
25db856134 LibJS: Dump CallExpression arguments (if any) 2020-03-12 19:34:59 +01:00
0xtechnobabble
ee5a49e2fe LibJS: Implement const variable declarations
This also tightens the means of redeclaration of a variable by proxy,
since we now have a way of knowing how a variable was initially
declared, we can check if it was declared using `let` or `const` and
not tolerate redeclaration like we did previously.
2020-03-12 14:58:16 +01:00
0xtechnobabble
8557bc56f7 LibJS: Implement update expressions
Note that currently only the non-prefixed variant is supported (i.e i++
not ++i), this variant returns the value of the argument before the
update.
2020-03-12 14:58:16 +01:00
0xtechnobabble
dc9a702aa8 LibJS/Parser: Parse let declarations 2020-03-12 14:58:16 +01:00
Andreas Kling
4dc1d6654f LibJS: Tweak AssignmentOp names 2020-03-12 13:54:56 +01:00
Andreas Kling
4781e3fb72 LibJS: Fix some coding style mistakes in Lexer 2020-03-12 13:52:54 +01:00
Conrad Pankoff
097e1af4e8 LibJS: Implement for statement 2020-03-12 13:42:23 +01:00
Conrad Pankoff
e88f2f15ee LibJS: Parse === and !== binary operators 2020-03-12 13:42:23 +01:00
Conrad Pankoff
9d41aa4d5d LibJS: Parse > and < binary operators 2020-03-12 13:42:23 +01:00
Conrad Pankoff
2b36b4f09f LibJS: Implement +=, -=, *=, and /= assignment operators 2020-03-12 13:42:23 +01:00
Conrad Pankoff
0fe87c5fec LibJS: Implement <= and >= binary operators 2020-03-12 13:42:23 +01:00
Conrad Pankoff
fdf7f81ba9 LibJS: Implement multiplication and division operators 2020-03-12 13:42:23 +01:00
Andreas Kling
f405cb6a77 LibJS: Implement basic MemberExpression parsing
At last we can parse "hello friends".length :^)
2020-03-12 13:05:57 +01:00
Andreas Kling
ed100bc6f4 LibJS: Implement basic lexing + parsing of StringLiteral
This still includes the double-quote characters (") but at least the
AST comes out right.
2020-03-12 13:05:06 +01:00
howar6hill
01133733dd
LibJS: Allow functions to take arguments (#1405) 2020-03-12 12:22:13 +01:00
Andreas Kling
425fd3ce51 LibJS: Defer Value construction until a Literal is executed
Remove the need to construct a full Value during parsing. This means
we don't have to worry about plumbing the heap into the parser.

The Literal ASTNode now has a bunch of subclasses that synthesize a
Value on demand.
2020-03-12 12:19:11 +01:00
Andreas Kling
0d42097cf1 LibJS: Forgot to move add/sub/typed_eq to Value.cpp 2020-03-12 09:26:23 +01:00
Stephan Unverwerth
f3a9eba987 LibJS: Add Javascript lexer and parser
This adds a basic Javascript lexer and parser. It can parse the
currently existing demo programs. More work needs to be done to
turn it into a complete parser than can parse arbitrary JS Code.

The lexer outputs tokens with preceeding whitespace and comments
in the trivia member. This should allow us to generate the exact
source code by concatenating the generated tokens.

The parser is written in a way that it always returns a complete
syntax tree. Error conditions are represented as nodes in the
tree. This simplifies the code and allows it to be used as an
early stage parser, e.g for parsing JS documents in an IDE while
editing the source code.:
2020-03-12 09:25:49 +01:00
Florian Stellbrink
17705d23fb LibJS: Fix string roots not being collected
Previously objects were the only heap
allocated value. Now there are also strings.

This replaces a usage of is_object with is_cell.
Without this change strings could be garbage
collected while still being used in an active scope.
2020-03-12 07:50:49 +01:00
0xtechnobabble
df40c85f80
LibJS: Allow the choice of a scope of declaration for a variable (#1408)
Previously, we were assuming all declared variables were bound to a
block scope, now, with the addition of declaration types, we can bind
a variable to a block scope using `let`, or a function scope (the scope
of the inner-most enclosing function of a `var` declaration) using
`var`.
2020-03-11 20:09:20 +01:00
Andreas Kling
542108421e LibJS: Support "hello friends".length
The above snippet is a MemberExpression that necessitates the implicit
construction of a StringObject wrapper around a PrimitiveString.

We then do a property lookup (a "get") on the StringObject, where we
find the "length" property. This is pretty neat! :^)
2020-03-11 19:00:26 +01:00
Andreas Kling
6ec6fa1a02 LibJS: Add StringObject, an Object wrapper around primitive strings
This object will (soon) be implicitly created to wrap a primitive
string when one is used in a context that requires an object.
2020-03-11 19:00:26 +01:00
Andreas Kling
111ef762f6 LibJS: Add a new PrimitiveString class to hold GC-allocated strings 2020-03-11 19:00:22 +01:00
Andreas Kling
29c7a5dcbe LibJS: Simplify Literal::dump() 2020-03-11 19:00:20 +01:00
Andreas Kling
ddb5c995c6 LibJS: Let's say that Identifier is an Expression for now
This allows us to tighten typing in various other classes.
2020-03-10 12:29:28 +01:00
Andreas Kling
7de35118a9 LibJS: Move Value ops into Value.cpp and tweak BinaryOp names 2020-03-10 12:29:00 +01:00
Andreas Kling
fe6bd9650f LibJS: Use Value::to_boolean() wherever we haven't checked is_boolean()
Unless we've verified that a Value is a boolean, we should not be
calling as_bool() on it.
2020-03-10 12:28:10 +01:00
Andreas Kling
a0e18f4450 LibJS: Oops, non-zero values should boolify to true, not false 2020-03-10 10:08:42 +01:00
Andreas Kling
dc0b091c31 LibJS: Implement basic boolean coercion
We can't expect the conditionals in "if" and "while" statements to
always return a bool, so we need to know how to boolify a JS::Value.
2020-03-10 08:47:36 +01:00
Andreas Kling
386867da9f LibJS: Add a convenience helper for visiting a JS::Value
We only really care to visit values if they refer to a Cell, but it's
nice to be able to say visit(some_value).
2020-03-09 22:19:06 +01:00
Andreas Kling
05c80cac20 LibJS: Make the GC marking phase cycle-proof
Don't visit cells that are already marked. This prevents the marking
phase from looping forever when two cells refer to each other.

Also do the marking directly from the CellVisitor, removing another
unnecessary phase of the collector. :^)
2020-03-09 22:18:03 +01:00
Andreas Kling
0d6be2cac2 LibJS: Make FunctionDeclaration and CallExpression scope-aware 2020-03-09 21:53:39 +01:00
Andreas Kling
363c40e3f3 LibJS: Make sure we mark everything reachable from the scope stack
This ensures that local variables survive GC.
2020-03-09 21:49:20 +01:00
Andreas Kling
26165cd92a LibJS: Add a very simple ObjectExpression for "var x = {}"
This allows us to allocate an empty new Object on the GC heap.
2020-03-09 21:49:20 +01:00
Andreas Kling
15d8b9c671 LibJS: Add magical "$gc" function that can be called to trigger GC
This will be immensely useful for testing.
2020-03-09 21:49:20 +01:00
Andreas Kling
1382dbc5e1 LibJS: Add basic support for (scoped) variables
It's now possible to assign expressions to variables. The variables are
put into the current scope of the interpreter.

Variable lookup follows the scope chain, ending in the global object.
2020-03-09 21:49:20 +01:00
Andreas Kling
c6e54d2a49 LibJS: Simplify Heap::mark_live_cells()
Instead of iterating over every single cell, simply iterate over the
live cells and mark them from there.

Thanks to Blam for suggesting this! :^)
2020-03-09 19:36:15 +01:00
0xtechnobabble
5e817ee678 LibJS: Move logical not operator to new unary expression class 2020-03-09 19:33:07 +01:00
0xtechnobabble
65343388b8 LibJS: Add new bitwise and relational operators
Do note that when it comes to evaluating binary expressions, we are
asserting in multiple contexts that the values we're operating on are
numbers, we should probably handle other value types to be more tolerant
in the future, since for example, adding a number and a string, in
which case the number is converted to a string implicitly which is then
concatenated, although ugly, is valid javascript.
2020-03-09 19:33:07 +01:00
howar6hill
11aac6fdce
LibJS: Remove superfluous explicit in AST.h (#1395) 2020-03-09 14:37:08 +01:00
howar6hill
1c83c5ed08 LibJS: Implement While statements 2020-03-09 10:13:27 +01:00
Stephan Unverwerth
1207187e97 LibJS: GC: Remove clear_all_mark_bits()
Clearing all marked flags has been integrated into the sweep function,
saving an additional full iteration over the heap.
2020-03-09 07:32:09 +01:00
Andreas Kling
63e4b744ed LibJS: Add a basic mark&sweep garbage collector :^)
Objects can now be allocated via the interpreter's heap. Objects that
are allocated in this way will need to be provably reachable from at
least one of the known object graph roots.

The roots are currently determined by Heap::collect_roots().

Anything that wants be collectable garbage should inherit from Cell,
the fundamental atom of the GC heap.

This is pretty neat! :^)
2020-03-08 19:23:58 +01:00
0xtechnobabble
b6307beb6e LibJS: Implement if statements
If statements execute a certain action or an alternative one depending
on whether the tested condition is true or false, this commit helps
establish basic control flow capabilities in the AST.
2020-03-08 11:15:07 +01:00
0xtechnobabble
a96bf2c22e LibJS: Implement logical expressions
Logical expressions are expressions which can return either true or
false according to a provided condition.
2020-03-08 11:15:07 +01:00
0xtechnobabble
4e62dcd6e6 LibJS: Add typed comparison operator
The `===` operator allows us to compare two values while taking their
type into consideration.
2020-03-08 11:15:07 +01:00
0xtechnobabble
3fb0ff102c LibJS: Allow the dumping of literals that aren't numbers 2020-03-08 11:15:07 +01:00
Andreas Kling
0c7058aaa0 LibJS: Include the operator in BinaryExpression dumps 2020-03-07 23:17:07 +01:00
Andreas Kling
1611071ac7 LibJS: Flesh out JS::Value a little bit more 2020-03-07 23:17:07 +01:00
Andreas Kling
d52130836e LibJS: Simplify LogStream::operator<<(JS::Value) and move to .cpp file 2020-03-07 23:17:07 +01:00
Elisée Maurer
cbe0053a97 LibJS: Fix string representation for value of type undefined 2020-03-07 23:15:36 +01:00
Andreas Kling
f5476be702 LibJS: Start building a JavaScript engine for SerenityOS :^)
I always tell people to start building things by working on the thing
that seems the most interesting right now. The most interesting thing
here was an AST + simple interpreter, so that's where we start!

There is no lexer or parser yet, we build an AST directly and then
execute it in the interpreter, producing a return value.

This seems like the start of something interesting. :^)
2020-03-07 19:42:11 +01:00