matcher: is_quote

This commit is contained in:
Khaïs COLIN 2025-02-20 13:22:32 +01:00
parent 591518e9bc
commit e10ed04169
Signed by: logistic-bot
SSH key fingerprint: SHA256:RlpiqKeXpcPFZZ4y9Ou4xi2M8OhRJovIwDlbCaMsuAo
4 changed files with 47 additions and 3 deletions

View file

@ -0,0 +1,23 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* quote.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/20 13:21:08 by khais #+# #+# */
/* Updated: 2025/02/20 13:22:12 by khais ### ########.fr */
/* */
/* ************************************************************************** */
#include "quote.h"
/*
** return true if c is either ' or "
*/
bool is_quote(char c)
{
if (c == '\'' || c == '"')
return (true);
return (false);
}

View file

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* quote.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/20 13:20:46 by khais #+# #+# */
/* Updated: 2025/02/20 13:21:28 by khais ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef QUOTE_H
# define QUOTE_H
# include <stdbool.h>
bool is_quote(char c);
#endif

View file

@ -6,12 +6,13 @@
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/19 13:20:01 by jguelen #+# #+# */
/* Updated: 2025/02/20 13:22:35 by khais ### ########.fr */
/* Updated: 2025/02/20 13:22:57 by khais ### ########.fr */
/* */
/* ************************************************************************** */
#include "wordsplit.h"
#include "rule_utils.h"
#include "../matchers/quote.h"
/*
** cf. Token Recognition section at
@ -74,8 +75,7 @@ bool rule_operator_end(t_token_build *builder, char *original)
*/
bool rule_quote(t_token_build *builder, char *original)
{
// FIXME
if (original[builder->idx] == '\'' || original[builder->idx] == '"')
if (is_quote(original[builder->idx]))
{
quote_flip(builder, original[builder->idx]);
builder->idx++;