diff options
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); } |
