Commit Graph

180 Commits

Author SHA1 Message Date
Kayne Ruse
a28053d4e9 Reworked Toy_String as a union, enabled -Wpedantic
Toy now fits into the C spec.

Fixed #158

Addendum: MacOS test caught an error:

error: a function declaration without a prototype is deprecated in all versions of C

That took 3 attempts to fix correctly.

Addendum: 'No new line at the end of file' are you shitting me?
2024-12-15 15:52:06 +11:00
Kayne Ruse
93fce94e9c Locales are hard, sorry!
Fixed #159
2024-12-14 12:57:53 +11:00
Kayne Ruse
7be63c8ccc Added -Wpointer-arith to CFLAGS, read more
I attempted to add '-Wpedantic' to CFLAGS, but it seems that my usage of
the variable length arrays within unions is causing an error that can't
be selectively disabled:

error: invalid use of structure with flexible array member [-Werror=pedantic]

This is the offending code: /source/toy_string.h#L9-L37

It seems that tagged unions, with VLAs within, is simply not allowed.
Unfortunately, my whole string system depends on it. I'll have to find some way
around it.

I've also updated the debugging output in repl/main.c.
2024-12-12 18:23:44 +11:00
Kayne Ruse
cf9affe190 Fixed unused param
Accidentally used a c23 feature.

MacOS runner didn't like that.
2024-12-12 16:23:09 +11:00
Kayne Ruse
fce71a6cda Tweaked CFLAGS, and fixed related errors 2024-12-12 16:18:41 +11:00
Kayne Ruse
5f4dfdccc5 Updated docs and comments 2024-12-11 17:07:49 +11:00
Kayne Ruse
476a79b746 Updated README.md syntax examples 2024-12-10 17:10:09 +11:00
Kayne Ruse
5f75b5f1a3 Allowed for empty arrays and trailing commas 2024-12-10 10:44:13 +11:00
Kayne Ruse
1a36c14247 Expanded array tests, read more
Getting the array's length is still not available yet, so I'm not
marking arrays as done - but everything that is there is tested.

I've also tweaked the assert output callbacks to also print 'assert failure'.
2024-12-09 12:11:31 +11:00
Kayne Ruse
61a105db2d Compound assignment for arrays is working, untested, read more
I added reference values in 62ca7a1fb7,
but forgot to mention it. I'm now using references to assign to the
internals of an array, no matter how many levels deep it is.
2024-12-07 15:35:06 +11:00
Kayne Ruse
2324150fd5 Update CODE_OF_CONDUCT.md 2024-12-07 07:43:28 +11:00
Kayne Ruse
03dce296cb Assignment target is now an AST node
This will make assigning to arbitrary targets easier.
2024-12-04 19:24:58 +11:00
Kayne Ruse
62ca7a1fb7 WIP: Implementing arrays into the script, read more
I had intended to solve the Advent of Code puzzles in Toy, but they
don't work without arrays. I wasn't able to enable arrays in time, so
I need to focus on doing things correctly.

The most immediate tasks are marked with 'URGENT', and a lot of tests
need writing.
2024-12-02 11:58:03 +11:00
Kayne Ruse
12c6ac938c WIP: tests incomplete 2024-11-30 12:50:46 +11:00
Kayne Ruse
58cecafb3b WIP: Adding arrays to value structure, tests incomplete 2024-11-29 12:17:54 +11:00
Kayne Ruse
bb2e85e350 Updated README.md 2024-11-29 12:16:10 +11:00
Kayne Ruse
431893bf60 WIP: Started on break & continue, needs Toy_Array in Toy_Value first 2024-11-28 13:43:26 +11:00
Kayne Ruse
6cc331d462 While is working but untested, read more
* TODO: break and continue keywords need to be implemented
* TODO: while-then needs testing
* Fixed the parser not liking zero-length strings
2024-11-26 14:48:24 +11:00
Kayne Ruse
0947430c29 Finished if-then-else tests, finally. 2024-11-26 11:30:28 +11:00
Kayne Ruse
1695f9d1c9 Found and fixed a bug in the parser 2024-11-23 15:43:31 +11:00
Kayne Ruse
79c4374a1f Make sure this test works without scope braces too 2024-11-23 13:41:02 +11:00
Kayne Ruse
37fb3927a6 Implemented some tests, not finished yet
* parser compounds
* routine keyword assert
2024-11-23 10:45:19 +11:00
Kayne Ruse
0b559ecb74 Fixed the lines marked as 'URGENT' 2024-11-23 10:07:05 +11:00
Kayne Ruse
7d4ea4881f WIP: Fixed print bug, tests incomplete, read more
I was sidetracked by a strange display bug - turns out it was caused by
pointers - this commit fixes it.

