Commit graph

71 commits

Author SHA1 Message Date
Erin b7464f6ad3 Implement function calls
- And printing
- Revised terminology in Lexer
- Control flow
2021-06-07 11:00:06 +02:00
Erin b6bce72b94 Added logical operators 2021-06-07 09:17:30 +02:00
Erin 97f0271534 Binary operator boilerplate reduction 2021-06-07 09:17:18 +02:00
Erin a5a048728c Added basic parsing
- Expressions
- If, Functio
2021-06-07 00:09:45 +02:00
Erin b04bd77672 Initial chthulic error impl in Lexer
- See discussions #17
2021-06-06 23:15:11 +02:00
Erin 93065e7dc9 AST revamp
- Unified terminology of span in error.rs
2021-06-06 23:13:48 +02:00
Erin 6fd95f3cc2 Updated AST 2021-06-06 21:09:18 +02:00
Erin afe6588c05 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
Erin 2c15f3dc17 Deleted old parser 2021-06-06 20:05:18 +02:00
Alex Bethel 4bda25c9f3 Correct spelling of "occurred" 2021-06-05 08:50:20 -05:00
Alex Bethel 6c2d5cc84a Prettier error handling 2021-06-04 18:56:26 -05:00
Alex Bethel 528de718dc 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 ce02aebd91 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 326d0511e7 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 07195d4cf6 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 acfd81ead2 More thorough unit tests 2021-05-30 13:32:29 -05:00
Alex Bethel 344a11084e 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 099b9e23d6 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 585bf2e19f Use single-letter identifiers as base-55 digits 2021-05-29 10:45:39 -05:00
Alex Bethel c906366e3f 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 ec81ead3ea Implement break and hopback statements 2021-05-25 21:22:38 -05:00
Alexander Bethel 669f379700 Better abstractions, implement scoping rules 2021-05-25 13:26:01 -05:00
Alexander Bethel 109c77eeb2 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 c27837a807 Slightly more curse 2021-05-24 01:18:36 -05:00
Alexander Bethel b625a71711 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 ea211fc3b0 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 eccc00ff81 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
tdark 1b195dc955 Added support for specifying a tape size limit 2021-05-15 18:39:49 +02:00
tdark 7b5ae34bfd Implemented brainfuck interpreter 2021-05-15 18:10:50 +02:00
able 87139c4448 consider using able brand products 2021-05-05 07:33:40 -05:00
able 9b7367353d Brain fuck work 2021-05-04 22:23:17 -05:00
able bdf27c83da Minor Changes 2021-05-03 19:33:21 -05:00
Erin 72cd540728 Tidy up 2021-05-03 23:02:19 +02:00
Erin 798c1807db Obeyed our paperclip overlord + fmt 2021-05-03 21:36:32 +02:00
Erin 30eedbc854 Fixed some incompatible old code
- Added assignment support
- Reduced boilerplate
- Removed `else`
2021-05-03 21:35:43 +02:00
Erin 29bf01935c Variable assignment implemented 2021-05-03 09:54:27 +02:00
Erin 8c6f415ac9 Fixed #13 2021-05-03 08:47:52 +02:00
Erin 051f6e781f Added tests and loop flow 2021-05-02 18:12:51 +02:00
Erin ecce080378 Added T-Dark block
- obeyed clippy
2021-05-02 17:38:12 +02:00
Erin 5a8dd5051f Parser production ready
- TODO: T-Dark block
- cargo fmt
- Obeyed our clippy overlord
2021-05-02 16:48:33 +02:00
Erin c90d242b0f Parser implements examples
- Function call is now stmt (muhehe)
2021-05-02 15:43:25 +02:00
Erin 18a1343e11 Added basic math operations
- cargo fmt
2021-05-02 00:39:08 +02:00
Erin 3794fd3c8f Divided token types
- Item = Expr | Stmt
- Added REPL (AST dump)
- Removed operator parsing because it was horrible and I need to redo it
2021-05-01 13:44:58 +02:00
Erin eef7ec16fa Tidy up 2021-04-29 19:19:35 +02:00
Erin ca60f818eb Implemented function calls 2021-04-29 18:50:51 +02:00
Erin 17a32a8df7 Bugfix: Peeking
- Fixed `PeekableLexer` next to not-be passtrough to iterator
- Made error handling depend on state of Option
2021-04-29 09:47:29 +02:00
Erin e45afeac5e Added Peekable Lexer
- Added wrapper for Lexer with `peek()` method
- Renamed `token` module to `lexer` as it more describe it's function
- Started work on operator flow
2021-04-28 22:52:19 +02:00
Erin f3779deeb5 Added parsing of conditionals 2021-04-27 13:48:56 +02:00
Erin 3f9e6b72cc Made parser to throw error when unexpected EOF 2021-04-27 11:57:11 +02:00
Erin 39a8bf6a54 Redone original parser
= implemented original features
2021-04-27 11:49:07 +02:00