WIP parser norminettation

This commit is contained in:
Maieul BOYER 2024-04-29 15:38:44 +02:00
parent 16f49181b5
commit ff4b0c471f
No known key found for this signature in database
44 changed files with 1130 additions and 265 deletions

View file

@ -5,6 +5,8 @@
#include <stdint.h>
#include <stdlib.h>
#include "me/vec/vec_parser_range.h"
/****************************/
/* Section - ABI Versioning */
/****************************/
@ -51,24 +53,10 @@ typedef enum TSSymbolType
TSSymbolTypeAuxiliary,
} TSSymbolType;
typedef struct TSPoint
{
uint32_t row;
uint32_t column;
} TSPoint;
typedef struct TSRange
{
TSPoint start_point;
TSPoint end_point;
uint32_t start_byte;
uint32_t end_byte;
} TSRange;
typedef struct TSInput
{
void *payload;
const char *(*read)(void *payload, uint32_t byte_index, TSPoint position,
const char *(*read)(void *payload, uint32_t byte_index, t_point position,
uint32_t *bytes_read);
TSInputEncoding encoding;
} TSInput;
@ -90,9 +78,9 @@ typedef struct TSInputEdit
uint32_t start_byte;
uint32_t old_end_byte;
uint32_t new_end_byte;
TSPoint start_point;
TSPoint old_end_point;
TSPoint new_end_point;
t_point start_point;
t_point old_end_point;
t_point new_end_point;
} TSInputEdit;
typedef struct TSNode
@ -210,7 +198,7 @@ bool ts_parser_set_language(TSParser *self, const TSLanguage *language);
* will not be assigned, and this function will return `false`. On success,
* this function returns `true`
*/
bool ts_parser_set_included_ranges(TSParser *self, const TSRange *ranges,
bool ts_parser_set_included_ranges(TSParser *self, const t_parser_range *ranges,
uint32_t count);
/**
@ -220,7 +208,8 @@ bool ts_parser_set_included_ranges(TSParser *self, const TSRange *ranges,
* it or write to it. The length of the array will be written to the given
* `count` pointer.
*/
const TSRange *ts_parser_included_ranges(const TSParser *self, uint32_t *count);
const t_parser_range *ts_parser_included_ranges(const TSParser *self,
uint32_t *count);
/**
* Use the parser to parse some source code and create a syntax tree.
@ -387,7 +376,7 @@ TSNode ts_tree_root_node(const TSTree *self);
* shifted forward by the given offset.
*/
TSNode ts_tree_root_node_with_offset(const TSTree *self, uint32_t offset_bytes,
TSPoint offset_extent);
t_point offset_extent);
/**
* Get the language that was used to parse the syntax tree.
@ -399,7 +388,7 @@ const TSLanguage *ts_tree_language(const TSTree *self);
*
* The returned pointer must be freed by the caller.
*/
TSRange *ts_tree_included_ranges(const TSTree *self, uint32_t *length);
t_parser_range *ts_tree_included_ranges(const TSTree *self, uint32_t *length);
/**
* Edit the syntax tree to keep it in sync with source code that has been
@ -425,8 +414,9 @@ void ts_tree_edit(TSTree *self, const TSInputEdit *edit);
* responsible for freeing it using `free`. The length of the array will be
* written to the given `length` pointer.
*/
TSRange *ts_tree_get_changed_ranges(const TSTree *old_tree,
const TSTree *new_tree, uint32_t *length);
t_parser_range *ts_tree_get_changed_ranges(const TSTree *old_tree,
const TSTree *new_tree,
uint32_t *length);
/**
* Write a DOT graph describing the syntax tree to the given file.
@ -474,7 +464,7 @@ uint32_t ts_node_start_byte(TSNode self);
/**
* Get the node's start position in terms of rows and columns.
*/
TSPoint ts_node_start_point(TSNode self);
t_point ts_node_start_point(TSNode self);
/**
* Get the node's end byte.
@ -484,7 +474,7 @@ uint32_t ts_node_end_byte(TSNode self);
/**
* Get the node's end position in terms of rows and columns.
*/
TSPoint ts_node_end_point(TSNode self);
t_point ts_node_end_point(TSNode self);
/**
* Get an S-expression representing the node as a string.
@ -629,8 +619,8 @@ uint32_t ts_node_descendant_count(TSNode self);
*/
TSNode ts_node_descendant_for_byte_range(TSNode self, uint32_t start,
uint32_t end);
TSNode ts_node_descendant_for_point_range(TSNode self, TSPoint start,
TSPoint end);
TSNode ts_node_descendant_for_point_range(TSNode self, t_point start,
t_point end);
/**
* Get the smallest named node within this node that spans the given range
@ -638,8 +628,8 @@ TSNode ts_node_descendant_for_point_range(TSNode self, TSPoint start,
*/
TSNode ts_node_named_descendant_for_byte_range(TSNode self, uint32_t start,
uint32_t end);
TSNode ts_node_named_descendant_for_point_range(TSNode self, TSPoint start,
TSPoint end);
TSNode ts_node_named_descendant_for_point_range(TSNode self, t_point start,
t_point end);
/**
* Edit the node to keep it in-sync with source code that has been edited.
@ -790,7 +780,7 @@ uint32_t ts_tree_cursor_current_depth(const TSTreeCursor *self);
int64_t ts_tree_cursor_goto_first_child_for_byte(TSTreeCursor *self,
uint32_t goal_byte);
int64_t ts_tree_cursor_goto_first_child_for_point(TSTreeCursor *self,
TSPoint goal_point);
t_point goal_point);
TSTreeCursor ts_tree_cursor_copy(const TSTreeCursor *cursor);
@ -976,8 +966,8 @@ void ts_query_cursor_set_match_limit(TSQueryCursor *self, uint32_t limit);
*/
void ts_query_cursor_set_byte_range(TSQueryCursor *self, uint32_t start_byte,
uint32_t end_byte);
void ts_query_cursor_set_point_range(TSQueryCursor *self, TSPoint start_point,
TSPoint end_point);
void ts_query_cursor_set_point_range(TSQueryCursor *self, t_point start_point,
t_point end_point);
/**
* Advance to the next match of the currently running query.

View file

@ -9,48 +9,4 @@
#define TREE_SITTER_SERIALIZATION_BUFFER_SIZE 1024
typedef struct s_language t_language;
typedef struct s_scanner
{
const bool *states;
const t_symbol *symbol_map;
void *(*create)(void);
void (*destroy)(void *);
bool (*scan)(void *, t_lexer *, const bool *symbol_whitelist);
unsigned (*serialize)(void *, char *);
void (*deserialize)(void *, const char *, unsigned);
} t_scanner;
struct s_language
{
uint32_t version;
uint32_t symbol_count;
uint32_t alias_count;
uint32_t token_count;
uint32_t external_token_count;
uint32_t state_count;
uint32_t large_state_count;
uint32_t production_id_count;
uint32_t field_count;
uint16_t max_alias_sequence_length;
const uint16_t *parse_table;
const uint16_t *small_parse_table;
const uint32_t *small_parse_table_map;
const t_parse_action_entry *parse_actions;
const char *const *symbol_names;
const char *const *field_names;
const t_field_map_slice *field_map_slices;
const t_field_map_entry *field_map_entries;
const t_symbol_metadata *symbol_metadata;
const t_symbol *public_symbol_map;
const uint16_t *alias_map;
const t_symbol *alias_sequences;
const t_lex_modes *lex_modes;
bool (*lex_fn)(t_lexer *, t_state_id);
bool (*keyword_lex_fn)(t_lexer *, t_state_id);
t_symbol keyword_capture_token;
t_scanner external_scanner;
const t_state_id *primary_state_ids;
};
#endif // TREE_SITTER_PARSER_H_

View file

@ -0,0 +1,24 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* types_char_range.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/29 15:03:34 by maiboyer #+# #+# */
/* Updated: 2024/04/29 15:27:38 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef TYPES_CHAR_RANGE_H
# define TYPES_CHAR_RANGE_H
# include "me/types.h"
typedef struct s_char_range
{
t_i32 start;
t_i32 end;
} t_char_range;
#endif /* TYPES_CHAR_RANGE_H */

View file

@ -0,0 +1,25 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* types_field_entry.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/29 14:51:21 by maiboyer #+# #+# */
/* Updated: 2024/04/29 15:35:36 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef TYPES_FIELD_ENTRY_H
# define TYPES_FIELD_ENTRY_H
# include "parser/types/types_field_id.h"
typedef struct s_field_map_entry
{
t_field_id field_id;
t_u8 child_index;
bool inherited;
} t_field_map_entry;
#endif /* TYPES_FIELD_ENTRY_H */

View file

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* types_field_id.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/29 14:44:38 by maiboyer #+# #+# */
/* Updated: 2024/04/29 14:44:44 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef TYPES_FIELD_ID_H
# define TYPES_FIELD_ID_H
# include "me/types.h"
typedef t_u16 t_field_id;
#endif /* TYPES_FIELD_ID_H */

View file

@ -0,0 +1,26 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* types_field_map_entry.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/29 14:51:45 by maiboyer #+# #+# */
/* Updated: 2024/04/29 14:53:31 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef TYPES_FIELD_MAP_ENTRY_H
# define TYPES_FIELD_MAP_ENTRY_H
# include "me/types.h"
# include "parser/types/types_field_id.h"
typedef struct s_field_map_entry
{
t_field_id field_id;
t_u8 child_index;
bool inherited;
} t_field_map_entry;
#endif /* TYPES_FIELD_MAP_ENTRY_H */

