From 89625d33abbdb99659ad6d8fa3df0de0b7a72f10 Mon Sep 17 00:00:00 2001 From: Ákos Kőrösi Date: Tue, 12 May 2026 16:28:30 +0200 Subject: fix bugs in lex/parse, add ugly print util --- lex.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'lex.c') diff --git a/lex.c b/lex.c index 8ffb2a8..8c64751 100644 --- a/lex.c +++ b/lex.c @@ -31,7 +31,6 @@ TokenVec lex_level(RawLine* line, char until, RegionVec* reg_arena); void expect_char(RawLine* line, char expected) { if (line->str[line->pos] != expected) { - printf("Expected %c, got %c.", expected, line->str[line->pos]); exit(45); // TODO: nicer handling } line->pos++; @@ -86,7 +85,7 @@ MaybeChunk lex_expansion_chunk(RawLine* line, RegionVec* reg_arena, QuotationMod .value = (Chunk){ .qmode = qmode, .kind = VAR_EXP, - .as.varname = inner(id_name), + .as.varname = inner(&id_name), } }; } @@ -118,7 +117,7 @@ void lex_double_quoted_section(RawLine* line, Word* coll, RegionVec* reg_arena) push_to_Word(coll, (Chunk){ .qmode = DOUBLE_Q, .kind = LITERAL, - .as.literal_str = inner(accum) + .as.literal_str = inner(&accum) }); accum = make_String(256); } @@ -131,7 +130,7 @@ void lex_double_quoted_section(RawLine* line, Word* coll, RegionVec* reg_arena) push_to_Word(coll, (Chunk){ .qmode = DOUBLE_Q, .kind = LITERAL, - .as.literal_str = inner(accum) + .as.literal_str = inner(&accum) }); } } @@ -142,7 +141,7 @@ Chunk next_word_unquoted(RawLine* line, RegionVec* reg_arena) { for (char c; (c=line->str[line->pos], c != '$' && c != '\0' && c != ' '); line->pos++) { push_to_String(&buf, c); } - return (Chunk){.qmode = UN_Q, .kind = LITERAL, .as.literal_str = inner(buf)}; + return (Chunk){.qmode = UN_Q, .kind = LITERAL, .as.literal_str = inner(&buf)}; } @@ -157,7 +156,7 @@ Chunk collect_single_quoted_section(RawLine* line) { return (Chunk){ .qmode = SINGLE_Q, .kind = LITERAL, - .as.literal_str = inner(chunk_str), + .as.literal_str = inner(&chunk_str), }; } @@ -176,7 +175,7 @@ void close_literal_germ(LexState* state) { (Chunk){ .qmode = UN_Q, .kind = LITERAL, - .as.literal_str = inner(state->unq_liter_germ) + .as.literal_str = inner(&state->unq_liter_germ) } ); state->unq_liter_germ = make_String(256); @@ -201,6 +200,7 @@ TokenVec lex_level(RawLine* line, char until, RegionVec* reg_arena) { while (line->str[line->pos] != until) { + if (line->str[line->pos] == ' ') { close_word_and_lit_germs(&state); while (line->str[line->pos] == ' ') line->pos++; -- cgit v1.2.3