Commit Graph

31 Commits

Author SHA1 Message Date
9d5e5f14ca Get rid of file-wide allow(dead_code) in object
Also, squash most of the warnings that came up as a result of this.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-01-24 18:03:01 -08:00
44e2442b9c quote.0 -> quote.index()
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-01-24 17:55:31 -08:00
ea01f8e191 Remove Rc wrapping of BuiltinFnPtr in BuiltinFn wrapper
I'm trying to remember why this was added in the first place - I think
to simplifly cloning? It's not important now though.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-01-24 17:53:29 -08:00
070e497e1f Objs replace Values
* Obj is now a trait instead of a struct
* Value enum is gone, replaced with individual structs that implement
  Obj
* All instances where a Value was used, a Gc<(dyn Obj + 'static)> takes
  its place. ObjPtr is shorthand for this.
* A __str__ method for objects is implemented for a couple builtin types
  as a proof-of-concept
* println and print builtin functions are implemented using this
  interface

There's still a lot to do, mostly with interned values. For example,
whenever a new string object is created, a new __str__ function object
is created each time, rather than reusing the first one that was
created. Stuff like that.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-01-18 14:39:06 -08:00
248dfd3630 Minor cleanup in main()
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-01-18 14:36:45 -08:00
c57c4f1ab3 Remove lazy_static dependency
I just learned about thread local storage, so we really don't
lazy_static for anything anymore - it was only being used for the lexer
regex.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-01-18 14:31:32 -08:00
aad0e8adc2 Add new base object stuff, gc dependency
I'm not writing my own GC, it's a huge pain in Rust. I'm using the gc
library instead.

Base object stuff implementation is here too. Hopefully going to start
using ObjPtr instead of Value next.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-01-17 19:54:19 -08:00
d06e1b82dd Remove max_arena_objects configuration
This isn't something we can't really control so out it goes, I guess.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-01-17 19:51:19 -08:00
5d30719fa2 Remove Obj and Arena
These weren't being used and they didn't have very good implementations.
Movin' on up

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-01-17 19:15:22 -08:00
953fe7cb2a Squash some more warnings from unused member in Machine
We're not using objects yet, so the object arena isn't being used.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-01-16 19:53:08 -08:00
280214c799 Remove Thunks for now.
Since we don't do any language-level indirection, thunks are probably
not necessary for now.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-01-16 19:51:55 -08:00
69431c4926 Add vm::builtins mod as a place for builtin functions to live
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-01-16 19:22:02 -08:00
4cf377ff1e Temporarily remove Value::ObjPtr because we aren't using those yet
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-01-16 19:21:28 -08:00
07ce1378cf Add tilde to allowed characters for words
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-01-16 19:19:40 -08:00
399ade6ba0 Fix parser test that was failing because of Span PartialCmp
Span was using the auto-implemented PartialCmp during testing, which was
interfering with the new "source" member, causing test failures.
PartialCmp of a Span during testing is now always true.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-01-16 19:16:26 -08:00
b3cf1c5681 Add call site discovery to call frames, and add call stack error messages
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-01-16 18:56:33 -08:00
dfac970cc7 Fix a bug with how line/col positions are calculated
Positions were being calculated by looking at the *first* character,
which would cause the same character to be visited twice. Now, if the
character is a null byte (\0), it won't advance the position at all.

The null byte should be a safe sentinel value to use because it
(hypothetically) shouldn't be showing up in a source file. This will
probably cause a hang if a file that starts with null bytes, but that's
a problem for future me.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-01-16 18:49:38 -08:00
1eb7eb73cb Remove RuntimeSpanError and just incorporate it into RuntimeError; add Span information to compiled instructions
* RuntimeSpanError was an extraneous solution to adding spans to the
  errors; so instead this behavior has been delegated to the
  RuntimeError itself.
* Usage of Inst has mostly been replaced with SpInst so if an error is
  encountered, we can spit out where it happened in the source code
  (hopefully with a stack trace).

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-01-16 16:49:54 -08:00
9704e07c45 Add call stack error chain
This allows us to write out errors that follow the call stack and give
locations to where errors originated.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-01-16 15:25:58 -08:00
2752bdf6d3 Add source string to Span
This is the path to the location that this span is pointing to. This is
usually going to be a file path, but it can really be anything you want.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-01-16 14:40:09 -08:00
effa99e65d Add Stmt and incorporate meta statements
This helps split up expressions, meta calls (like includes) that can be
expanded into more expressions.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-01-16 14:14:50 -08:00
cc1d55d826 Remove colon token, and update assign atom to use colon instead of equals
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-01-16 13:08:23 -08:00
c493ab69bb Add meta token
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-01-16 12:27:26 -08:00
88080c750b Rename bang->apply
! syntax item has been referred to as "bang" instead of "apply" in some
places, this is fixed

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-01-12 22:14:54 -08:00
90f27a4108 Add branching and more coherent method of function calls
We're turing-complete, babey!

* Call stack for functions now differentiates between native and quote
  calls
* Better API for builtin functions allowing for more control
* Example showing off branches

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-01-12 21:49:41 -08:00
907c8ce1af Move src/syn/word.rs to src/scope.rs; add BuiltinFn
* crate::scope instead of crate::syn::word, which makes more sense
  because scopes are not really used in syntax at all
* Reference-counted BuiltinFn values are available for creation now

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-01-12 18:00:11 -08:00
1c669decc4 Finally have things printing to the screen
Nothing fancy yet. This commit adds a bunch of stuff (oops):

* compiling code
* VM with instructions
* remove eval.rs and just eval in the Machine struct itself
* squash most warnings now that we're using stuff here

And probably more. But that's all for now folks

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-01-12 17:35:48 -08:00
a190157eeb Minor cosmetic update to parser.rs
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-01-09 18:04:32 -08:00
cbe22bb89e Start adding eval and machine implementations, remove Inst for now
We're not compiling yet and mostly want to get the name stuff figured
out. Also may switch to using anyhow error handling.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-01-08 10:13:27 -08:00
9e20dcf59c Add parser, vm, objects
Big ol thing. You should check it out sometime

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-01-07 20:30:55 -08:00
946a927b09 Initial commit WIP
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2021-12-21 11:29:59 -08:00