View file

@ -0,0 +1,24 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* types_field_map_slice.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/29 14:54:41 by maiboyer #+# #+# */
/* Updated: 2024/04/29 15:08:21 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef TYPES_FIELD_MAP_SLICE_H
# define TYPES_FIELD_MAP_SLICE_H
# include "me/types.h"
typedef struct s_field_map_slice
{
t_u16 index;
t_u16 length;
} t_field_map_slice;
#endif /* TYPES_FIELD_MAP_SLICE_H */

View file

@ -0,0 +1,61 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* types_language.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/29 14:39:37 by maiboyer #+# #+# */
/* Updated: 2024/04/29 15:36:47 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef TYPES_LANGUAGE_H
# define TYPES_LANGUAGE_H
# include "me/types.h"
# include "parser/types/types_field_map_entry.h"
# include "parser/types/types_field_map_slice.h"
# include "parser/types/types_lex_modes.h"
# include "parser/types/types_lexer.h"
# include "parser/types/types_parse_action_entry.h"
# include "parser/types/types_scanner.h"
# include "parser/types/types_state_id.h"
# include "parser/types/types_symbol.h"
# include "parser/types/types_symbol_metadata.h"
typedef bool (*t_lex_fn)(t_lexer *lex, t_state_id state);
typedef struct s_language
{
t_u32 version;
t_u32 symbol_count;
t_u32 alias_count;
t_u32 token_count;
t_u32 external_token_count;
t_u32 state_count;
t_u32 large_state_count;
t_u32 production_id_count;
t_u32 field_count;
t_u16 max_alias_sequence_length;
const t_u16 *parse_table;
const t_u16 *small_parse_table;
const t_u32 *small_parse_table_map;
const t_parse_action_entry *parse_actions;
const t_const_str *symbol_names;
const t_const_str *field_names;
const t_field_map_slice *field_map_slices;
const t_field_map_entry *field_map_entries;
const t_symbol_metadata *symbol_metadata;
const t_symbol *public_symbol_map;
const t_u16 *alias_map;
const t_symbol *alias_sequences;
const t_lex_modes *lex_modes;
t_lex_fn lex_fn;
t_lex_fn keyword_lex_fn;
t_symbol keyword_capture_token;
t_scanner external_scanner;
const t_state_id *primary_state_ids;
} t_language;
#endif /* TYPES_LANGUAGE_H */

View file

@ -0,0 +1,24 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* types_lex_modes.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/29 15:01:24 by maiboyer #+# #+# */
/* Updated: 2024/04/29 15:01:31 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef TYPES_LEX_MODES_H
# define TYPES_LEX_MODES_H
# include "me/types.h"
typedef struct s_lex_modes
{
t_u16 lex_state;
t_u16 external_lex_state;
} t_lex_modes;
#endif /* TYPES_LEX_MODES_H */

