split heredoc handling in the scanner
This commit is contained in:
parent
8be7417a61
commit
7e1e51e90b
30 changed files with 663 additions and 416 deletions
|
|
@ -6,7 +6,7 @@
|
|||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/09/01 15:06:56 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/09/01 15:08:47 by maiboyer ### ########.fr */
|
||||
/* Updated: 2024/09/01 19:01:16 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -46,4 +46,10 @@ static inline void reset_heredoc(t_heredoc *heredoc)
|
|||
string_clear(&heredoc->delimiter);
|
||||
}
|
||||
|
||||
static inline void heredoc_free(t_heredoc heredoc)
|
||||
{
|
||||
string_free(heredoc.delimiter);
|
||||
string_free(heredoc.current_leading_word);
|
||||
}
|
||||
|
||||
#endif /* HEREDOC_TYPE_H */
|
||||
|
|
|
|||
|
|
@ -2,18 +2,54 @@
|
|||
#define SCANNER_H
|
||||
|
||||
#include "me/types.h"
|
||||
#include "parser/inner/heredoc.h"
|
||||
#include "me/vec/vec_heredoc.h"
|
||||
#include "parser/array.h"
|
||||
#include "parser/parser.h"
|
||||
|
||||
typedef struct s_scanner t_scanner;
|
||||
|
||||
struct s_scanner
|
||||
{
|
||||
t_u8 last_glob_paren_depth;
|
||||
bool ext_was_in_double_quote;
|
||||
bool ext_saw_outside_quote;
|
||||
t_u8 last_glob_paren_depth;
|
||||
bool ext_was_in_double_quote;
|
||||
bool ext_saw_outside_quote;
|
||||
t_vec_heredoc heredocs;
|
||||
};
|
||||
|
||||
#endif
|
||||
enum e_token_type
|
||||
{
|
||||
HEREDOC_START,
|
||||
SIMPLE_HEREDOC_BODY,
|
||||
HEREDOC_BODY_BEGINNING,
|
||||
HEREDOC_CONTENT,
|
||||
HEREDOC_END,
|
||||
FILE_DESCRIPTOR,
|
||||
EMPTY_VALUE,
|
||||
CONCAT,
|
||||
VARIABLE_NAME,
|
||||
REGEX,
|
||||
EXPANSION_WORD,
|
||||
EXTGLOB_PATTERN,
|
||||
BARE_DOLLAR,
|
||||
IMMEDIATE_DOUBLE_HASH,
|
||||
HEREDOC_ARROW,
|
||||
HEREDOC_ARROW_DASH,
|
||||
NEWLINE,
|
||||
OPENING_PAREN,
|
||||
ESAC,
|
||||
ERROR_RECOVERY,
|
||||
};
|
||||
|
||||
struct s_heredoc_scan_state
|
||||
{
|
||||
t_scanner *scanner;
|
||||
TSLexer *lexer;
|
||||
enum e_token_type middle_type;
|
||||
enum e_token_type end_type;
|
||||
bool did_advance;
|
||||
t_heredoc *heredoc;
|
||||
bool return_value;
|
||||
};
|
||||
|
||||
bool advance_word(TSLexer *lexer, t_string *unquoted_word);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue