Commit Graph

24 Commits

Author SHA1 Message Date
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
67054b2c84 Update branching example to use new syntax
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-01-16 16:49:09 -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
c3d667ec54 Add .vscode directory to gitignore
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-01-16 14:07:26 -08:00
ced903c0c1 Update hello world example to match new syntax
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-01-16 14:05:28 -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
c31be8142c Update hello world to use a function
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2022-01-12 19:43:29 -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