modif assignment word
This commit is contained in:
parent
b90a17f2fa
commit
d0c9baeeb8
3 changed files with 47 additions and 6 deletions
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/02/09 20:39:06 by jhalford #+# #+# */
|
/* Created: 2017/02/09 20:39:06 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/02/24 21:39:47 by ariard ### ########.fr */
|
/* Updated: 2017/03/03 15:06:07 by wescande ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -35,9 +35,9 @@ t_lexstate get_state_global(t_lexer *lexer)
|
||||||
return (PAREN);
|
return (PAREN);
|
||||||
else if (c == '{' || c == '}')
|
else if (c == '{' || c == '}')
|
||||||
return (CURLY_BRACKETS);
|
return (CURLY_BRACKETS);
|
||||||
else if (c == '=')
|
/* else if (c == '=')
|
||||||
return (ASSIGNEMENT_WORD);
|
return (ASSIGNEMENT_WORD);
|
||||||
else if (c == 0)
|
*/ else if (c == 0)
|
||||||
return (END);
|
return (END);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,12 +6,53 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/03 12:07:11 by jhalford #+# #+# */
|
/* Created: 2016/12/03 12:07:11 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/01 23:32:59 by ariard ### ########.fr */
|
/* Updated: 2017/03/03 16:00:13 by wescande ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "lexer.h"
|
#include "lexer.h"
|
||||||
|
|
||||||
|
static int word_is_assignment(t_token *token)
|
||||||
|
{
|
||||||
|
const int len = ft_strlen(token->data);
|
||||||
|
int pos = -1;
|
||||||
|
char c;
|
||||||
|
|
||||||
|
while (++pos < len)
|
||||||
|
{
|
||||||
|
if (is_char_esc(token->esc, token->data, token->data + pos))
|
||||||
|
return (0);
|
||||||
|
c = token->data[pos];
|
||||||
|
if (!ft_isalnum(c) && c != '_' && c != '-')
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
int lexer_word(t_list **alst, t_lexer *lexer)
|
||||||
|
{
|
||||||
|
t_token *token;
|
||||||
|
t_lexstate state;
|
||||||
|
|
||||||
|
token = (*alst)->content;
|
||||||
|
token->type = TK_WORD;
|
||||||
|
if ((state = get_state_global(lexer))
|
||||||
|
|| (state = get_state_redir(lexer)))
|
||||||
|
{
|
||||||
|
lexer->state = state;
|
||||||
|
return (lexer_lex(alst, lexer));
|
||||||
|
}
|
||||||
|
if (lexer->str[lexer->pos] == '=' && word_is_assignment(token))
|
||||||
|
{
|
||||||
|
lexer->state = ASSIGNEMENT_WORD;
|
||||||
|
return (lexer_lex(alst, lexer));
|
||||||
|
}
|
||||||
|
token_append(token, lexer, 0, 0);
|
||||||
|
lexer->pos++;
|
||||||
|
return (lexer_lex(alst, lexer));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
int lexer_word(t_list **alst, t_lexer *lexer)
|
int lexer_word(t_list **alst, t_lexer *lexer)
|
||||||
{
|
{
|
||||||
t_token *token;
|
t_token *token;
|
||||||
|
|
@ -33,3 +74,4 @@ int lexer_word(t_list **alst, t_lexer *lexer)
|
||||||
lexer->pos++;
|
lexer->pos++;
|
||||||
return (lexer_lex(alst, lexer));
|
return (lexer_lex(alst, lexer));
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
|
||||||
|
|
@ -6,13 +6,12 @@
|
||||||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/11 17:18:42 by jhalford #+# #+# */
|
/* Created: 2016/11/11 17:18:42 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/02/24 20:33:59 by ariard ### ########.fr */
|
/* Updated: 2017/03/03 15:12:41 by wescande ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "lexer.h"
|
#include "lexer.h"
|
||||||
|
|
||||||
|
|
||||||
int token_append_char(t_token *token, char c,
|
int token_append_char(t_token *token, char c,
|
||||||
short int esc, short int esc2)
|
short int esc, short int esc2)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue