diff options
| author | Ákos Kőrösi <korakos99@gmail.com> | 2026-05-12 15:14:24 +0200 |
|---|---|---|
| committer | Ákos Kőrösi <korakos99@gmail.com> | 2026-05-12 15:14:24 +0200 |
| commit | 32babee5145bb0248566960a69b674484deb3f94 (patch) | |
| tree | 8180b6a10b0c8b20bacd4d63bebe4fd731014f75 | |
| parent | ce7bc08b1db6011a82b27dbccf4e5502b948a820 (diff) | |
fixes
| -rw-r--r-- | lex.c | 8 | ||||
| -rw-r--r-- | main.c | 3 | ||||
| -rw-r--r-- | parse.c | 4 | ||||
| -rw-r--r-- | parse.h | 5 |
4 files changed, 15 insertions, 5 deletions
@@ -214,6 +214,11 @@ TokenVec lex_level(RawLine* line, char until, RegionVec* reg_arena) { case '\"': lex_double_quoted_section(line, &state.word_germ, reg_arena); break; + case '|': + line->pos++; + close_word_and_lit_germs(&state); + push_to_TokenVec(&state.tokens, (Token){.kind = TOK_SPECIAL, .as.spec = PIPE}); + break; case '$': line->pos++; MaybeChunk mchunk = lex_expansion_chunk(line, reg_arena, UN_Q); @@ -256,9 +261,8 @@ TokenVec lex_level(RawLine* line, char until, RegionVec* reg_arena) { line->pos++; push_to_TokenVec(&state.tokens, (Token){.kind = TOK_PROCSUB_IN, .as.procsub_region = reg_ptr}); - break; } else { - push_to_TokenVec(&state.tokens, (Token){.kind = TOK_SPECIAL, .as.spec = READ_REDIR}); + push_to_TokenVec(&state.tokens, (Token){.kind = TOK_SPECIAL, .as.spec = READ_REDIR}); } break; default: @@ -4,7 +4,7 @@ #include <string.h> #include "lex.h" - +#include "parse.h" int main() { char* line; @@ -13,6 +13,7 @@ int main() { if (line[0] == '\0') continue; if (strcmp(line, "exit") == 0) exit(0); LexResult res = lex(line); + Pipeline pl = parse_tokstream(res.top_tokens); printf("%s \n", line); } @@ -1,4 +1,5 @@ #include <stdlib.h> +#include <stdio.h> #include "lex.h" #include "typeutils.h" @@ -29,7 +30,7 @@ Command parse_command(TokStream* toks) { RedirectVec redirects = make_RedirectVec(256); for ( Token curr_tok; - (curr_tok = toks->ptr[toks->pos], !(curr_tok.kind == TOK_SPECIAL && (curr_tok.as.spec == PIPE && curr_tok.as.spec == EOL))); + (curr_tok = toks->ptr[toks->pos], !(curr_tok.kind == TOK_SPECIAL && (curr_tok.as.spec == PIPE || curr_tok.as.spec == EOL))); toks->pos++ ) { switch (curr_tok.kind) { @@ -73,5 +74,6 @@ Pipeline parse_tokstream(TokenVec toks) { Command cmd = parse_command(&tokstream); Connector conn = parse_connector(&tokstream); push_to_Pipeline(&result, (PipelineElement){.cmd = cmd, .conn = conn}); + if (conn == CONN_EOL) break; } } @@ -42,7 +42,10 @@ typedef struct { Connector conn; } PipelineElement; - DECLARE_VEC(PipelineElement, Pipeline) +Pipeline parse_tokstream(TokenVec toks); + + + |
