lexer function increment lexer.pos not lexer.str
This commit is contained in:
parent
f05172b9e1
commit
8abf9fe433
6 changed files with 9 additions and 24 deletions
1
42sh/.gitignore
vendored
1
42sh/.gitignore
vendored
|
|
@ -2,6 +2,7 @@ minishell
|
||||||
21sh
|
21sh
|
||||||
42sh
|
42sh
|
||||||
out
|
out
|
||||||
|
STDBUG
|
||||||
debug
|
debug
|
||||||
.42sh_history
|
.42sh_history
|
||||||
*.dSYM
|
*.dSYM
|
||||||
|
|
|
||||||
18
42sh/file
18
42sh/file
|
|
@ -1,18 +0,0 @@
|
||||||
4
|
|
||||||
42sh
|
|
||||||
Makefile
|
|
||||||
Session.vim
|
|
||||||
debug
|
|
||||||
donovan_segaults_06-02
|
|
||||||
file
|
|
||||||
file1
|
|
||||||
file2
|
|
||||||
file3
|
|
||||||
includes
|
|
||||||
libft
|
|
||||||
objs
|
|
||||||
out
|
|
||||||
pdf
|
|
||||||
script.sh
|
|
||||||
src
|
|
||||||
update_makefile.sh
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
Subproject commit a82ea94ef7f50f8396d7bf6f9c08ab4a7faa994d
|
Subproject commit 0ca8ca817f32fc0345ef93ef74a3abe2583bd89c
|
||||||
|
|
@ -21,13 +21,13 @@ int lexer_greatand(t_list **alst, t_lexer *lexer)
|
||||||
if (ft_isdigit(lexer->str[lexer->pos]))
|
if (ft_isdigit(lexer->str[lexer->pos]))
|
||||||
{
|
{
|
||||||
token_append(token, lexer, 0, 0);
|
token_append(token, lexer, 0, 0);
|
||||||
lexer->str++;
|
lexer->pos++;
|
||||||
return (lexer_greatand(alst, lexer));
|
return (lexer_greatand(alst, lexer));
|
||||||
}
|
}
|
||||||
else if (lexer->str[lexer->pos] == '-')
|
else if (lexer->str[lexer->pos] == '-')
|
||||||
{
|
{
|
||||||
token_append(token, lexer, 0, 0);
|
token_append(token, lexer, 0, 0);
|
||||||
lexer->str++;
|
lexer->pos++;
|
||||||
lexer->state = DEFAULT;
|
lexer->state = DEFAULT;
|
||||||
return (lexer_lex(&(*alst)->next, lexer));
|
return (lexer_lex(&(*alst)->next, lexer));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,13 +21,13 @@ int lexer_lessand(t_list **alst, t_lexer *lexer)
|
||||||
if (ft_isdigit(lexer->str[lexer->pos]))
|
if (ft_isdigit(lexer->str[lexer->pos]))
|
||||||
{
|
{
|
||||||
token_append(token, lexer, 0, 0);
|
token_append(token, lexer, 0, 0);
|
||||||
lexer->str++;
|
lexer->pos++;
|
||||||
return (lexer_lessand(alst, lexer));
|
return (lexer_lessand(alst, lexer));
|
||||||
}
|
}
|
||||||
else if (lexer->str[lexer->pos] == '-')
|
else if (lexer->str[lexer->pos] == '-')
|
||||||
{
|
{
|
||||||
token_append(token, lexer, 0, 0);
|
token_append(token, lexer, 0, 0);
|
||||||
lexer->str++;
|
lexer->pos++;
|
||||||
lexer->state = DEFAULT;
|
lexer->state = DEFAULT;
|
||||||
return (lexer_lex(&(*alst)->next, lexer));
|
return (lexer_lex(&(*alst)->next, lexer));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,8 @@ int interactive_shell()
|
||||||
token = NULL;
|
token = NULL;
|
||||||
ast = NULL;
|
ast = NULL;
|
||||||
do {
|
do {
|
||||||
ft_strappend(&lexer.str, readline(stack_to_prompt(lexer.stack)));
|
char *str = readline(stack_to_prompt(lexer.stack));
|
||||||
|
ft_strappend(&lexer.str, str);
|
||||||
if (get_lexer_stack(lexer) == BACKSLASH)
|
if (get_lexer_stack(lexer) == BACKSLASH)
|
||||||
pop(&lexer.stack);
|
pop(&lexer.stack);
|
||||||
else if (get_lexer_stack(lexer) == DLESS)
|
else if (get_lexer_stack(lexer) == DLESS)
|
||||||
|
|
@ -74,6 +75,7 @@ int interactive_shell()
|
||||||
btree_print(STDBUG, ast, &ft_putast);
|
btree_print(STDBUG, ast, &ft_putast);
|
||||||
if (ft_exec(&ast))
|
if (ft_exec(&ast))
|
||||||
return (1);
|
return (1);
|
||||||
|
DG("gonna free [%s] @ [%p]", lexer.str, lexer.str);
|
||||||
ft_strdel(&lexer.str);
|
ft_strdel(&lexer.str);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue