rule utils: unquoted operator

This commit is contained in:
Khaïs COLIN 2025-02-20 12:06:34 +01:00
parent edf8946fe3
commit f86de825bd
Signed by: logistic-bot
SSH key fingerprint: SHA256:RlpiqKeXpcPFZZ4y9Ou4xi2M8OhRJovIwDlbCaMsuAo
4 changed files with 49 additions and 4 deletions

View file

@ -33,6 +33,7 @@ srcs = \
src/parser/matchers/operator_start.c \
src/parser/worddesc/worddesc.c \
src/parser/wordlist/wordlist.c \
src/parser/wordsplit/rule_utils.c \
src/parser/wordsplit/tokenizing_1_5.c \
src/parser/wordsplit/tokenizing_6_10.c \
src/parser/wordsplit/wordsplit.c \

View file

@ -0,0 +1,21 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* rule_utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/20 12:01:57 by khais #+# #+# */
/* Updated: 2025/02/20 12:04:15 by khais ### ########.fr */
/* */
/* ************************************************************************** */
#include "rule_utils.h"
/*
** return true if we are in an unquoted operator state
*/
bool unquoted_operator(t_token_build *builder)
{
return (builder->quote == '\0' && builder->currently_in_operator);
}

View file

@ -0,0 +1,21 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* rule_utils.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/20 12:01:31 by khais #+# #+# */
/* Updated: 2025/02/20 12:03:50 by khais ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef RULE_UTILS_H
# define RULE_UTILS_H
# include <stdbool.h>
# include "wordsplit.h"
bool unquoted_operator(t_token_build *builder);
#endif

View file

@ -3,15 +3,16 @@
/* ::: :::::::: */
/* tokenizing_1_5.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jguelen <marvin@42.fr> +#+ +:+ +#+ */
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/19 13:20:01 by jguelen #+# #+# */
/* Updated: 2025/02/20 12:22:28 by khais ### ########.fr */
/* Updated: 2025/02/20 12:23:27 by khais ### ########.fr */
/* */
/* ************************************************************************** */
#include "wordsplit.h"
#include "../matchers/operator_combo.h"
#include "rule_utils.h"
/*
** cf. Token Recognition section at
@ -39,7 +40,8 @@ bool rule_eof(t_token_build *builder, char *original)
*/
bool rule_combine_operator(t_token_build *builder, char *original)
{
if (builder->currently_in_operator && builder->quote == '\0'
// FIXME: operator combo null check
if (unquoted_operator(builder)
&& is_operator_combo(builder->cur_token->buffer,
original[builder->idx]))
{
@ -57,7 +59,7 @@ bool rule_combine_operator(t_token_build *builder, char *original)
*/
bool rule_operator_end(t_token_build *builder, char *original)
{
if (builder->currently_in_operator && builder->quote == '\0' // FIXME
if (unquoted_operator(builder)
&& !is_operator_combo(builder->cur_token->buffer,
original[builder->idx]))
{