started to rename struct and stuff
This commit is contained in:
parent
ff4b0c471f
commit
54cefca53f
25 changed files with 2413 additions and 2431 deletions
|
|
@ -6,40 +6,37 @@
|
|||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/24 23:01:45 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/04/29 15:26:51 by maiboyer ### ########.fr */
|
||||
/* Updated: 2024/04/29 16:41:40 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef PARSETYPES_H
|
||||
#define PARSETYPES_H
|
||||
#ifndef PARSE_TYPES_H
|
||||
# define PARSE_TYPES_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
# include <stdbool.h>
|
||||
# include <stdint.h>
|
||||
|
||||
#define ts_builtin_sym_end 0
|
||||
#define ts_builtin_sym_error -1
|
||||
# include "me/types.h"
|
||||
# include "parser/types/types_char_range.h"
|
||||
# include "parser/types/types_field_id.h"
|
||||
# include "parser/types/types_field_map_entry.h"
|
||||
# include "parser/types/types_field_map_slice.h"
|
||||
# include "parser/types/types_language.h"
|
||||
# include "parser/types/types_lex_modes.h"
|
||||
# include "parser/types/types_lexer.h"
|
||||
# include "parser/types/types_lexer_state.h"
|
||||
# include "parser/types/types_parse_action_entry.h"
|
||||
# include "parser/types/types_parse_action_type.h"
|
||||
# include "parser/types/types_parse_actions.h"
|
||||
# include "parser/types/types_parser_range.h"
|
||||
# include "parser/types/types_point.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"
|
||||
|
||||
#include "me/types.h"
|
||||
#include "parser/types/types_field_id.h"
|
||||
#include "parser/types/types_field_map_entry.h"
|
||||
#include "parser/types/types_field_map_slice.h"
|
||||
#include "parser/types/types_language.h"
|
||||
#include "parser/types/types_lex_modes.h"
|
||||
#include "parser/types/types_lexer.h"
|
||||
#include "parser/types/types_lexer_state.h"
|
||||
#include "parser/types/types_parse_action_entry.h"
|
||||
#include "parser/types/types_parse_action_type.h"
|
||||
#include "parser/types/types_parse_actions.h"
|
||||
#include "parser/types/types_parser_range.h"
|
||||
#include "parser/types/types_point.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"
|
||||
#include "parser/types/types_char_range.h"
|
||||
|
||||
static inline bool lex_skip(t_state_id state_value, t_lexer *lexer,
|
||||
t_lexer_state *s)
|
||||
static inline bool lex_skip(t_state_id state_value, t_lexer *lexer,
|
||||
t_lexer_state *s)
|
||||
{
|
||||
(void)(lexer);
|
||||
s->skip = true;
|
||||
|
|
@ -47,16 +44,16 @@ static inline bool lex_skip(t_state_id state_value, t_lexer *lexer,
|
|||
return (true);
|
||||
};
|
||||
|
||||
static inline bool lex_advance(t_state_id state_value, t_lexer *lexer,
|
||||
t_lexer_state *s)
|
||||
static inline bool lex_advance(t_state_id state_value, t_lexer *lexer,
|
||||
t_lexer_state *s)
|
||||
{
|
||||
(void)(lexer);
|
||||
s->state = state_value;
|
||||
return (true);
|
||||
};
|
||||
|
||||
static inline bool lex_accept_token(t_symbol symbol_value, t_lexer *lexer,
|
||||
t_lexer_state *s)
|
||||
static inline bool lex_accept_token(t_symbol symbol_value, t_lexer *lexer,
|
||||
t_lexer_state *s)
|
||||
{
|
||||
s->result = true;
|
||||
lexer->result_symbol = symbol_value;
|
||||
|
|
@ -64,15 +61,15 @@ static inline bool lex_accept_token(t_symbol symbol_value, t_lexer *lexer,
|
|||
return (true);
|
||||
};
|
||||
|
||||
static inline bool lex_end_state(t_lexer *lexer, t_lexer_state *s)
|
||||
static inline bool lex_end_state(t_lexer *lexer, t_lexer_state *s)
|
||||
{
|
||||
(void)(lexer);
|
||||
(void)(s);
|
||||
return (false);
|
||||
};
|
||||
|
||||
static inline t_field_map_entry fmap_entry(t_field_id field_id,
|
||||
uint8_t child_index, bool inherited)
|
||||
static inline t_field_map_entry fmap_entry(t_field_id field_id,
|
||||
uint8_t child_index, bool inherited)
|
||||
{
|
||||
return ((t_field_map_entry){
|
||||
.field_id = field_id,
|
||||
|
|
@ -81,7 +78,7 @@ static inline t_field_map_entry fmap_entry(t_field_id field_id,
|
|||
});
|
||||
};
|
||||
|
||||
static inline t_field_map_slice fmap_slice(t_u16 index, t_u16 length)
|
||||
static inline t_field_map_slice fmap_slice(t_u16 index, t_u16 length)
|
||||
{
|
||||
return ((t_field_map_slice){
|
||||
.index = index,
|
||||
|
|
@ -89,8 +86,8 @@ static inline t_field_map_slice fmap_slice(t_u16 index, t_u16 length)
|
|||
});
|
||||
};
|
||||
|
||||
static inline t_symbol_metadata sym_metadata(bool visible, bool named,
|
||||
bool supertype)
|
||||
static inline t_symbol_metadata sym_metadata(bool visible, bool named,
|
||||
bool supertype)
|
||||
{
|
||||
return ((t_symbol_metadata){
|
||||
.visible = visible,
|
||||
|
|
@ -99,13 +96,13 @@ static inline t_symbol_metadata sym_metadata(bool visible, bool named,
|
|||
});
|
||||
};
|
||||
|
||||
static inline t_parse_action_entry entry(uint8_t count, bool reusable)
|
||||
static inline t_parse_action_entry entry(uint8_t count, bool reusable)
|
||||
{
|
||||
return ((t_parse_action_entry){
|
||||
.entry = {.count = count, .reusable = reusable}});
|
||||
return ((t_parse_action_entry){.entry = {.count = count,
|
||||
.reusable = reusable}});
|
||||
};
|
||||
|
||||
static inline t_parse_action_entry shift(t_state_id state_value)
|
||||
static inline t_parse_action_entry shift(t_state_id state_value)
|
||||
{
|
||||
return ((t_parse_action_entry){{.shift = {
|
||||
.type = ActionTypeShift,
|
||||
|
|
@ -113,57 +110,55 @@ static inline t_parse_action_entry shift(t_state_id state_value)
|
|||
}}});
|
||||
};
|
||||
|
||||
static inline t_parse_action_entry shift_repeat(t_state_id state_value)
|
||||
static inline t_parse_action_entry shift_repeat(t_state_id state_value)
|
||||
{
|
||||
return ((t_parse_action_entry){{.shift = {.type = ActionTypeShift,
|
||||
.state = (state_value),
|
||||
.repetition = true}}});
|
||||
.state = (state_value), .repetition = true}}});
|
||||
};
|
||||
|
||||
static inline t_parse_action_entry shift_extra(void)
|
||||
static inline t_parse_action_entry shift_extra(void)
|
||||
{
|
||||
return ((t_parse_action_entry){
|
||||
{.shift = {.type = ActionTypeShift, .extra = true}}});
|
||||
return ((t_parse_action_entry){{.shift = {.type = ActionTypeShift,
|
||||
.extra = true}}});
|
||||
};
|
||||
|
||||
static inline t_parse_action_entry reduce(
|
||||
static inline t_parse_action_entry reduce(
|
||||
|
||||
t_symbol symbol, uint8_t child_count, int16_t dynamic_precedence,
|
||||
t_u16 production_id)
|
||||
t_u16 production_id)
|
||||
{
|
||||
return (
|
||||
(t_parse_action_entry){{.reduce = {
|
||||
.type = ActionTypeReduce,
|
||||
.child_count = child_count,
|
||||
.symbol = symbol,
|
||||
.dynamic_precedence = dynamic_precedence,
|
||||
.production_id = production_id,
|
||||
}}});
|
||||
return ((t_parse_action_entry){{.reduce = {
|
||||
.type = ActionTypeReduce,
|
||||
.child_count = child_count,
|
||||
.symbol = symbol,
|
||||
.dynamic_precedence = dynamic_precedence,
|
||||
.production_id = production_id,
|
||||
}}});
|
||||
};
|
||||
|
||||
static inline t_parse_action_entry recover(void)
|
||||
static inline t_parse_action_entry recover(void)
|
||||
{
|
||||
return ((t_parse_action_entry){{.type = ActionTypeRecover}});
|
||||
};
|
||||
|
||||
static inline t_parse_action_entry accept(void)
|
||||
static inline t_parse_action_entry accept(void)
|
||||
{
|
||||
return ((t_parse_action_entry){{.type = ActionTypeAccept}});
|
||||
};
|
||||
|
||||
static inline bool set_contains(t_char_range *ranges, t_u32 len,
|
||||
int32_t lookahead)
|
||||
static inline bool set_contains(t_char_range *ranges, t_u32 len,
|
||||
int32_t lookahead)
|
||||
{
|
||||
t_u32 index = 0;
|
||||
t_u32 size = len - index;
|
||||
while (size > 1)
|
||||
{
|
||||
t_u32 half_size = size / 2;
|
||||
t_u32 mid_index = index + half_size;
|
||||
t_u32 half_size = size / 2;
|
||||
t_u32 mid_index = index + half_size;
|
||||
t_char_range *range = &ranges[mid_index];
|
||||
if (lookahead >= range->start && lookahead <= range->end)
|
||||
{
|
||||
return true;
|
||||
return (true);
|
||||
}
|
||||
else if (lookahead > range->end)
|
||||
{
|
||||
|
|
@ -175,8 +170,8 @@ static inline bool set_contains(t_char_range *ranges, t_u32 len,
|
|||
return (lookahead >= range->start && lookahead <= range->end);
|
||||
};
|
||||
|
||||
static inline bool advance_map_inner(t_u32 *map, t_u32 elems, t_lexer *l,
|
||||
t_lexer_state *s)
|
||||
static inline bool advance_map_inner(t_u32 *map, t_u32 elems, t_lexer *l,
|
||||
t_lexer_state *s)
|
||||
{
|
||||
t_u32 i;
|
||||
|
||||
|
|
@ -187,15 +182,15 @@ static inline bool advance_map_inner(t_u32 *map, t_u32 elems, t_lexer *l,
|
|||
if (map[i] == (t_u32)s->lookahead)
|
||||
{
|
||||
s->state = map[i + 1];
|
||||
return true;
|
||||
return (true);
|
||||
}
|
||||
i += 2;
|
||||
}
|
||||
return (false);
|
||||
};
|
||||
|
||||
static inline t_lex_modes lex_mode_external(t_u16 lex_state,
|
||||
t_u16 ext_lex_state)
|
||||
static inline t_lex_modes lex_mode_external(t_u16 lex_state,
|
||||
t_u16 ext_lex_state)
|
||||
{
|
||||
return ((t_lex_modes){
|
||||
.lex_state = lex_state,
|
||||
|
|
@ -203,21 +198,21 @@ static inline t_lex_modes lex_mode_external(t_u16 lex_state,
|
|||
});
|
||||
};
|
||||
|
||||
static inline t_lex_modes lex_mode_normal(t_u16 lex_state)
|
||||
static inline t_lex_modes lex_mode_normal(t_u16 lex_state)
|
||||
{
|
||||
return ((t_lex_modes){
|
||||
.lex_state = lex_state,
|
||||
});
|
||||
};
|
||||
|
||||
static inline t_u16 actions(t_u16 val)
|
||||
static inline t_u16 actions(t_u16 val)
|
||||
{
|
||||
return (val);
|
||||
};
|
||||
|
||||
static inline t_u16 state(t_u16 val)
|
||||
static inline t_u16 state(t_u16 val)
|
||||
{
|
||||
return (val);
|
||||
};
|
||||
|
||||
#endif /* PARSETYPES_H */
|
||||
#endif /* PARSE_TYPES_H */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue