lexer norm finished
This commit is contained in:
parent
f482f78254
commit
685c749d3d
3 changed files with 17 additions and 23 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/03/17 20:02:48 by jhalford ### ########.fr */
|
/* Updated: 2017/03/20 10:02:26 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -17,28 +17,22 @@ t_lexstate get_state_global(t_lexer *lexer)
|
||||||
char c;
|
char c;
|
||||||
char cn;
|
char cn;
|
||||||
char cl;
|
char cl;
|
||||||
|
int ret;
|
||||||
|
|
||||||
c = lexer->str[lexer->pos];
|
c = lexer->str[lexer->pos];
|
||||||
cn = lexer->str[lexer->pos + 1];
|
cn = lexer->str[lexer->pos + 1];
|
||||||
cl = lexer->str[lexer->pos ? lexer->pos - 1 : 0];
|
cl = lexer->str[lexer->pos ? lexer->pos - 1 : 0];
|
||||||
if (ft_is_delim(c))
|
ret = 0;
|
||||||
return (DELIM);
|
if ((ft_is_delim(c) && (ret = DELIM))
|
||||||
else if (c == '&' || c == ';' || c == '|' || c == '!')
|
|| ((c == '&' || c == ';' || c == '|' || c == '!') && (ret = SEP))
|
||||||
return (SEP);
|
|| ((c == '\\') && (ret = BACKSLASH))
|
||||||
else if (c == '\\')
|
|| ((c == '\'') && (ret = QUOTE))
|
||||||
return (BACKSLASH);
|
|| ((c == '\"') && (ret = DQUOTE))
|
||||||
else if (c == '\'')
|
|| ((c == '`') && (ret = BQUOTE))
|
||||||
return (QUOTE);
|
|| ((c == '(' || c == ')') && (ret = PAREN))
|
||||||
else if (c == '\"')
|
|| (((c == '{' && cn == ' ') || (c == '}' && cl == ' '))
|
||||||
return (DQUOTE);
|
&& (ret = CURLY_BRACKETS))
|
||||||
else if (c == '`')
|
|| ((c == 0) && (ret = END)))
|
||||||
return (BQUOTE);
|
;
|
||||||
else if (c == '(' || c == ')')
|
return (ret);
|
||||||
return (PAREN);
|
|
||||||
else if ((c == '{' && cn == ' ')
|
|
||||||
|| (c == '}' && cl == ' '))
|
|
||||||
return (CURLY_BRACKETS);
|
|
||||||
else if (c == 0)
|
|
||||||
return (END);
|
|
||||||
return (0);
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/15 14:19:48 by gwojda #+# #+# */
|
/* Created: 2016/12/15 14:19:48 by gwojda #+# #+# */
|
||||||
/* Updated: 2017/03/20 09:46:30 by jhalford ### ########.fr */
|
/* Updated: 2017/03/20 09:57:09 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/28 19:26:32 by jhalford #+# #+# */
|
/* Created: 2016/11/28 19:26:32 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/20 09:55:33 by jhalford ### ########.fr */
|
/* Updated: 2017/03/20 09:57:11 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue