Commit graph

11 commits

Author SHA1 Message Date
ae45aeebe2 parser+expr: Handle blank identifier (_) 2022-01-08 23:20:29 +01:00
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
ac3af0baf1 apfl_ctx_destroy: Do nothing on NULL input 2022-01-08 22:09:43 +01:00
e928f40da4 Implement simple variable support
We can now assign to variables and retrieve their values. Not all
assignables are implemented yet, but still pretty cool :).
2022-01-06 22:53:26 +01:00
721d2d2d21 Implement evaluating container member access 2022-01-05 00:25:41 +01:00
0384875ef3 values: Split lists into read-only lists and editable lists
This is analogous to dictionaries and ensures that no circular references
can be created when using the exported API in apfl.h.

This also changes apfl_value_copy into apfl_value_incref to better reflect
what it does and to reflect that it is no longer an operation that can
fail.
2022-01-04 23:11:38 +01:00
f3d0bbed17 Implement evaluating dictionary literals
We can now have dictionaries with keys and values of arbitrary types.
Very cool! :)
2022-01-04 21:51:44 +01:00
eaa6b723bc Fix refcounted strings
Increasing the refcount (confusingly called copy before, fixed that too)
didn't work properly, as the object was copied and the refcount was only
updated in one of the copies.
2022-01-04 21:22:46 +01:00
4cd95d32c5 eval.c: Handle errors during evaluating string constants 2022-01-02 21:20:08 +01:00
b29219af25 Make strings in apfl_value refcounted
This avoids copying the string every time we pass it around. Not too
important right now, but will become important onve we're able to evaluate
more complex expressions.
2022-01-02 17:55:44 +01:00
649607ce50 Start work on evaluating expressions
Right now we're only evaluating bool/nil/number/string/list literals, but
it's a start :).
2022-01-02 17:22:22 +01:00