diff options
author | Bad Diode <bd@badd10de.dev> | 2022-04-03 18:54:51 -0300 |
---|---|---|
committer | Bad Diode <bd@badd10de.dev> | 2022-04-03 18:54:51 -0300 |
commit | c8b53cb4590d8d6cbfc5cbf891809ddd99e33fe5 (patch) | |
tree | 716f3676abb4a777add1683390cfc37a605fe911 /src/errors.c | |
parent | 496ec36c8002a85dc0c3bb62de6d176e369b40af (diff) | |
download | bdl-c8b53cb4590d8d6cbfc5cbf891809ddd99e33fe5.tar.gz bdl-c8b53cb4590d8d6cbfc5cbf891809ddd99e33fe5.zip |
Add parsing for function definitions
This commits also changes the structure of some existing functions.
Namely, parse_* functions other than parse_next check that the type of
the token to parse is correct. This allow us to use them directly in the
rest of the code to consume tokens and properly produce an error if the
token type is not the expected one.
In the same fashion, two new functions consume_lparen and consume_rparen
are implemented. They only report true/false and report errors if
something went wrong.
Diffstat (limited to 'src/errors.c')
-rw-r--r-- | src/errors.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/errors.c b/src/errors.c index e69e4f9..b93b462 100644 --- a/src/errors.c +++ b/src/errors.c | |||
@@ -8,6 +8,13 @@ static const char* error_msgs[] = { | |||
8 | [ERR_MALFORMED_NUMBER] = "error: malformed number token", | 8 | [ERR_MALFORMED_NUMBER] = "error: malformed number token", |
9 | [ERR_MALFORMED_EXPR] = "error: malformed expression", | 9 | [ERR_MALFORMED_EXPR] = "error: malformed expression", |
10 | [ERR_UNIMPLEMENTED] = "error: not implemented", | 10 | [ERR_UNIMPLEMENTED] = "error: not implemented", |
11 | [ERR_NOT_A_NUMBER] = "error: expected a number", | ||
12 | [ERR_NOT_A_SYMBOL] = "error: expected a symbol", | ||
13 | [ERR_NOT_A_STRING] = "error: expected a string", | ||
14 | [ERR_NOT_A_TYPE] = "error: expected a type", | ||
15 | [ERR_NOT_A_BOOL] = "error: expected a bool", | ||
16 | [ERR_NOT_A_LPAREN] = "error: expected opening parentheses (lparen)", | ||
17 | [ERR_NOT_A_RPAREN] = "error: expected closing parentheses (rparen)", | ||
11 | }; | 18 | }; |
12 | 19 | ||
13 | static Error current_error = {.value = ERR_OK}; | 20 | static Error current_error = {.value = ERR_OK}; |