Working on scanner.c
This commit is contained in:
parent
f925aea552
commit
c5bc77f467
6 changed files with 722 additions and 762 deletions
|
|
@ -28,18 +28,20 @@ struct s_heredoc
|
|||
|
||||
static inline t_heredoc heredoc_new(void)
|
||||
{
|
||||
return ((t_heredoc){
|
||||
return (t_heredoc){
|
||||
.is_raw = false,
|
||||
.started = false,
|
||||
.allows_indent = false,
|
||||
.delimiter = string_new(0),
|
||||
.current_leading_word = string_new(0),
|
||||
});
|
||||
.delimiter = string_new(16),
|
||||
.current_leading_word = string_new(16),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
static inline void reset_heredoc(t_heredoc *heredoc)
|
||||
{
|
||||
if (heredoc == NULL)
|
||||
return;
|
||||
heredoc->is_raw = false;
|
||||
heredoc->started = false;
|
||||
heredoc->allows_indent = false;
|
||||
|
|
|
|||
|
|
@ -17,65 +17,65 @@
|
|||
#include "me/vec/vec_heredoc.h"
|
||||
#include "parser/parser.h"
|
||||
|
||||
typedef struct s_scanner t_scanner;
|
||||
// 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_vec_heredoc heredocs;
|
||||
};
|
||||
// struct s_scanner
|
||||
// {
|
||||
// t_u8 last_glob_paren_depth;
|
||||
// bool ext_was_in_double_quote;
|
||||
// bool ext_saw_outside_quote;
|
||||
// t_vec_heredoc heredocs;
|
||||
// };
|
||||
|
||||
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,
|
||||
};
|
||||
// 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;
|
||||
};
|
||||
// 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;
|
||||
// };
|
||||
|
||||
typedef bool (*t_heredoc_content_func)(struct s_heredoc_scan_state *state);
|
||||
// typedef bool (*t_heredoc_content_func)(struct s_heredoc_scan_state *state);
|
||||
|
||||
bool advance_word(TSLexer *lexer, t_string *unquoted_word);
|
||||
bool check_scan_concat(t_scanner *scanner, TSLexer *lexer, const bool *valid_symbols);
|
||||
bool scan(t_scanner *scanner, TSLexer *lexer, const bool *valid_symbols);
|
||||
bool scan_bare_dollar(TSLexer *lexer);
|
||||
bool scan_concat(t_scanner *scanner, TSLexer *lexer, const bool *valid_symbols);
|
||||
bool scan_double_hash(t_scanner *scanner, TSLexer *lexer, const bool *valid_symbols);
|
||||
bool scan_expansion_word(t_scanner *scanner, TSLexer *lexer, const bool *valid_symbols);
|
||||
bool scan_heredoc_content(t_scanner *scanner, TSLexer *lexer, enum e_token_type middle_type, enum e_token_type end_type);
|
||||
bool scan_heredoc_end(t_scanner *scanner, TSLexer *lexer);
|
||||
bool scan_heredoc_end_identifier(t_heredoc *heredoc, TSLexer *lexer);
|
||||
bool scan_heredoc_start(t_heredoc *heredoc, TSLexer *lexer);
|
||||
bool scan_varname(t_scanner *scanner, TSLexer *lexer, const bool *valid_symbols);
|
||||
void reset(t_scanner *scanner);
|
||||
// bool advance_word(TSLexer *lexer, t_string *unquoted_word);
|
||||
// bool check_scan_concat(t_scanner *scanner, TSLexer *lexer, const bool *valid_symbols);
|
||||
// bool scan(t_scanner *scanner, TSLexer *lexer, const bool *valid_symbols);
|
||||
// bool scan_bare_dollar(TSLexer *lexer);
|
||||
// bool scan_concat(t_scanner *scanner, TSLexer *lexer, const bool *valid_symbols);
|
||||
// bool scan_double_hash(t_scanner *scanner, TSLexer *lexer, const bool *valid_symbols);
|
||||
// bool scan_expansion_word(t_scanner *scanner, TSLexer *lexer, const bool *valid_symbols);
|
||||
// bool scan_heredoc_content(t_scanner *scanner, TSLexer *lexer, enum e_token_type middle_type, enum e_token_type end_type);
|
||||
// bool scan_heredoc_end(t_scanner *scanner, TSLexer *lexer);
|
||||
// bool scan_heredoc_end_identifier(t_heredoc *heredoc, TSLexer *lexer);
|
||||
// bool scan_heredoc_start(t_heredoc *heredoc, TSLexer *lexer);
|
||||
// bool scan_varname(t_scanner *scanner, TSLexer *lexer, const bool *valid_symbols);
|
||||
// void reset(t_scanner *scanner);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue