update: fixed expansion stuff
This commit is contained in:
parent
01c8e7cf2c
commit
3287b6a2a7
10 changed files with 133 additions and 16 deletions
|
|
@ -6,15 +6,25 @@
|
|||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/02 19:04:32 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/10/03 22:50:40 by maiboyer ### ########.fr */
|
||||
/* Updated: 2024/10/05 13:19:33 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "me/str/str.h"
|
||||
#include "me/types.h"
|
||||
#include "me/vec/vec_token.h"
|
||||
#include "parser/passes.h"
|
||||
#include "parser/token.h"
|
||||
|
||||
bool _can_be_varname(t_token *tok)
|
||||
{
|
||||
if (tok->type == TOK_DOLLAR)
|
||||
return (true);
|
||||
if (tok->type != TOK_NALPHANUM)
|
||||
return (false);
|
||||
return (str_find_chr("!?#*-", tok->string.buf[0]) != NULL);
|
||||
}
|
||||
|
||||
/// This is a sample pass
|
||||
///
|
||||
/// There is a few rules the rest of the tokenizer machinery assumes
|
||||
|
|
@ -38,8 +48,8 @@ t_error ts_fold_expension(t_vec_token input, t_vec_token *output)
|
|||
if (i + 1 >= input.len)
|
||||
vec_token_push(&out, token_clone(&input.buffer[i]));
|
||||
else if (input.buffer[i].type == TOK_DOLLAR \
|
||||
&& (input.buffer[i + 1].type == TOK_DOLLAR \
|
||||
|| input.buffer[i + 1].type == TOK_NQUOTE))
|
||||
&& (input.buffer[i + 1].type == TOK_NQUOTE \
|
||||
|| _can_be_varname(&input.buffer[i+1])))
|
||||
{
|
||||
tmp = token_clone(&input.buffer[++i]);
|
||||
tmp.type= TOK_EXPENSION;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue