Commit graph

48 commits

Author SHA1 Message Date
Erin fa63fda7f8 Obeyed clippy 2021-07-29 23:22:38 +02:00
Alex Bethel 8570f495f5 Get carts sort of working
still a bunch of `todo`s and needs a lot of work, but I'm hungry and
going on lunch break :)
2021-07-29 13:29:23 -05:00
Erin 1714629492 Added cart support into AST 2021-07-27 11:51:05 +02:00
Alex Bethel 003d800d6e Fix broken type_errors unit test 2021-07-22 22:27:17 -05:00
Alex Bethel 594968f781 Remove latent debug println for BFF input 2021-07-22 22:11:55 -05:00
Alex Bethel 9beb45adf0 Silently fail when calling a non-function
The most cursed possible way to deal with this error.
2021-07-16 19:02:51 -05:00
Alex Bethel 56623de96a Make integer coercion infallible 2021-07-16 18:56:45 -05:00
Alex Bethel f6e6f8cea1 Fix function call type error message 2021-07-15 14:24:07 -05:00
Alex Bethel a4d815cf7c Make consts accessible from AbleScript code 2021-07-13 14:22:06 -05:00
Alex Bethel 53e624fdff Merge branch 'feature/read' 2021-06-19 17:34:19 -05:00
Alex Bethel 09d551075a Merge 'feature/forty-two' into master 2021-06-19 17:32:12 -05:00
Alex Bethel f7ac2a1a43 Implement read semantics in interpreter
Also added a test file `iotest.able` to just read data and print
it (the `cat` of AbleScript I guess).
2021-06-18 16:05:50 -05:00
Erin 2ec416db97 Implemented read in Parser 2021-06-18 20:28:53 +02:00
Alex Bethel b26c0ab639 Clippy conformance 2021-06-16 10:35:06 -05:00
Alex Bethel 90c3e31824 Fix ignored unit tests in interpret.rs 2021-06-15 11:46:01 -05:00
Alex Bethel d0f7052290 Fix unit tests 2021-06-15 11:29:52 -05:00
Alex Bethel c35f3d80ff rustfmt: whoops, let's put a semicolon there
maybe I should have actually looked at what rustfmt produced before I
just blindly accepted it and pushed it onto master.
2021-06-15 10:26:44 -05:00
Alex Bethel f02b33d564 rustfmt: break long line 2021-06-15 10:24:50 -05:00
Alex Bethel 0e6bf2b27e Use pass-by-reference for variables, pass-by-value for expressions 2021-06-15 09:51:00 -05:00
Alex Bethel 5ac9117651 Implement most of pass-by-reference
We need some parser changes to make it work fully: function arguments
are now identifiers rather than expressions.
2021-06-15 09:51:00 -05:00
Alex Bethel e709f398f7 Implement functio declaration & calling 2021-06-15 09:51:00 -05:00
HTG-YT aa33fe88db comply with the move of rickroll 2021-06-14 20:53:27 +08:00
HTG-YT 087768fcbc move rickroll content into a file 2021-06-14 09:42:23 +08:00
HTG-YT 1bba812018 Update interpret.rs 2021-06-13 13:22:30 +08:00
HTG-YT 141feac31c handle StmtKind::Rickroll 2021-06-13 13:22:01 +08:00
Alex Bethel ede6eccc71 Make arithmetic errors evaluate to 42 2021-06-12 10:48:44 -05:00
Alex Bethel 1a8f17339e Reimplement BF function declaration semantics 2021-06-12 09:26:21 -05:00
Erin eecde7635c Basic BfFunctio support 2021-06-11 17:52:47 +02:00
Alex Bethel 2a428e8415 Re-enable assignment semantics 2021-06-11 10:05:48 -05:00
Erin 588f69b710 Added variable assignment to parser
- Fixed parse error, that `rlyeh` returned HopBack
2021-06-11 16:59:40 +02:00
Alex Bethel 0fe7819e28 Fix interpreter variable persistence bug 2021-06-08 19:21:33 -05:00
Alex Bethel dfededfe26 Fix all 0..0 span placeholders in interpret.rs 2021-06-07 19:57:44 -05:00
Alex Bethel b6a4ecba29 Fix unit tests 2021-06-07 17:35:49 -05:00
Alex Bethel aedeeb2512 Remove giant comment block left in by mistake 2021-06-07 16:28:27 -05:00
Alex Bethel 3bca3f88a6 Repair interpreter after parser changes 2021-06-07 16:20:20 -05:00
Erin 7b1546387e Unified span terminology
- Add more derivations, because it's required by another parts of project
2021-06-07 22:21:21 +02:00
Alex Bethel 98b2fae6f3 Clean up eval_expr some more
I keep going back and forth on how I want this block to look :P
Anyway, this is *probably* its final-ish form, until the parser gets
re-written.
2021-06-02 18:41:20 -05:00
Alex Bethel d80f47716d Use impl Value rather than trait BfWriter
It probably makes more sense to be writing values with
`Value::bf_write` than to go for the complexity of using a trait to
allow `Writer::write_value` (which also looks ambiguous because it's
not immediately clear that a generic name like "write_value" relates
to BF or AbleScript).
2021-06-02 18:20:30 -05:00
Alex Bethel 2c35691ec4 Add Brainfuck functio interpretation
BF functios can now be declared and called from AbleScript code.
Function parameters supplied from AbleScript are serialized manually
into byte sequences using the `BfWriter` trait, and are available from
BF code using the input operator, `,`.

At the moment, BF functios simply write output to stdout, and are
therefore incapable of communicating results to the rest of the
program; this might change in the future if we can get something close
to pass-by-reference working.
2021-06-02 15:29:31 -05:00
Alex Bethel b3866eea9e Fix panic on arithmetic error
Divide by zero and add, subtract, or multiply with overflow are all
caught now and reported as an ArithmeticError, rather than causing the
interpreter to panic.
2021-05-30 13:32:29 -05:00
Alex Bethel d13c22a473 More thorough unit tests 2021-05-30 13:32:29 -05:00
Alex Bethel 7bfefd3ba1 Add some unit tests to interpret.rs
Currently `overflow_should_not_panic` and `variable_persistence` both
fail due to bugs in the interpreter.
2021-05-30 13:32:29 -05:00
Alex Bethel 00e80e9740 Use single-letter identifiers as base-55 digits 2021-05-29 10:45:39 -05:00
Alex Bethel 51db37f1fe Improve name & documentation accuracy
Renamed ControlFlow -> HaltStatus because that's what the enum really
is -- a status on why something halted. Also reviewed `interpret.rs`'s
documentation and fixed a few things that were out of date.
2021-05-25 21:55:02 -05:00
Alexander Bethel 7537b4ac98 Implement break and hopback statements 2021-05-25 21:22:38 -05:00
Alexander Bethel e7560f9364 Better abstractions, implement scoping rules 2021-05-25 13:26:01 -05:00
Alexander Bethel 1c2032ab87 Implement more statements
Added variable declaration, `if` statements, `loop` statements,
variable assignment, and variable banning to go along with
printing (which was already implemented). We still need function
declarations, brainfuck declarations, function calls, and the control
flow operators "break" and "hopback".
2021-05-24 10:50:26 -05:00
Alexander Bethel e31b8fb00d Implement basic interpreter
Added code for interpreting parsed AbleScript expressions and
statements, and hooked it up to the REPL.
2021-05-20 18:18:01 -05:00