Commit graph

105 commits

Author SHA1 Message Date
Alex Bethel 66d4f4f82d 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 75938f27c0 Implement functio declaration & calling 2021-06-15 09:51:00 -05:00
HTG-YT aa72945010 comply with the move of rickroll 2021-06-14 20:53:27 +08:00
HTG-YT 26df745dee move rickroll to src/ folder 2021-06-14 20:52:38 +08:00
HTG-YT b526d5c575 move rickroll content into a file 2021-06-14 09:42:23 +08:00
HTG-YT 72e48d1b86 rustfmt: add trailing comma 2021-06-14 09:40:42 +08:00
HTG-YT 227fa8e35b handle Token::Rickroll in parser 2021-06-13 13:24:09 +08:00
HTG-YT fa0d3968f5 Update interpret.rs 2021-06-13 13:22:30 +08:00
HTG-YT 3646c5e32e handle StmtKind::Rickroll 2021-06-13 13:22:01 +08:00
HTG-YT 286a12b28e add StmtKind::Rickroll 2021-06-13 13:11:51 +08:00
HTG-YT 855383faac add rickroll lexeme in lexer 2021-06-13 13:11:02 +08:00
Alex Bethel 976518a251 Reimplement BF function declaration semantics 2021-06-12 09:26:21 -05:00
Erin ff04c34cf6 Better comment 2021-06-11 19:44:53 +02:00
Erin 183c584e96 Removed todo when unknown token 2021-06-11 18:34:34 +02:00
Erin 3d7c89634e Fixed invalid spanning of UnexpectedToken in parse_expr 2021-06-11 18:31:25 +02:00
Erin 3bcef28843 BF code is now Vec<u8> 2021-06-11 18:10:11 +02:00
Erin 711ad27e00 Basic BfFunctio support 2021-06-11 17:52:47 +02:00
Alex Bethel 41316f5696 Re-enable assignment semantics 2021-06-11 10:05:48 -05:00
Erin 6f16d2594b Added variable assignment to parser
- Fixed parse error, that `rlyeh` returned HopBack
2021-06-11 16:59:40 +02:00
HTG-YT dd28ff985f add nevergonnagiveyouup constant 2021-06-11 15:26:30 +08:00
HTG-YT 77749bc32b add interessant and funny constants 2021-06-11 15:19:27 +08:00
Alex Bethel 7d7c1e4a1b Fix interpreter variable persistence bug 2021-06-08 19:21:33 -05:00
Alex Bethel dc5ef63fef 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 a0c1f93392 Remove 0..0 placeholder from unexpected_eof() 2021-06-07 20:03:26 -05:00
Alex Bethel ce20611c07 Fix all 0..0 span placeholders in interpret.rs 2021-06-07 19:57:44 -05:00
Alex Bethel d8f462e0b5 Fix unit tests 2021-06-07 17:35:49 -05:00
Alex Bethel addda8fc87 Remove giant comment block left in by mistake 2021-06-07 16:28:27 -05:00
Alex Bethel 426aee6a2b Repair interpreter after parser changes 2021-06-07 16:20:20 -05:00
Erin 903b1a3809 Added T-Dark test 2021-06-07 23:06:13 +02:00
Erin 8bd61a4a65 Added tests, Bugfix
- Originally, it spanned from operator (bug)
2021-06-07 22:58:28 +02:00
Erin 1f78cb0ee1 Added missing mut 2021-06-07 22:24:43 +02:00
Erin 902d8b914c Unified span terminology
- Add more derivations, because it's required by another parts of project
2021-06-07 22:21:21 +02:00
Erin f893e24aed Changed position terminology 2021-06-07 21:28:24 +02:00
Erin 2084ebeed1 Removed unwraps, added Rlyeh 2021-06-07 11:07:50 +02:00
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