diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/parse.c | 13 | ||||
| -rw-r--r-- | src/stdlib/tables.c | 11 | ||||
| -rw-r--r-- | src/types.c | 4 |
3 files changed, 10 insertions, 18 deletions
diff --git a/src/parse.c b/src/parse.c index ca6a6af2..d9f06371 100644 --- a/src/parse.c +++ b/src/parse.c @@ -520,14 +520,13 @@ type_ast_t *parse_table_type(parse_ctx_t *ctx, const char *pos) { type_ast_t *parse_set_type(parse_ctx_t *ctx, const char *pos) { const char *start = pos; - if (!match(&pos, "{")) return NULL; + if (!match(&pos, "|")) return NULL; whitespace(&pos); type_ast_t *item_type = parse_type(ctx, pos); if (!item_type) return NULL; pos = item_type->end; whitespace(&pos); - if (match(&pos, ",")) return NULL; - expect_closing(ctx, &pos, "}", "I wasn't able to parse the rest of this set type"); + expect_closing(ctx, &pos, "|", "I wasn't able to parse the rest of this set type"); return NewTypeAST(ctx->file, start, pos, SetTypeAST, .item=item_type); } @@ -706,7 +705,6 @@ PARSER(parse_array) { PARSER(parse_table) { const char *start = pos; - if (match(&pos, "{/}")) return NULL; if (!match(&pos, "{")) return NULL; whitespace(&pos); @@ -768,10 +766,10 @@ PARSER(parse_table) { PARSER(parse_set) { const char *start = pos; - if (match(&pos, "{/}")) + if (match(&pos, "||")) return NewAST(ctx->file, start, pos, Set); - if (!match(&pos, "{")) return NULL; + if (!match(&pos, "|")) return NULL; whitespace(&pos); @@ -780,7 +778,6 @@ PARSER(parse_set) { ast_t *item = optional(ctx, &pos, parse_extended_expr); if (!item) break; whitespace(&pos); - if (match(&pos, "=")) return NULL; ast_t *suffixed = parse_comprehension_suffix(ctx, item); while (suffixed) { item = suffixed; @@ -795,7 +792,7 @@ PARSER(parse_set) { REVERSE_LIST(items); whitespace(&pos); - expect_closing(ctx, &pos, "}", "I wasn't able to parse the rest of this set"); + expect_closing(ctx, &pos, "|", "I wasn't able to parse the rest of this set"); return NewAST(ctx->file, start, pos, Set, .items=items); } diff --git a/src/stdlib/tables.c b/src/stdlib/tables.c index 71b9c7f4..d59bc113 100644 --- a/src/stdlib/tables.c +++ b/src/stdlib/tables.c @@ -588,13 +588,13 @@ public Text_t Table$as_text(const void *obj, bool colorize, const TypeInfo_t *ty Text("}")); else return Text$concat( - Text("{"), + Text("|"), generic_as_text(NULL, false, table.key), - Text("}")); + Text("|")); } int64_t val_off = (int64_t)value_offset(type); - Text_t text = Text("{"); + Text_t text = table.value == &Void$info ? Text("|") : Text("{"); for (int64_t i = 0, length = Table$length(*t); i < length; i++) { if (i > 0) text = Text$concat(text, Text(", ")); @@ -604,14 +604,11 @@ public Text_t Table$as_text(const void *obj, bool colorize, const TypeInfo_t *ty text = Text$concat(text, Text("="), generic_as_text(entry + val_off, colorize, table.value)); } - if (table.value == &Void$info) - text = Text$concat(text, Text("/")); - if (t->fallback) { text = Text$concat(text, Text("; fallback="), Table$as_text(t->fallback, colorize, type)); } - text = Text$concat(text, Text("}")); + text = Text$concat(text, table.value == &Void$info ? Text("|") : Text("}")); return text; } diff --git a/src/types.c b/src/types.c index 29963f76..0b69a8c4 100644 --- a/src/types.c +++ b/src/types.c @@ -370,9 +370,7 @@ PUREFUNC bool can_promote(type_t *actual, type_t *needed) if (actual->tag == ArrayType && needed->tag == ArrayType && Match(actual, ArrayType)->item_type == NULL) return true; // [] -> [T] if (actual->tag == SetType && needed->tag == SetType && Match(actual, SetType)->item_type == NULL) - return true; // {/} -> {T} - if (actual->tag == TableType && needed->tag == SetType && Match(actual, TableType)->key_type == NULL && Match(actual, TableType)->value_type == NULL) - return true; // {} -> {T} + return true; // || -> |T| if (actual->tag == TableType && needed->tag == TableType && Match(actual, TableType)->key_type == NULL && Match(actual, TableType)->value_type == NULL) return true; // {} -> {K=V} |
