From d4b10514fbe3afc7229efe74b015a664b52eba33 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sun, 24 Nov 2024 16:36:27 -0500 Subject: Clean up some more null->none renames and fix the documentation. Also change the literal syntax to `NONE:T` instead of `!T` --- parse.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'parse.c') diff --git a/parse.c b/parse.c index b1d9f739..d92df34d 100644 --- a/parse.c +++ b/parse.c @@ -116,7 +116,7 @@ static PARSER(parse_lang_def); static PARSER(parse_namespace); static PARSER(parse_negative); static PARSER(parse_not); -static PARSER(parse_null); +static PARSER(parse_none); static PARSER(parse_num); static PARSER(parse_parens); static PARSER(parse_pass); @@ -1530,14 +1530,17 @@ PARSER(parse_lambda) { return NewAST(ctx->file, start, pos, Lambda, .id=ctx->next_lambda_id++, .args=args, .ret_type=ret, .body=body); } -PARSER(parse_null) { +PARSER(parse_none) { const char *start = pos; - if (match_word(&pos, "NONE")) - return NewAST(ctx->file, start, pos, Null, .type=NULL); - if (!match(&pos, "!")) return NULL; + if (!match_word(&pos, "NONE")) + return NULL; + + if (!match(&pos, ":")) + return NewAST(ctx->file, start, pos, None, .type=NULL); + type_ast_t *type = parse_type(ctx, pos); if (!type) return NULL; - return NewAST(ctx->file, start, type->end, Null, .type=type); + return NewAST(ctx->file, start, type->end, None, .type=type); } PARSER(parse_var) { @@ -1553,7 +1556,7 @@ PARSER(parse_term_no_suffix) { (void)( false || (term=parse_moment(ctx, pos)) // Must come before num/int - || (term=parse_null(ctx, pos)) + || (term=parse_none(ctx, pos)) || (term=parse_num(ctx, pos)) // Must come before int || (term=parse_int(ctx, pos)) || (term=parse_negative(ctx, pos)) // Must come after num/int -- cgit v1.2.3