Commit Graph

174 Commits

Author SHA1 Message Date
mark
f43ab49408 removed some annoying debug prints 2023-05-27 18:38:33 +02:00
mark
e0f13bdb85 fixed issue https://github.com/Dummi26/mers/issues/1#issue-1728187127 and fixed = vs. := in README. 2023-05-27 18:31:58 +02:00
mark
68c2b52ad7 bugfix: changing the implementation of get() to respect references broke some builtin functions which did not account for this 2023-05-26 21:55:04 +02:00
mark
82f2f028fa fixed line counts ignoring newlines after a // comment 2023-05-26 21:47:47 +02:00
mark
4356858ab2 made syntax cheat sheet a bit clearer 2023-05-26 20:18:09 +02:00
mark
45f6f30de3 revamped switch and match syntax 2023-05-26 20:02:46 +02:00
mark
be9403d63d added destructuring assignments for tuples (and lists on the left) 2023-05-26 18:46:47 +02:00
mark
e766e78e96 updated site + added docs/builtins.md + statements can end with ',' to differentiate '1, -2' from '1 - 2' == '-1'. 2023-05-25 00:22:03 +02:00
mark
b4b33b1c82 added := for initialization/declaration 2023-05-24 22:32:54 +02:00
mark
8e16140b0f fixed oversight 2023-05-24 01:00:42 +02:00
mark
c32419508e fixed examples 2023-05-23 23:56:45 +02:00
mark
9d3a149648 to_runnable treats assignment to a variable as initialization/declaration unless is_ref is true. if the variable doesn't exist yet, it will be created. for custom parser implementations, this means that making all variable assignments ones where is_ref is true will work just fine, but explicit declarations can be done by setting it to false if desired. always leaving it at false will repeatedly shadow the variable, so this isn't recommended although it does work. 2023-05-23 23:30:12 +02:00
mark
1ec7296f50 . 2023-05-23 20:52:48 +02:00
mark
9fd09eff37 fixed order of operations 2023-05-23 20:49:39 +02:00
mark
22b4ace81b added \r and \0 escape sequences 2023-05-23 20:24:32 +02:00
mark
07a443a60b <, <=, > and >= are ordered to happen before == and != instead of defaulting to left-to-right 2023-05-23 19:12:26 +02:00
mark
14d1995d8b add order of operations to the parser ( . | + - | * / % | == != < <= > >= | = ) 2023-05-23 12:20:36 +02:00
mark
7af9902b6a fixed [[2]].0.0 parsing 0.0 as a float, removed get_ref() and made get() return a reference to the inner value if called on a reference to a collection (&[int ...].get(0) returns []/[&int]). 2023-05-23 12:01:27 +02:00
mark
56b457e1b3 add missing file 2023-05-19 21:28:57 +02:00
mark
b5924b5da1 -f+c will print the parsed script with colored highlighting 2023-05-19 21:25:05 +02:00
mark
f2f5af94a7 . 2023-05-18 02:31:04 +02:00
mark
ac8d3befb7 temporarily made cloning actually clone, giving up on CopyOnWrite for now because I kept finding tiny bugs. This might harm performance, but overall performance was bad and will still be bad so who even cares, at least everything kindof works now. 2023-05-18 00:08:28 +02:00
mark
aff55fdc9e changed VData system again, renamed src/script to src/lang and added src/c.mers, which is an example something that currently does not work properly due to the VData implementation (and serves as a reminder to fix the issue) 2023-05-14 00:11:36 +02:00
mark
f8102c8fe6 (maybe?) fixed inner mutability on immutable (shared) values 2023-05-12 15:32:56 +02:00
mark
c501a6e558 fixed bug with function args and custom types 2023-05-12 15:03:20 +02:00
mark
f76ff55401 removed type_syntax.mers test because type force syntax will change (and has been removed for now).
i plan to move it to the statement itself rather than the assignment
2023-05-12 01:02:42 +02:00
mark
bba48b311f changed assignment parser from var = statement to statement = statement
left side of assignments can now be various different things instead of just variables. any statement that returns a reference can be used to assign to the value behind that reference. variables are automatically referenced, so the '&' can be omitted. if the variable contains a reference and that reference should be used, dereference it with *varname instead of just varname.
2023-05-12 00:44:47 +02:00
mark
6f31abd5cc changed VData implementation. It will now always (exception: references) behave like a clone BUT it will avoid cloning whenever possible using Copy-on-Write-style logic. 2023-05-11 14:49:49 +02:00
mark
79b169d951 fixed bug where all but the first loop iterations would write data to the mutable variables from the last iteration(s) even though the variables are supposed to be completely local: is_init can be set on steatements that have an output_to to force them to always redeclare and never reassign the new value. 2023-05-11 01:56:33 +02:00
mark
9ec4acaf70 made custom type names case-insensitive 2023-05-11 01:11:12 +02:00
mark
4efee9e2a2 completely changed the VData/VDataEnum system: Multiple VData can share one VDataEnum via an Arc<Mutex<VDataEnum>>. If one wants to modify the data, it copies it (Copy on Write). This copying is skipped for shared mutable data (references). This was necessary for the get_ref() function. Expect bugs! 2023-05-11 01:04:15 +02:00
mark
ceddb886a9 changed usize/isize static size types from u32/i32 to u64/i64 2023-05-10 20:02:36 +02:00
mark
a7bb3e67fa libraries can now work threaded if they wish (see http_requests). This means that multiple functions provided by one library can run at the same time (using thread(), see http.mers) and actually do the work they need to do simultaneously. 2023-05-09 22:11:13 +02:00
mark
5a8edd9605 update site 2023-05-04 05:42:45 +02:00
mark
4c86897a71 fix nushell_plugins not compiling due to rename of parse module to parsing 2023-05-01 01:05:22 +02:00
mark
77cd1358e6 fixed bad error message if no arguments are provided 2023-04-30 22:41:36 +02:00
mark
b83f54cb2d added basic tests 2023-04-30 22:21:46 +02:00
mark
ca3dd4c798 forgot to add files to last commit. L. 2023-04-30 21:37:13 +02:00
Dummi26
0feb1b8778 added nushell support. 2023-04-30 17:31:50 +02:00
mark
1a446248e4 fixed 'type [custom type] does not fit in [litterally the same type but not custom]' problem 2023-04-29 19:56:54 +02:00
mark
ef5874747e added custom types that can be defined using 'type <name> <type>' 2023-04-29 19:04:38 +02:00
mark
8bafe58593 safety commit because i want to try cargo fix 2023-04-29 16:35:25 +02:00
Dummi26
690a4716fd add missing files 2023-04-29 01:48:06 +02:00
Dummi26
09d0d29138 added macro support, syntax is !(macro-type ...), i.e. !(mers my_file.mers) or !(mers { "value to compute at compile-time".regex("\\S+").assume_no_enum() }) 2023-04-29 01:45:00 +02:00
Dummi26
0a2c67c2d5 changed syntax from var::type to var: type 2023-04-26 22:53:22 +02:00
Dummi26
d9c354685f changed syntax from var::type = statement to var: type = statement 2023-04-26 22:52:31 +02:00
Dummi26
dd017ffea4 added clone() to dereference by cloning 2023-04-26 17:53:25 +02:00
Dummi26
9741fa64cc added thread(t) type to parser 2023-04-26 15:09:59 +02:00
Dummi26
e4ef85a9ea fixed bug with function-iterators 2023-04-26 14:18:57 +02:00
Dummi26
34be9adef2 fixed interactive mode activating on cli arguments that shouldn't activate it. 2023-04-26 13:52:30 +02:00
Dummi26
49f465c444 updated tutor and changed 'while' to 'loop' because while should be while <condition> <statement> while loop is loop <statement>, which is the actual syntax mers uses. 2023-04-25 20:54:35 +02:00
Dummi26
e8ee005743 removed print statement from tutor/mod.rs because it messed with cli editors 2023-04-25 19:43:11 +02:00
Dummi26
89cc7971ee - revamped fmt methods for VData, VType, and some others => value == parse(value.fmtgi(..))
- updated debug() method to output static_type :: dynamic_type :: value
- updated to_string() to output "val" if called on a string (it just uses the fmt methods)
- updated format() to only take strings as arguments
2023-04-25 19:38:00 +02:00
Dummi26
99f8c504a4 tutor 2023-04-25 15:15:21 +02:00
Dummi26
d66a0f37f2 tutor 2023-04-25 15:15:03 +02:00
Dummi26
ca1dbf2722 changed "var type = value" syntax to "var::type = value" and added the tutor (mers -t) 2023-04-25 02:55:16 +02:00
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
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
7a7da1e946 add \n to files that dont end in one to prevent weird errors 2023-04-13 17:51:38 +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
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
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