View file

@ -0,0 +1,30 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* types_lexer.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/29 14:45:45 by maiboyer #+# #+# */
/* Updated: 2024/04/29 14:46:48 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef TYPES_LEXER_H
# define TYPES_LEXER_H
# include "me/types.h"
# include "parser/types/types_symbol.h"
typedef struct s_lexer
{
t_u32 lookahead;
t_symbol result_symbol;
void (*advance)(struct s_lexer *, bool);
void (*mark_end)(struct s_lexer *);
t_u32 (*get_column)(struct s_lexer *);
bool (*is_at_included_range_start)(const struct s_lexer *);
bool (*eof)(const struct s_lexer *);
} t_lexer;
#endif /* TYPES_LEXER_H */

View file

@ -0,0 +1,28 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* types_lexer_state.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/29 14:50:20 by maiboyer #+# #+# */
/* Updated: 2024/04/29 14:51:00 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef TYPES_LEXER_STATE_H
# define TYPES_LEXER_STATE_H
# include "me/types.h"
# include "parser/types/types_state_id.h"
typedef struct s_lexer_state
{
t_u32 lookahead;
t_state_id state;
bool result;
bool skip;
bool eof;
} t_lexer_state;
#endif /* TYPES_LEXER_STATE_H */

View file

@ -0,0 +1,31 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* types_parse_action_entry.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/29 15:01:57 by maiboyer #+# #+# */
/* Updated: 2024/04/29 15:03:13 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef TYPES_PARSE_ACTION_ENTRY_H
# define TYPES_PARSE_ACTION_ENTRY_H
# include "me/types.h"
# include "parser/types/types_parse_actions.h"
struct s_parse_actions_entry_entry
{
t_u8 count;
bool reusable;
};
typedef union u_parse_actions_entry
{
t_parse_actions action;
struct s_parse_actions_entry_entry entry;
} t_parse_action_entry;
#endif /* TYPES_PARSE_ACTION_ENTRY_H */

View file

@ -0,0 +1,24 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* types_parse_action_type.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/29 14:57:22 by maiboyer #+# #+# */
/* Updated: 2024/04/29 14:57:32 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef TYPES_PARSE_ACTION_TYPE_H
# define TYPES_PARSE_ACTION_TYPE_H
typedef enum e_parse_action_type
{
ActionTypeShift,
ActionTypeReduce,
ActionTypeAccept,
ActionTypeRecover,
} t_parse_action_type;
#endif /* TYPES_PARSE_ACTION_TYPE_H */

View file

@ -0,0 +1,44 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* types_parse_actions.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/29 14:58:36 by maiboyer #+# #+# */
/* Updated: 2024/04/29 15:00:51 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef TYPES_PARSE_ACTIONS_H
# define TYPES_PARSE_ACTIONS_H
# include "me/types.h"
# include "parser/types/types_state_id.h"
# include "parser/types/types_symbol.h"
struct s_parse_action_shift
{
t_u8 type;
t_state_id state;
bool extra;
bool repetition;
};
struct s_parse_action_reduce
{
t_u8 type;
t_u8 child_count;
t_symbol symbol;
t_i16 dynamic_precedence;
t_u16 production_id;
};
typedef union u_parse_actions
{
struct s_parse_action_shift shift;
struct s_parse_action_reduce reduce;
t_u8 type;
} t_parse_actions;
#endif /* TYPES_PARSE_ACTIONS_H */

View file

@ -0,0 +1,26 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* types_parser_node.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/29 14:36:46 by maiboyer #+# #+# */
/* Updated: 2024/04/29 14:37:36 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef TYPES_PARSER_NODE_H
# define TYPES_PARSER_NODE_H
# include "me/types.h"
# include "parser/types/types_parser_tree.h"
typedef struct s_parser_node
{
t_u32 context[4];
const void *id;
const t_parser_tree *tree;
} t_parser_node;
#endif /* TYPES_PARSER_NODE_H */

View file

