Commit Graph

407 Commits (trunk)

Author SHA1 Message Date
Alex Bethel 5998033612 Better error handling in REPL
We have much better spanned expression support, so now we get to show
it off!
2021-06-07 20:08:38 -05:00
Alex Bethel d89ab5e49b Remove 0..0 placeholder from unexpected_eof() 2021-06-07 20:03:26 -05:00
Alex Bethel 0414d6a99b Fix all 0..0 span placeholders in interpret.rs 2021-06-07 19:57:44 -05:00
Alex Bethel a4c8f4f30e Fix unit tests 2021-06-07 17:35:49 -05:00
Alex Bethel c8810b50cb Remove giant comment block left in by mistake 2021-06-07 16:28:27 -05:00
Alex Bethel e1ce6e3a05 Repair interpreter after parser changes 2021-06-07 16:20:20 -05:00
ondra05 63cc11e965 Added T-Dark test 2021-06-07 23:06:13 +02:00
ondra05 937f19858d Added tests, Bugfix
- Originally, it spanned from operator (bug)
2021-06-07 22:58:28 +02:00
ondra05 8beb81cd1a Added missing mut 2021-06-07 22:24:43 +02:00
ondra05 3af792779f Unified span terminology
- Add more derivations, because it's required by another parts of project
2021-06-07 22:21:21 +02:00
ondra05 f966b08bf2 Changed position terminology 2021-06-07 21:28:24 +02:00
ondra05 918cfe0eff Removed unwraps, added Rlyeh 2021-06-07 11:07:50 +02:00
ondra05 535a62357f Implement function calls
- And printing
- Revised terminology in Lexer
- Control flow
2021-06-07 11:00:06 +02:00
ondra05 17a5a5e814 Added logical operators 2021-06-07 09:17:30 +02:00
ondra05 d00d147baa Binary operator boilerplate reduction 2021-06-07 09:17:18 +02:00
ondra05 2a77ffa516 Added basic parsing
- Expressions
- If, Functio
2021-06-07 00:09:45 +02:00
ondra05 29a8a8f5f0 Initial chthulic error impl in Lexer
- See discussions #17
2021-06-06 23:15:11 +02:00
ondra05 5ff156f7ea AST revamp
- Unified terminology of span in error.rs
2021-06-06 23:13:48 +02:00
ondra05 9b76e9bea6 Updated AST 2021-06-06 21:09:18 +02:00
ondra05 82883638ef Removed custom Lexer, reorganised `Token` definition
- As peeking will not be involved in parsing, it was removed
2021-06-06 20:28:13 +02:00
ondra05 019fa818e3 Deleted old parser 2021-06-06 20:05:18 +02:00
Alex Bethel 3b8487a0aa Correct spelling of "occurred" 2021-06-05 08:50:20 -05:00
Alex Bethel 6f646a76e6 Prettier error handling 2021-06-04 18:56:26 -05:00
Able db741b7fe0
Merge pull request #28 from AlexBethel/bf-functio 2021-06-02 20:02:53 -05:00
Alex Bethel 988f6ad053 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 b2290fc76e 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 7eabaafb98 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 663a429db2 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 e8af0ec3c9 More thorough unit tests 2021-05-30 13:32:29 -05:00
Alex Bethel 2ad3d6d76f 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
Able 78dcee732d
Merge pull request #27 from AlexBethel/master 2021-05-29 17:14:25 -05:00
Alex Bethel 6971d0a56c Make base-55 encoding & decoding match
Changed "U"'s encoding to -210, so now when the README claims "U =
-210", it's actually accurate :)
2021-05-29 14:24:46 -05:00
Alex Bethel 270ffb98a2 Use single-letter identifiers as base-55 digits 2021-05-29 10:45:39 -05:00
Able 3b1ffd7489
Merge pull request #26 from Seppel3210/patch-1 2021-05-28 05:10:43 -05:00
Seppel3210 3cb187981d
Change "*" versions to explicit versions
Change "*" versions to explicit versions in Cargo.toml
2021-05-28 09:30:16 +02:00
Able 535093f0bc
Update README.md 2021-05-27 17:51:08 -05:00
Able 5ff0d1c5cc
Merge pull request #24 from AlexBethel/master 2021-05-25 23:06:08 -05:00
Alex Bethel 3cc4a153ab 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 ce63e1a734 Implement `break` and `hopback` statements 2021-05-25 21:22:38 -05:00
Alexander Bethel 9246c1453c Better abstractions, implement scoping rules 2021-05-25 13:26:01 -05:00
Alexander Bethel 7c1ef4be82 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
Able 562645c8ef Slightly more curse 2021-05-24 01:18:36 -05:00
Able 3977e3d28b
Merge pull request #22 from AlexBethel/master 2021-05-21 12:29:03 -05:00
Alexander Bethel 746ece58c7 Allow abool -> bool coercion
The expression `sometimes & true` now evaluates to `true` 50% of the
time and false 50% of the time, rather than throwing a type error
because `sometimes` is not a bool.
2021-05-21 12:25:37 -05:00
Alexander Bethel 5698761568 Make `ablescript -f` run interpreter
`ablescript -f foo.able` will now both parse and interpret `foo.able`,
rather than just parsing it.
2021-05-20 18:24:18 -05:00
Alexander Bethel d4766c19ec 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
Able 6d17df24f7
Merge pull request #18 from T-Dark0/tdark-brainfuck 2021-05-15 20:34:29 -05:00
tdark 115bf5e639 Added support for specifying a tape size limit 2021-05-15 18:39:49 +02:00
tdark a500a7f8bc Implemented brainfuck interpreter 2021-05-15 18:10:50 +02:00
Able 2c0d5d12cb
Update README.md 2021-05-14 10:52:16 -05:00