mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-06 07:28:09 +01:00
rule utils: operator combo
This commit is contained in:
parent
b13f8f096b
commit
591518e9bc
3 changed files with 21 additions and 11 deletions
|
|
@ -6,11 +6,12 @@
|
|||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/02/20 12:01:57 by khais #+# #+# */
|
||||
/* Updated: 2025/02/20 12:27:45 by khais ### ########.fr */
|
||||
/* Updated: 2025/02/20 13:18:22 by khais ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "rule_utils.h"
|
||||
#include "../matchers/operator_combo.h"
|
||||
|
||||
/*
|
||||
** return true if we are in an unquoted operator state
|
||||
|
|
@ -27,3 +28,17 @@ bool unquoted(t_token_build *builder)
|
|||
{
|
||||
return (builder->quote == '\0');
|
||||
}
|
||||
|
||||
/*
|
||||
** return true if the current char combines with the current token to form an
|
||||
** operator.
|
||||
**
|
||||
** If current token is null, return false
|
||||
*/
|
||||
bool operator_combo(t_token_build *builder, char *original)
|
||||
{
|
||||
if (builder->cur_token == NULL)
|
||||
return (false);
|
||||
return (is_operator_combo(builder->cur_token->buffer,
|
||||
original[builder->idx]));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/02/20 12:01:31 by khais #+# #+# */
|
||||
/* Updated: 2025/02/20 12:27:05 by khais ### ########.fr */
|
||||
/* Updated: 2025/02/20 13:16:06 by khais ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -18,5 +18,6 @@
|
|||
|
||||
bool unquoted_operator(t_token_build *builder);
|
||||
bool unquoted(t_token_build *builder);
|
||||
bool operator_combo(t_token_build *builder, char *original);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -6,12 +6,11 @@
|
|||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/02/19 13:20:01 by jguelen #+# #+# */
|
||||
/* Updated: 2025/02/20 12:23:27 by khais ### ########.fr */
|
||||
/* Updated: 2025/02/20 13:22:35 by khais ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "wordsplit.h"
|
||||
#include "../matchers/operator_combo.h"
|
||||
#include "rule_utils.h"
|
||||
|
||||
/*
|
||||
|
|
@ -40,10 +39,7 @@ bool rule_eof(t_token_build *builder, char *original)
|
|||
*/
|
||||
bool rule_combine_operator(t_token_build *builder, char *original)
|
||||
{
|
||||
// FIXME: operator combo null check
|
||||
if (unquoted_operator(builder)
|
||||
&& is_operator_combo(builder->cur_token->buffer,
|
||||
original[builder->idx]))
|
||||
if (unquoted_operator(builder) && operator_combo(builder, original))
|
||||
{
|
||||
push_char(builder, original[builder->idx]);
|
||||
builder->idx++;
|
||||
|
|
@ -59,9 +55,7 @@ bool rule_combine_operator(t_token_build *builder, char *original)
|
|||
*/
|
||||
bool rule_operator_end(t_token_build *builder, char *original)
|
||||
{
|
||||
if (unquoted_operator(builder)
|
||||
&& !is_operator_combo(builder->cur_token->buffer,
|
||||
original[builder->idx]))
|
||||
if (unquoted_operator(builder) && !operator_combo(builder, original))
|
||||
{
|
||||
delimit(builder);
|
||||
return (true);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue