I NEED TO REDO THE LEX FUNCTION LETZGO :(((((((

This commit is contained in:
Maieul BOYER 2024-06-30 19:15:27 +02:00
parent c7fe19a7d5
commit 61fd72480e
No known key found for this signature in database
20 changed files with 5173 additions and 12 deletions

View file

@ -6,7 +6,7 @@
# By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2023/11/03 13:20:01 by maiboyer #+# #+# #
# Updated: 2024/06/30 18:15:08 by maiboyer ### ########.fr #
# Updated: 2024/06/30 18:45:33 by maiboyer ### ########.fr #
# #
# **************************************************************************** #

View file

@ -14,8 +14,8 @@
#include "../static/headers/symbols.h"
#include "./parser.h"
bool lex_keywords_main(TSLexer *lexer, TSStateId state);
bool lex_normal_main(TSLexer *lexer, TSStateId state);
// bool lex_keywords_main(TSLexer *lexer, TSStateId state);
// bool lex_normal_main(TSLexer *lexer, TSStateId state);
bool tree_sitter_sh_external_scanner_scan(void *ctx, TSLexer *lexer, const bool *ret);
void *create_external_scanner_states(void);
void *create_field_names(void);
@ -33,6 +33,8 @@ void *create_symbols_metadata(void);
void *create_parse_table(void);
void *create_small_parse_table(void);
void *create_small_parse_table_map(void);
bool ts_lex_keywords(TSLexer *lexer, TSStateId state);
bool ts_lex_keywords(TSLexer *lexer, TSStateId state);
uint32_t tree_sitter_sh_external_scanner_serialize(void *ctx, char *s);
void tree_sitter_sh_external_scanner_deserialize(void *ctx, const char *s, uint32_t val);
@ -68,8 +70,8 @@ static void init_language(TSLanguage *language)
language->alias_sequences = create_alias_sequences();
language->lex_modes = create_lex_modes();
language->primary_state_ids = create_primary_state_ids();
language->lex_fn = lex_normal_main;
language->keyword_lex_fn = lex_keywords_main;
language->lex_fn = ts_lex;
language->keyword_lex_fn = ts_lex_keywords;
language->keyword_capture_token = sym_word;
language->external_scanner = init_scanner();
}

5162
parser/src/lex.c Normal file

File diff suppressed because it is too large Load diff

View file

@ -12,6 +12,6 @@
#include "./tree.c"
#include "./tree_cursor.c"
#include "./wasm_store.c"
#include "./lex.c"
#include "./create_language.c"
#include "./scanner.c"

View file

@ -26,20 +26,18 @@ static inline uint32_t ts_decode_ascii(const uint8_t *string, uint32_t length, i
static inline uint32_t ts_decode_utf8(const uint8_t *string, uint32_t length, int32_t *code_point)
{
return (ts_decode_ascii(string, length, code_point));
/*
return (ts_decode_ascii(string, length, code_point));
/*
uint32_t i = 0;
U8_NEXT(string, i, length, *code_point);
printf("[UTF8]read %i bytes\n", i);
return i;
*/
*/
}
static inline uint32_t ts_decode_utf16(const uint8_t *string, uint32_t length, int32_t *code_point)
{
uint32_t i = 0;
U16_NEXT(((uint16_t *)string), i, length, *code_point);
printf("[UTF16]read %i bytes\n", i);
return i * 2;
}

View file

@ -12,7 +12,6 @@
#ifndef CONSTANTS_H
# define CONSTANTS_H
# define LANGUAGE_VERSION 14
# define STATE_COUNT 2340
# define LARGE_STATE_COUNT 2