summaryrefslogtreecommitdiff
path: root/lex.c
diff options
context:
space:
mode:
authorÁkos Kőrösi <korakos99@gmail.com>2026-05-12 16:28:30 +0200
committerÁkos Kőrösi <korakos99@gmail.com>2026-05-12 16:28:30 +0200
commit89625d33abbdb99659ad6d8fa3df0de0b7a72f10 (patch)
treed26a70c2f342f1f2dcaf3c9847723cbbfba7be51 /lex.c
parent32babee5145bb0248566960a69b674484deb3f94 (diff)
fix bugs in lex/parse, add ugly print util
Diffstat (limited to 'lex.c')
-rw-r--r--lex.c14
1 files changed, 7 insertions, 7 deletions
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++;