Commit graph

13 commits

Author SHA1 Message Date
50cd2c18d2 expr+parser: Restrict what an assignable can be
If you assign into a member access (`foo.bar = baz` or `foo@bar = baz`), it
is no longer permitted that the LHS of the at/dot is an arbitrary
assignable. It now must be a variable, at or dot. This disallows some silly
constructs (e.g. `[foo]@bar = baz`), increases the similarity to function
parameters and should make writing the evaluation code for these more easy.
2022-01-08 23:06:22 +01:00
4eea93ff97 Improve AST representation of expansion in assignables / parameters
The previous representation didn't properly model the fact that an
assignable / parameter can only be expanded, if it's a list element. This
now better models this. Other than being more correct, this should also
make evaluating these a bit easier.

While I was at it, I also improved the error message for multiple
expansions on the same level and added tests for these.
2022-01-07 23:08:25 +01:00
76f3c776a0 Add parser tests for function calls 2022-01-06 22:50:14 +01:00
7903686fe7 Parser: Fix not setting error when -> is missing in dictionaries 2022-01-05 21:50:50 +01:00
eea7e8f840 strings: Add apfl_string_blank() and doucment apfl_string_copy()
It's really easy to accidentally pass an uninitialized string as dst into
the copy function, which will result in an free() call to an arbitrary
pointer. Maybe it's a better idea to not deinit the dst string before
copying? The documentation at least makes it more clear and the new
apfl_string_blank() function makes it easy to create an empty string.
2022-01-02 17:01:51 +01:00
8d1eaf5d78 Add tests for some parsing errors 2021-12-19 00:27:34 +01:00
c74bd74bda Add another parser test 2021-12-18 17:06:17 +01:00
3759813ed9 Parser tests: Make LIST_* macros type safe
With the varargs approach that was used before, it was very easy to add a
list item of the wrong type, which would (hopefully) result in an assertion
violation, because va_arg() then read some senseless data.
2021-12-18 16:35:18 +01:00
5712d7f4ff Add more parser tests 2021-12-18 16:12:37 +01:00
632687b47d Parser tests: Add helpers for creating consts 2021-12-18 16:11:23 +01:00
1ba891282e Parser test: Fix error message when encountering an error 2021-12-18 16:09:53 +01:00
e3369d8a32 Add more parser tests 2021-12-17 21:08:03 +01:00
3469623fee Add first parser test cases 2021-12-16 23:42:37 +01:00