Started to work on parser.c and split scanner into headers
This commit is contained in:
parent
800c9b0a50
commit
86695aad14
6 changed files with 218 additions and 210 deletions
82
parser/include/parser/inner/parser_inner.h
Normal file
82
parser/include/parser/inner/parser_inner.h
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* parser_inner.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/09/10 13:56:47 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/09/10 13:58:59 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef PARSER_INNER_H
|
||||
#define PARSER_INNER_H
|
||||
|
||||
#include "me/mem/mem.h"
|
||||
#include "me/types.h"
|
||||
#include "me/vec/vec_reduce_action.h"
|
||||
#include "me/vec/vec_subtree.h"
|
||||
#include "parser/api.h"
|
||||
#include "parser/array.h"
|
||||
#include "parser/language.h"
|
||||
#include "parser/length.h"
|
||||
#include "parser/lexer.h"
|
||||
#include "parser/reduce_action.h"
|
||||
#include "parser/stack.h"
|
||||
#include "parser/subtree.h"
|
||||
#include "parser/tree.h"
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define MAX_VERSION_COUNT 40
|
||||
#define MAX_VERSION_COUNT_OVERFLOW 60
|
||||
#define MAX_SUMMARY_DEPTH 1
|
||||
#define MAX_COST_DIFFERENCE 16 * ERROR_COST_PER_SKIPPED_TREE
|
||||
|
||||
typedef struct s_error_status t_error_status;
|
||||
typedef enum e_error_comparison t_error_comparison;
|
||||
typedef struct s_string_input t_string_input;
|
||||
|
||||
|
||||
struct TSParser
|
||||
{
|
||||
t_lexer lexer;
|
||||
t_stack *stack;
|
||||
const TSLanguage *language;
|
||||
ReduceActionSet reduce_actions;
|
||||
t_subtree finished_tree;
|
||||
t_vec_subtree trailing_extras;
|
||||
t_vec_subtree trailing_extras2;
|
||||
t_vec_subtree scratch_trees;
|
||||
void *external_scanner_payload;
|
||||
t_u32 accept_count;
|
||||
t_u32 operation_count;
|
||||
bool has_scanner_error;
|
||||
};
|
||||
|
||||
struct s_error_status
|
||||
{
|
||||
t_u32 cost;
|
||||
t_u32 node_count;
|
||||
int dynamic_precedence;
|
||||
bool is_in_error;
|
||||
};
|
||||
|
||||
enum e_error_comparison
|
||||
{
|
||||
|
||||
ECTakeLeft,
|
||||
ECPreferLeft,
|
||||
ECNone,
|
||||
ECPreferRight,
|
||||
ECTakeRight,
|
||||
};
|
||||
|
||||
struct s_string_input
|
||||
{
|
||||
const t_u8 *string;
|
||||
t_u32 length;
|
||||
};
|
||||
|
||||
#endif /* PARSER_INNER_H */
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* scanner.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/09/02 13:22:04 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/09/06 16:57:20 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef SCANNER_H
|
||||
#define SCANNER_H
|
||||
|
||||
#include "me/types.h"
|
||||
#include "me/vec/vec_heredoc.h"
|
||||
#include "parser/parser.h"
|
||||
|
||||
#endif
|
||||
62
parser/include/parser/inner/scanner_inner.h
Normal file
62
parser/include/parser/inner/scanner_inner.h
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* scanner_inner.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/09/10 13:57:11 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/09/10 13:57:53 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef SCANNER_INNER_H
|
||||
#define SCANNER_INNER_H
|
||||
|
||||
#include "me/char/char.h"
|
||||
#include "me/mem/mem.h"
|
||||
#include "me/str/str.h"
|
||||
#include "me/string/string.h"
|
||||
#include "me/types.h"
|
||||
#include "me/vec/vec_heredoc.h"
|
||||
#include "parser/inner/heredoc.h"
|
||||
#include "parser/lexer.h"
|
||||
#include "parser/parser.h"
|
||||
|
||||
typedef struct s_heredoc t_heredoc;
|
||||
typedef struct s_scanner t_scanner;
|
||||
|
||||
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_scanner
|
||||
{
|
||||
t_u8 last_glob_paren_depth;
|
||||
bool ext_was_in_double_quote;
|
||||
bool ext_saw_outside_quote;
|
||||
t_vec_heredoc heredocs;
|
||||
};
|
||||
|
||||
|
||||
#endif /* SCANNER_INNER_H */
|
||||
Loading…
Add table
Add a link
Reference in a new issue