The tests for if-then-else still aren't finished, but I'm knocking off
as it's past my time limit. I've marked 'TODO' and 'URGENT' using
comments, so finding the issues should be easy.
2024-11-22 18:21:47 +11:00
Kayne Ruse
b29a87840d EMERGENCY: Computer is dying, this is an incomplete commit, do not use 2024-11-22 15:48:44 +11:00
Kayne Ruse
b2b2ca7e53 If-then-else is working, untested 2024-11-20 12:50:27 +11:00
Kayne Ruse
34577ecfe1 WIP: if-then-else, incomplete 2024-11-19 17:14:39 +11:00
Kayne Ruse
7398898a61 Added valgrind to the CI, fixed tests
This exposed an issue with my dev environment, which I had to patch.

Fixed #153
2024-11-17 18:49:40 +11:00
Kayne Ruse
2f9489d5fd Fixed a 'malformed assignment' issue, read more
I've also added some support for compiler errors in general, but these
will get expanded on later.

I've also quickly added a valgrind option to the tests and found a few
leaks. I'll deal with these later.

Summary of changes:

* Clarified the lifetime of the bytecode in memory
* Erroneous routines exit without compiling
* Empty VMs don't run
* Added a check for malformed assignments
* Renamed "routine" to "module" within the VM
* VM no longer tries to free the bytecode - must be done manually
* Started experimenting with valgrind, not yet ready
2024-11-16 21:02:37 +11:00
Kayne Ruse
04f0653595 Planned control flow statements 2024-11-16 17:57:51 +11:00
Kayne Ruse
cd2113594d Fixed a call when using print keyword 2024-11-12 22:23:34 +11:00
Kayne Ruse
be7e4ddd18 Reworked the tests, read more
I've brought the tests up to scratch, except for compounds im the
parser, because I'm too damn tired to do that over SSH. It looks like
collections are right-recursive, whixh was unintended but still works
just fine.

I've also added the '--verbose' flag to the repl to control the
debugging output.

Several obscure bugs have been fixed, and comments have been tweaked.

Mustfail tests are still needed, but that's a low priority. See #142.

Fixed #151
2024-11-12 22:04:07 +11:00
Kayne Ruse
b74aa63c1c Added verbose debugging option to the REPL 2024-11-12 11:16:50 +11:00
Kayne Ruse
935993ee8a Adding discord webhook 2024-11-11 19:17:07 +11:00
Kayne Ruse
436bd3ffca Added silent cmd args
Fixed #145
2024-11-10 10:27:50 +11:00
Kayne Ruse
1608a13b43 Implemented assert keyword, read more
The assert keyword works, but I want to add a cmd option to suppress or
disable the errors.

The tests need some serious TLC. I know that, but I'm kicking it down
the road for now.
2024-11-09 17:41:29 +11:00
Kayne Ruse
1925d41940 Added indexing to strings, tests still needed 2024-11-09 13:10:54 +11:00
Kayne Ruse
5588986042 Tweaked file locations
Also altered the commit message, because there was a weird character in
it.
2024-11-03 12:10:39 +11:00
Kayne Ruse
32727f986c Benchmarked and tweaked Toy_Table, read more
I read the DOOM 1 source code and found a neat trick to replace modulo.

YOINK!!!
2024-11-02 21:29:13 +11:00
Kayne Ruse
92955d56dd Added a nice error message 2024-11-02 14:39:59 +11:00
Kayne Ruse
ef72415c21 Updated README 2024-11-02 11:52:54 +11:00
Kayne Ruse
7173f7770f Added types and constness
Fixed #144
2024-11-02 11:39:47 +11:00
Kayne Ruse
3ad53c5e0e Tweaked README 2024-10-31 14:54:46 +11:00
Kayne Ruse
3cb2132bfa Escaped characters stored in strings correctly
Fixed #147
2024-10-30 21:13:57 +11:00
Kayne Ruse
feab02e790 Fixed a test's return value
Only one platform caught this?
2024-10-30 21:00:02 +11:00
Kayne Ruse
163c8aa7f6 Fixed a printf format issue 2024-10-30 20:52:52 +11:00
Kayne Ruse
d19ca1bcee Reworked variable equality and comparisons
Fixed #146
2024-10-30 19:58:55 +11:00
Kayne Ruse
b30a092ab8 Added more reserved words 2024-10-27 18:07:52 +11:00
Kayne Ruse
e3bb7c0d25 Renamed a macro 2024-10-27 14:19:28 +11:00
Kayne Ruse
c5206daaea Implemented scopes 2024-10-27 13:44:09 +11:00