92dc89d3ca
Move {=>apfl_}print_indented out of expr.c
...
We'll soon need it elsewhere.
2022-01-02 16:53:26 +01:00
f685214abe
Add apfl_string_eq macro
...
It's easy to forget the `== 0` after the apfl_string_cmp() call, so let's
add a macro that does the job for us.
2022-01-02 16:51:19 +01:00
002894a960
Add a logo :)
2022-01-02 16:45:21 +01:00
74e43e61ce
Parser: Clean up more things and make sure to not deinit uninitialized data
2021-12-19 00:28:35 +01:00
8d1eaf5d78
Add tests for some parsing errors
2021-12-19 00:27:34 +01:00
0995739ca8
Parser: Do a better job at cleaning up temporary allocations
...
-fsanitize=memory no longer finds any memory leak in the parser test suite.
We don't yet test error cases, but still pretty good :).
2021-12-18 21:42:48 +01:00
d312500a5b
parser: Remove useless result var in parse_fragment
...
Was always PF_OK
2021-12-18 21:39:09 +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
54f27e448c
Parser: Skip inner bracket separators after every list element
...
Forgot that here.
2021-12-18 16:12:21 +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
bde841120a
test.h: Make test functions static
...
This makes the compiler complain about a test that was not registered with
ADDTEST.
2021-12-18 16:09:03 +01:00
e3369d8a32
Add more parser tests
2021-12-17 21:08:03 +01:00
4908386435
expr: Also print position on variables and constants
2021-12-17 21:07:45 +01:00
fd24623c27
parser: Set the position of a call to the open parenthesis
2021-12-17 21:07:12 +01:00
3469623fee
Add first parser test cases
2021-12-16 23:42:37 +01:00
10a99d0b1e
expr: Fix silly bug in equality check
2021-12-16 23:42:11 +01:00
84f127bfec
Move must_alloc into test.h
2021-12-16 22:50:14 +01:00
025fd61abd
Add apfl_string_source_reader
...
A useful source reader implementation to pass in a source saved as an
in-memory string into the tokenizer.
This replaces the string_src_reader in the tokenizer_test and is even a bit
more flexible, by allowing any aplf_string_view as the source.
2021-12-16 22:49:41 +01:00
e79945a398
Continue work on parser
...
- Simplify return types: Many functions that returned
`enum parse_fragment_result` only ever returned PF_OK or PF_ERROR.
Changing these functions to return bool simplifies things a lot. This
also helped in identifying some places where I didn't handle all
parse_fragment_result values properly.
- More cleaning up
- Allow linebreaks inside parenthesis
2021-12-16 22:09:59 +01:00
d853ba40ad
parser: Fix parsing assignments
2021-12-16 22:09:59 +01:00
86e1c1339d
strings: Also reset length when moving a string
2021-12-16 22:09:59 +01:00
c0e47b14e6
Add tokenizer test case
...
During development on the parser I got a "malloc(): corrupted top size"
error in the tokenizer when parsing `a=a`. I wrote this test to see if it
was really a problem with the tokenizer. It wasn't, lets keep the test
nontheless.
2021-12-16 22:09:59 +01:00
808219f9c7
expr: Fix printing assignments
2021-12-15 23:11:54 +01:00
c288c333ca
Continue work on parser
...
Seems that we can parse most things now :). Assignments don't work yet,
thoug. Also we're currently leaking memory pretty badly.
2021-12-15 21:47:17 +01:00
af33887131
internal: Fix list deinitialization
2021-12-15 21:47:17 +01:00
fd3c5702ca
expr: More consistent and easier to read printing
2021-12-15 21:47:17 +01:00
ade0972d67
expr: Fix moving listlike structures
2021-12-15 21:47:17 +01:00
f907461b90
resizable: Fix capacity growing
2021-12-15 21:47:17 +01:00
09d51b9080
Parser: Make the parser object own the token
...
This simplifies the code a bit, since the methods now don't have to deinit
the token themselves any more.
2021-12-15 21:47:17 +01:00
d094ed7bd5
Initial commit
2021-12-15 21:47:17 +01:00