@ -0,0 +1,28 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* types_parser_range.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/29 14:11:26 by maiboyer #+# #+# */
/* Updated: 2024/04/29 14:25:11 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef TYPES_PARSER_RANGE_H
# define TYPES_PARSER_RANGE_H
# include "me/types.h"
# include "parser/types/types_point.h"
typedef struct s_parser_range
{
t_point start_point;
t_point end_point;
t_u32 start_byte;
t_u32 end_byte;
} t_parser_range;
#endif /* TYPES_PARSER_RANGE_H */

View file

@ -0,0 +1,16 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* types_parser_subtree.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/29 14:49:40 by maiboyer #+# #+# */
/* Updated: 2024/04/29 14:49:40 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef TYPES_PARSER_SUBTREE_H
# define TYPES_PARSER_SUBTREE_H
#endif /* TYPES_PARSER_SUBTREE_H */

View file

@ -0,0 +1,29 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* types_parser_tree.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/29 14:37:41 by maiboyer #+# #+# */
/* Updated: 2024/04/29 14:49:20 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef TYPES_PARSER_TREE_H
# define TYPES_PARSER_TREE_H
# include "me/types.h"
# include "parser/types/types_language.h"
# include "parser/types/types_parser_range.h"
# include "parser/types/types_parser_subtree.h"
typedef struct s_parser_tree
{
t_parser_subtree root;
const t_language *language;
t_parser_range *included_ranges;
t_i32 included_range_count;
} t_parser_tree;
#endif /* TYPES_PARSER_TREE_H */

View file

@ -0,0 +1,24 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* types_point.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/29 14:20:34 by maiboyer #+# #+# */
/* Updated: 2024/04/29 14:21:16 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef TYPES_POINT_H
# define TYPES_POINT_H
# include "me/types.h"
typedef struct s_point
{
t_u32 row;
t_u32 column;
} t_point;
#endif /* TYPES_POINT_H */

View file

@ -0,0 +1,39 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* types_scanner.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/29 14:42:52 by maiboyer #+# #+# */
/* Updated: 2024/04/29 15:34:21 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef TYPES_SCANNER_H
# define TYPES_SCANNER_H
# include "me/types.h"
# include "parser/types/types_lexer.h"
# include "parser/types/types_symbol.h"
typedef bool (*t_scanner_scan)(void *self, t_lexer *lex,
const bool *symbol_whitelist);
typedef void *(*t_scanner_create)(void);
typedef void (*t_scanner_destroy)(void *ctx);
typedef unsigned (*t_scanner_serialize)(void *self, t_str s);
typedef void (*t_scanner_deserialize)(void *self, t_const_str s,
t_u32 len);
typedef struct s_scanner
{
const bool *states;
const t_symbol *symbol_map;
t_scanner_create create;
t_scanner_destroy destroy;
t_scanner_scan scan;
t_scanner_serialize serialize;
t_scanner_deserialize deserialize;
} t_scanner;
#endif /* TYPES_SCANNER_H */

View file

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* types_state_id.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/29 14:44:15 by maiboyer #+# #+# */
/* Updated: 2024/04/29 14:44:47 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef TYPES_STATE_ID_H
# define TYPES_STATE_ID_H
# include "me/types.h"
typedef t_u16 t_state_id;
#endif /* TYPES_STATE_ID_H */

View file

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* types_symbol.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/29 14:43:33 by maiboyer #+# #+# */
/* Updated: 2024/04/29 14:44:50 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef TYPES_SYMBOL_H
# define TYPES_SYMBOL_H
# include "me/types.h"
typedef t_u16 t_symbol;
#endif /* TYPES_SYMBOL_H */

View file

@ -0,0 +1,25 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* types_symbol_metadata.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/29 14:55:57 by maiboyer #+# #+# */
/* Updated: 2024/04/29 14:56:04 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef TYPES_SYMBOL_METADATA_H
# define TYPES_SYMBOL_METADATA_H
# include "me/types.h"
typedef struct s_symbol_metadata
{
bool visible;
bool named;
bool supertype;
} t_symbol_metadata;
#endif /* TYPES_SYMBOL_METADATA_H */