mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-06 07:28:09 +01:00
rule utils: unquoted operator
This commit is contained in:
parent
edf8946fe3
commit
f86de825bd
4 changed files with 49 additions and 4 deletions
1
Makefile
1
Makefile
|
|
@ -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 \
|
||||
|
|
|
|||
21
src/parser/wordsplit/rule_utils.c
Normal file
21
src/parser/wordsplit/rule_utils.c
Normal 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);
|
||||
}
|
||||
21
src/parser/wordsplit/rule_utils.h
Normal file
21
src/parser/wordsplit/rule_utils.h
Normal 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
|
||||
|
|
@ -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]))
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue