Commit Graph

265 Commits

Author SHA1 Message Date
Dummi26
7baa1c2aba removed some temporary eprints 2023-04-24 16:27:42 +02:00
Dummi26
9c1564b426 added var_name var_type = statement syntax, which forces the statements return type to fit in var_type. This is useful if your initial value doesn't cover all types (like [ ...], which is a list with an inner type that cannot exist because there are 0 valid types, making the list completely useless. but arr [int/string ...] = [] expands that inner type to int/string, making the list usable) 2023-04-24 15:55:37 +02:00
Dummi26
14d004d848 added dereferences to assignments: x = 1 y = &x *y = 2 x.debug() will print 2 because we changed x through the reference. 2023-04-24 13:49:20 +02:00
Dummi26
ed8aecde86 added support for shebangs: if the file starts with "#!", the first line will be ignored. 2023-04-20 19:37:29 +02:00
Dummi26
5bb4d2e4a5 readme claimed &statement was valid, but it isn't. now it correctly states that &varname must be used to get a reference. 2023-04-19 16:16:34 +02:00
Dummi26
2fc3d52626 update readme to include the correct fn type syntax and fixed an example where list types didn't use ... yet. 2023-04-19 16:13:45 +02:00
Dummi26
2ac19dcd00 added iterators: any function that takes no arguments can be used in a for loop. Each iteration, it will be called once. If its value matches, the for loop will execute its block with that value. If the value doesn't match, the for loop will stop. This also required adding function types: fn((input11 input12 output1) (input21 input22 output2)). The type maps inputs to outputs, because the add function isn't add(int/float int/float) -> int/float, but rather add((int int int) (int float float) (float int float) (float float float)) (notice that add(int int) can't return float and any other add can't return ints). 2023-04-19 15:40:05 +02:00
Dummi26
2293e9365c added boolean functions not(a), and(a v) and or(a b). and and or are short-circuiting. 2023-04-19 14:32:30 +02:00
Dummi26
ea5346f81c fixed a bug where the character directly following a float literal would be ignored (because parsing the float accidentally used that character). this is what caused [12.5] to break. 2023-04-15 16:01:34 +02:00
Dummi26
c484d2cbb2 fixed parser infinite looping because parse_function() on a function with no args (fn my_func() {}) would break before the ')'. 2023-04-15 15:41:07 +02:00
Dummi26
65fdc87c01 added more accurate type-checking to some of the builtins 2023-04-15 14:41:52 +02:00
Dummi26
effdc096a2 implemented working float literals and removed the 5,2 workaround: 5.2 is now a float! (see 10.5.debug()).
this was an issue for so long because it requires an exception to the usual dot syntax, and exceptions can be dangerous. So if there is an issue, you can resort to { 10.5 }.something() or { 10 }.5 (although this doesn't make sense) to convince the parser to do what you want.
2023-04-15 14:22:41 +02:00
Dummi26
b2a36416cf implemented better errors (not finished). this also prevents crashes (because there were todo!()s and panic!()s as temporary errors before) when an error is found while in interactive mode. 2023-04-14 20:47:13 +02:00
Dummi26
dfd83fa581 fixed warnings in mers, but one warning in parse.rs will stay 2023-04-14 17:10:54 +02:00
Dummi26
c526912ecb fixed typo 2023-04-13 22:47:18 +02:00
Dummi26
699c0081aa removed mers_libs/*/Cargo.lock 2023-04-13 17:55:18 +02:00
Dummi26
7a7da1e946 add \n to files that dont end in one to prevent weird errors 2023-04-13 17:51:38 +02:00
Dummi26
52be3d04f0 fixed small issue in readme 2023-04-13 17:45:52 +02:00
Dummi26
a2a976c7f9 - changed the list type from [t] to [t ...]
- added more examples to the readme
2023-04-13 17:40:25 +02:00
Dummi26
a6389b7ac0 added -e flag to readme 2023-04-13 04:23:29 +02:00
Dummi26
233590ead3 added -e: mers -e println("you don't need a file for this") 2023-04-13 04:21:15 +02:00
Dummi26
765a2597ee added thread example and made small changes to the readme 2023-04-13 04:04:48 +02:00
Dummi26
c2362aca13 fixed small issue in readme 2023-04-13 03:27:51 +02:00
Dummi26
ce61749260 - Added assume_no_enum() because the Err enum is used at least as often as [] for reporting fails.
- changed substring(a b) behavior from "b is the max length of the resulting string" to "b is the exclusive end index, unless it is negative, in which case its abs() value is the maximum length".
- fixed a bug in libs/path
- added the http_requests library, which can be used to make very basic GET requests
- fixed a bug in the gui library that would mess up button handling
- you can now escape comments using a backslash `\`: \// will turn into the literal //, \/* will turn into the literal /*. Useful for URLs (because comments work in string literals). Putting a backslash before a linebreak will also ignore that linebreak (useful in long string literals)
2023-04-13 03:04:47 +02:00
Dummi26
2acdcd3f53 moved Cargo.toml and src/ to /mers/Cargo.toml and /mers/src/ because rust-analyzer was apparently very confused when I was trying to edit projects in mers_libs/*/. 2023-04-12 22:23:07 +02:00
Dummi26
5b051e72f1 improved the mers library system
added a GUI library wrapping iced-rs, mainly to test the limits of the current library system.

see gui.txt for an example on how to use the gui library. (note: set the MERS_LIB_DIR environment variable to the path of your local mers_libs/ folder (lib paths are relative to MERS_LIB_DIR if they're not specified as absolute))
2023-04-04 23:48:01 +02:00
Dummi26
38d641ffcd updated readme 2023-04-01 20:39:18 +02:00
Dummi26
fd32fd2ba7 updated readme 2023-04-01 20:30:34 +02:00
Dummi26
3dea550565 . 2023-04-01 16:29:46 +02:00
Dummi26
794e776e25 changed enum type syntax because A: int/string is ambiguous while A(int)/string and A(int/string) aren't. Builtins now use the Err enum variant for errors. 2023-04-01 16:27:52 +02:00
Dummi26
b1a90d5872 implemented enum functionality. todo: default functions should use Ok/Err enum variants? 2023-04-01 14:38:46 +02:00
Dummi26
260e42d4a7 changed while loop break to use matching (any matching value breaks) and added the same break functionality to for loops. 2023-03-30 19:11:21 +02:00
Dummi26
52973eb0f8 changed remove and pop to return [] or [v] instead of [] or v to remove the ambiguity when successfully returning v with v = []. This also makes .assume1() work with these functions. 2023-03-30 18:46:45 +02:00
Dummi26
2ba1ed270d changed get to return [] or [v] instead of [] or v because v might be []. This also matches the 0-or-1-length-tuple patterns for optionals (so it can be unwrap()d using .assume1()). 2023-03-30 18:38:05 +02:00
Dummi26
45186e3803 parser bugfix, started working on external libraries (libraries can register functions and react to function calls via stdout/stdin) 2023-03-24 14:57:42 +01:00
Dummi26
296163d5fe added examples 2023-03-22 19:37:21 +01:00
Dummi26
2c12556af9 fixed compiler errors 2023-03-22 19:23:18 +01:00
Dummi26
744f268bfd added some string methods and assume1, which takes ([]/[t]) or ([]/[t] string) and returns t. If the first argument passed is [] instead of [t], panics with the custom error message, if one was provided (string argument). 2023-03-22 19:20:02 +01:00
Dummi26
2a00d01812 fixed a bug with while loops running unreachable!() code instead of looping on [] values. 2023-03-17 17:05:19 +01:00
Dummi26
021a247369 update readme 2023-03-17 16:56:55 +01:00
Dummi26
fff0b868ce added files and fixed a bug in run() and thread() 2023-03-17 16:54:27 +01:00
Dummi26
04b9cbc4c7 fixed readme issue 2023-03-17 16:33:23 +01:00
Dummi26
6712097829 added match statements. 2023-03-17 16:29:42 +01:00
Dummi26
664de5c347 cleaned up script/value.rs by splitting it up into val_data and val_type. 2023-03-17 14:23:54 +01:00
Dummi26
a43a23da8c - added type-checking for builtins. Except for the List-functions, all builtins should now be properly type-checked.
- changed List.insert(..) from (list, index, element) to (list, element, index) to be more in line with List.push(list, element)
2023-03-16 15:33:43 +01:00
Dummi26
585017da46 improved and fixed some bugs with the switch! unhandled type error and some builtins 2023-03-14 20:58:35 +01:00
Dummi26
1b43dfebda fixed bug where the last item in a list would break the parser if it wasn't followed by a whitespace, ), or }. (added ] to the list of statement-breaking chars) 2023-03-14 20:21:36 +01:00
Dummi26
862418ce98 almost functional type checking for builtins; builtins return types work
as expected now (for List.get, Thread.await() etc)
2023-03-14 20:14:30 +01:00
Mark
5ca0373640
(2) 2023-03-14 12:42:39 +01:00
Mark
5d868a759d
basis for type-checked builtins (1) 2023-03-14 12:40:15 +01:00