diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-09-06 14:47:45 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-09-06 14:47:45 -0400 |
| commit | a8316252db95e3d77f9f0e9beb89cfcb4573d5b1 (patch) | |
| tree | e5905bce9611e35ccb2f84481232fca0e657ff42 /src/parse/text.c | |
| parent | a0ac652cd1eebdc42425b34f1685f8cb20cb4eea (diff) | |
| parent | 73246764f88f6f652316ee0c138a990d836698a7 (diff) | |
Merge branch 'main' into simplified-quotes
Diffstat (limited to 'src/parse/text.c')
| -rw-r--r-- | src/parse/text.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/src/parse/text.c b/src/parse/text.c index 8897fd34..30ff8656 100644 --- a/src/parse/text.c +++ b/src/parse/text.c @@ -148,21 +148,19 @@ ast_t *parse_inline_c(parse_ctx_t *ctx, const char *pos) { spaces(&pos); type_ast_t *type = NULL; - ast_list_t *chunks; if (match(&pos, ":")) { type = expect(ctx, start, &pos, parse_type, "I couldn't parse the type for this C_code code"); spaces(&pos); - chunks = _parse_text_helper(ctx, &pos); - if (type) { - chunks = new (ast_list_t, .ast = NewAST(ctx->file, pos, pos, TextLiteral, Text("({")), .next = chunks); - REVERSE_LIST(chunks); - chunks = new (ast_list_t, .ast = NewAST(ctx->file, pos, pos, TextLiteral, Text("; })")), .next = chunks); - REVERSE_LIST(chunks); - } - } else { - chunks = _parse_text_helper(ctx, &pos); } + static const char *quote_chars = "\"'`|/;([{<"; + if (!strchr(quote_chars, *pos)) + parser_err(ctx, pos, pos + 1, + "This is not a valid string quotation character. Valid characters are: \"'`|/;([{<"); + + char quote = *(pos++); + char unquote = closing[(int)quote] ? closing[(int)quote] : quote; + ast_list_t *chunks = _parse_text_helper(ctx, &pos, quote, unquote, '@', false); return NewAST(ctx->file, start, pos, InlineCCode, .chunks = chunks, .type_ast = type); } |
