update: normed stuff
This commit is contained in:
parent
71d9a201b5
commit
b058348d35
20 changed files with 388 additions and 193 deletions
|
|
@ -6,7 +6,7 @@
|
|||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/02 18:41:16 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/10/05 18:57:59 by maiboyer ### ########.fr */
|
||||
/* Updated: 2024/10/06 13:32:00 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -26,6 +26,17 @@
|
|||
/// there is a few stuff we want to do, for example:
|
||||
/// - combine any *QUOTE token that are next to eachothers
|
||||
/// into a single metatoken WORD
|
||||
/// - do somekind of arith expansion that will have any token between
|
||||
/// DOLLAR DLPAREN and the matching DRPAREN in it
|
||||
/// - do somekind of parenthesis token will have any token between
|
||||
/// LPAREN and the matching RPAREN in it
|
||||
/// - do somekind of CMD token that will store every token that consitute
|
||||
/// command into a single token stopping at the correct ending:
|
||||
/// semicolon, pipe, or, and
|
||||
/// - do a smth that will take any <TOK (OR|AND) TOK> into a single token
|
||||
/// - do a smth that will take any TOK PIPE TOK into a single token and
|
||||
/// merge if any of the TOK is also a pipeline
|
||||
/// (merging may be done during the final ast building)
|
||||
|
||||
// here is the signature easily accessible:
|
||||
//
|
||||
|
|
@ -35,17 +46,18 @@
|
|||
|
||||
static const struct s_ts_pass_def g_ts_passes[] = {\
|
||||
{ts_double_string_pass, "double string parser"}, \
|
||||
{ts_fold_expension, "fold expansion"},
|
||||
{ts_fold_no_quote, "fold no quote"},
|
||||
{ts_fold_whitespace, "fold whitespace"},
|
||||
{ts_double_amp, "double amp => and"},
|
||||
{ts_double_pipe, "double pipe => or"},
|
||||
{ts_double_lparen, "double lparen => dlparen"},
|
||||
{ts_double_rparen, "double rparen => drparen"},
|
||||
{ts_double_lcarret, "double lcarret => dlcarret"},
|
||||
{ts_double_rcarret, "double rcarrer => drcarret"},
|
||||
{ts_fold_expension, "fold expansion"}, \
|
||||
{ts_fold_no_quote, "fold no quote"}, \
|
||||
{ts_fold_whitespace, "fold whitespace"}, \
|
||||
{ts_double_amp, "double amp => and"}, \
|
||||
{ts_double_pipe, "double pipe => or"}, \
|
||||
{ts_double_lparen, "double lparen => dlparen"}, \
|
||||
{ts_double_rparen, "double rparen => drparen"}, \
|
||||
{ts_double_lcarret, "double lcarret => dlcarret"}, \
|
||||
{ts_double_rcarret, "double rcarrer => drcarret"}, \
|
||||
// there should be an ts_fold_arith here
|
||||
{ts_fold_redir, "fold redir+argument"},
|
||||
{ts_split_paren, "split double parenthesis"}, \
|
||||
{ts_fold_redir, "fold redir+argument"}, \
|
||||
};
|
||||
|
||||
t_error ts_apply_passes(t_vec_token ts, t_vec_token *out)
|
||||
|
|
@ -59,7 +71,8 @@ t_error ts_apply_passes(t_vec_token ts, t_vec_token *out)
|
|||
if (g_ts_passes[i].fn == NULL)
|
||||
return (vec_token_free(ts), ERROR);
|
||||
if ((g_ts_passes[i].fn)(ts, &next))
|
||||
return (me_eprintf("failed on %s token pass\n", g_ts_passes[i].name), ERROR);
|
||||
return (me_eprintf("failed on %s token pass\n", \
|
||||
g_ts_passes[i].name), ERROR);
|
||||
else
|
||||
me_printf("Applied '%s' pass\n", g_ts_passes[i].name);
|
||||
ts = next;
|
||||
|
|
@ -70,10 +83,12 @@ t_error ts_apply_passes(t_vec_token ts, t_vec_token *out)
|
|||
}
|
||||
|
||||
static const struct s_ts_pass_def g_ts_dq_passes[] = {\
|
||||
{ts_double_lparen, "double lparen => dlparen"},
|
||||
{ts_double_rparen, "double rparen => drparen"},
|
||||
{ts_fold_expension, "fold expansion"},
|
||||
{ts_double_lparen, "double lparen => dlparen"}, \
|
||||
{ts_double_rparen, "double rparen => drparen"}, \
|
||||
{ts_fold_expension, "fold expansion"}, \
|
||||
// there should be an ts_fold_arith here
|
||||
{ts_split_paren, "split double parenthesis"}, \
|
||||
{ts_paren_to_noquote, "parenthesis to noquote"}, \
|
||||
{ts_fold_no_quote, "fold no quote"},
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue