did stuff, done stuff
This commit is contained in:
parent
4a8fb259dc
commit
62a4f377a1
37 changed files with 325 additions and 399 deletions
|
|
@ -16,19 +16,19 @@
|
|||
bool ts_lexer__eof(const TSLexer *_self);
|
||||
t_u32 ts_lexer__get_column(TSLexer *_self);
|
||||
void ts_lexer__advance(TSLexer *_self, bool skip);
|
||||
void ts_lexer__clear_chunk(Lexer *self);
|
||||
void ts_lexer__get_chunk(Lexer *self);
|
||||
void ts_lexer__get_lookahead(Lexer *self);
|
||||
void ts_lexer__clear_chunk(t_lexer *self);
|
||||
void ts_lexer__get_chunk(t_lexer *self);
|
||||
void ts_lexer__get_lookahead(t_lexer *self);
|
||||
void ts_lexer__mark_end(TSLexer *_self);
|
||||
void ts_lexer_advance_to_end(Lexer *self);
|
||||
void ts_lexer_goto(Lexer *self, Length position);
|
||||
void ts_lexer_advance_to_end(t_lexer *self);
|
||||
void ts_lexer_goto(t_lexer *self, Length position);
|
||||
|
||||
bool ts_lexer__do_advance_loop(Lexer *self, const TSRange **current_range);
|
||||
void ts_lexer__do_advance_after_loop(Lexer *self, bool skip,
|
||||
bool ts_lexer__do_advance_loop(t_lexer *self, const TSRange **current_range);
|
||||
void ts_lexer__do_advance_after_loop(t_lexer *self, bool skip,
|
||||
const TSRange *cur);
|
||||
|
||||
// Intended to be called only from functions that control logging.
|
||||
void ts_lexer__do_advance(Lexer *self, bool skip)
|
||||
void ts_lexer__do_advance(t_lexer *self, bool skip)
|
||||
{
|
||||
const TSRange *cur = \
|
||||
&self->included_ranges[self->current_included_range_index];
|
||||
|
|
@ -55,15 +55,15 @@ void ts_lexer__do_advance(Lexer *self, bool skip)
|
|||
// chunk of source code if needed.
|
||||
void ts_lexer__advance(TSLexer *_self, bool skip)
|
||||
{
|
||||
Lexer *self;
|
||||
t_lexer *self;
|
||||
|
||||
self = (Lexer *)_self;
|
||||
self = (t_lexer *)_self;
|
||||
if (!self->chunk)
|
||||
return ;
|
||||
ts_lexer__do_advance(self, skip);
|
||||
}
|
||||
|
||||
bool ts_lexer__do_advance_loop(Lexer *self, const TSRange **current_range)
|
||||
bool ts_lexer__do_advance_loop(t_lexer *self, const TSRange **current_range)
|
||||
{
|
||||
if (self->current_included_range_index < self->included_range_count)
|
||||
self->current_included_range_index++;
|
||||
|
|
@ -83,7 +83,7 @@ bool ts_lexer__do_advance_loop(Lexer *self, const TSRange **current_range)
|
|||
return (false);
|
||||
}
|
||||
|
||||
void ts_lexer__do_advance_after_loop(Lexer *self, bool skip,
|
||||
void ts_lexer__do_advance_after_loop(t_lexer *self, bool skip,
|
||||
const TSRange *cur)
|
||||
{
|
||||
if (skip)
|
||||
|
|
|
|||
|
|
@ -16,17 +16,17 @@
|
|||
bool ts_lexer__eof(const TSLexer *_self);
|
||||
t_u32 ts_lexer__get_column(TSLexer *_self);
|
||||
void ts_lexer__advance(TSLexer *_self, bool skip);
|
||||
void ts_lexer__do_advance(Lexer *self, bool skip);
|
||||
void ts_lexer__clear_chunk(Lexer *self);
|
||||
void ts_lexer__get_chunk(Lexer *self);
|
||||
void ts_lexer__get_lookahead(Lexer *self);
|
||||
void ts_lexer__do_advance(t_lexer *self, bool skip);
|
||||
void ts_lexer__clear_chunk(t_lexer *self);
|
||||
void ts_lexer__get_chunk(t_lexer *self);
|
||||
void ts_lexer__get_lookahead(t_lexer *self);
|
||||
void ts_lexer__mark_end(TSLexer *_self);
|
||||
void ts_lexer_advance_to_end(Lexer *self);
|
||||
void ts_lexer_goto(Lexer *self, Length position);
|
||||
void ts_lexer_advance_to_end(t_lexer *self);
|
||||
void ts_lexer_goto(t_lexer *self, Length position);
|
||||
|
||||
// Clear the currently stored chunk of source code, because the lexer's
|
||||
// position has changed.
|
||||
void ts_lexer__clear_chunk(Lexer *self)
|
||||
void ts_lexer__clear_chunk(t_lexer *self)
|
||||
{
|
||||
self->chunk = NULL;
|
||||
self->chunk_size = 0;
|
||||
|
|
@ -35,7 +35,7 @@ void ts_lexer__clear_chunk(Lexer *self)
|
|||
|
||||
// Call the lexer's input callback to obtain a new chunk of source code
|
||||
// for the current position.
|
||||
void ts_lexer__get_chunk(Lexer *self)
|
||||
void ts_lexer__get_chunk(t_lexer *self)
|
||||
{
|
||||
self->chunk_start = self->current_position.bytes;
|
||||
self->chunk = self->input.read(self->input.payload,
|
||||
|
|
|
|||
|
|
@ -16,22 +16,22 @@
|
|||
bool ts_lexer__eof(const TSLexer *_self);
|
||||
t_u32 ts_lexer__get_column(TSLexer *_self);
|
||||
void ts_lexer__advance(TSLexer *_self, bool skip);
|
||||
void ts_lexer__do_advance(Lexer *self, bool skip);
|
||||
void ts_lexer__clear_chunk(Lexer *self);
|
||||
void ts_lexer__get_chunk(Lexer *self);
|
||||
void ts_lexer__get_lookahead(Lexer *self);
|
||||
void ts_lexer__do_advance(t_lexer *self, bool skip);
|
||||
void ts_lexer__clear_chunk(t_lexer *self);
|
||||
void ts_lexer__get_chunk(t_lexer *self);
|
||||
void ts_lexer__get_lookahead(t_lexer *self);
|
||||
void ts_lexer__mark_end(TSLexer *_self);
|
||||
void ts_lexer_advance_to_end(Lexer *self);
|
||||
void ts_lexer_goto(Lexer *self, Length position);
|
||||
void ts_lexer_advance_to_end(t_lexer *self);
|
||||
void ts_lexer_goto(t_lexer *self, Length position);
|
||||
|
||||
// Check if the lexer has reached EOF. This state is stored
|
||||
// by setting the lexer's `current_included_range_index` such that
|
||||
// it has consumed all of its available ranges.
|
||||
bool ts_lexer__eof(const TSLexer *_self)
|
||||
{
|
||||
Lexer *self;
|
||||
t_lexer *self;
|
||||
|
||||
self = (Lexer *)_self;
|
||||
self = (t_lexer *)_self;
|
||||
return (self->current_included_range_index == self->included_range_count);
|
||||
}
|
||||
|
||||
|
|
@ -39,11 +39,11 @@ bool ts_lexer__eof(const TSLexer *_self)
|
|||
// times if a longer match is found later.
|
||||
void ts_lexer__mark_end(TSLexer *_self)
|
||||
{
|
||||
Lexer *self;
|
||||
t_lexer *self;
|
||||
TSRange *current_included_range;
|
||||
TSRange *previous_included_range;
|
||||
|
||||
self = (Lexer *)_self;
|
||||
self = (t_lexer *)_self;
|
||||
if (!ts_lexer__eof(&self->data))
|
||||
{
|
||||
current_included_range = \
|
||||
|
|
@ -62,7 +62,7 @@ void ts_lexer__mark_end(TSLexer *_self)
|
|||
self->token_end_position = self->current_position;
|
||||
}
|
||||
|
||||
void ts_lexer_advance_to_end(Lexer *self)
|
||||
void ts_lexer_advance_to_end(t_lexer *self)
|
||||
{
|
||||
while (self->chunk)
|
||||
ts_lexer__advance(&self->data, false);
|
||||
|
|
|
|||
|
|
@ -16,21 +16,21 @@
|
|||
bool ts_lexer__eof(const TSLexer *_self);
|
||||
t_u32 ts_lexer__get_column(TSLexer *_self);
|
||||
void ts_lexer__advance(TSLexer *_self, bool skip);
|
||||
void ts_lexer__do_advance(Lexer *self, bool skip);
|
||||
void ts_lexer__clear_chunk(Lexer *self);
|
||||
void ts_lexer__get_chunk(Lexer *self);
|
||||
void ts_lexer__get_lookahead(Lexer *self);
|
||||
void ts_lexer__do_advance(t_lexer *self, bool skip);
|
||||
void ts_lexer__clear_chunk(t_lexer *self);
|
||||
void ts_lexer__get_chunk(t_lexer *self);
|
||||
void ts_lexer__get_lookahead(t_lexer *self);
|
||||
void ts_lexer__mark_end(TSLexer *_self);
|
||||
void ts_lexer_advance_to_end(Lexer *self);
|
||||
void ts_lexer_goto(Lexer *self, Length position);
|
||||
void ts_lexer_advance_to_end(t_lexer *self);
|
||||
void ts_lexer_goto(t_lexer *self, Length position);
|
||||
|
||||
t_u32 ts_lexer__get_column(TSLexer *_self)
|
||||
{
|
||||
Lexer *self;
|
||||
t_lexer *self;
|
||||
t_u32 goal_byte;
|
||||
t_u32 result;
|
||||
|
||||
self = (Lexer *)_self;
|
||||
self = (t_lexer *)_self;
|
||||
goal_byte = self->current_position.bytes;
|
||||
self->did_get_column = true;
|
||||
self->current_position.bytes -= self->current_position.extent.column;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/08/31 18:08:11 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/08/31 18:25:58 by maiboyer ### ########.fr */
|
||||
/* Updated: 2024/08/31 18:39:32 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -16,19 +16,19 @@
|
|||
bool ts_lexer__eof(const TSLexer *_self);
|
||||
t_u32 ts_lexer__get_column(TSLexer *_self);
|
||||
void ts_lexer__advance(TSLexer *_self, bool skip);
|
||||
void ts_lexer__do_advance(Lexer *self, bool skip);
|
||||
void ts_lexer__clear_chunk(Lexer *self);
|
||||
void ts_lexer__get_chunk(Lexer *self);
|
||||
void ts_lexer__get_lookahead(Lexer *self);
|
||||
void ts_lexer__do_advance(t_lexer *self, bool skip);
|
||||
void ts_lexer__clear_chunk(t_lexer *self);
|
||||
void ts_lexer__get_chunk(t_lexer *self);
|
||||
void ts_lexer__get_lookahead(t_lexer *self);
|
||||
void ts_lexer__mark_end(TSLexer *_self);
|
||||
void ts_lexer_advance_to_end(Lexer *self);
|
||||
void ts_lexer_goto(Lexer *self, Length position);
|
||||
void ts_lexer_advance_to_end(t_lexer *self);
|
||||
void ts_lexer_goto(t_lexer *self, Length position);
|
||||
|
||||
void ts_lexer_goto_inside_loop(Lexer *self, bool *found_included_range,
|
||||
void ts_lexer_goto_inside_loop(t_lexer *self, bool *found_included_range,
|
||||
TSRange *included_range, t_usize i);
|
||||
void ts_lexer_goto_after_loop(Lexer *self, bool found_included_range);
|
||||
void ts_lexer_goto_after_loop(t_lexer *self, bool found_included_range);
|
||||
|
||||
void ts_lexer_goto(Lexer *self, Length position)
|
||||
void ts_lexer_goto(t_lexer *self, Length position)
|
||||
{
|
||||
bool found_included_range;
|
||||
TSRange *included_range;
|
||||
|
|
@ -53,7 +53,7 @@ void ts_lexer_goto(Lexer *self, Length position)
|
|||
ts_lexer_goto_after_loop(self, found_included_range);
|
||||
}
|
||||
|
||||
void ts_lexer_goto_inside_loop(Lexer *self, bool *found_included_range,
|
||||
void ts_lexer_goto_inside_loop(t_lexer *self, bool *found_included_range,
|
||||
TSRange *included_range, t_usize i)
|
||||
{
|
||||
if (included_range->start_byte >= self->current_position.bytes)
|
||||
|
|
@ -67,7 +67,7 @@ void ts_lexer_goto_inside_loop(Lexer *self, bool *found_included_range,
|
|||
*found_included_range = true;
|
||||
}
|
||||
|
||||
void ts_lexer_goto_after_loop(Lexer *self, bool found_included_range)
|
||||
void ts_lexer_goto_after_loop(t_lexer *self, bool found_included_range)
|
||||
{
|
||||
TSRange *last_included_range;
|
||||
|
||||
|
|
|
|||
|
|
@ -18,20 +18,20 @@
|
|||
bool ts_lexer__eof(const TSLexer *_self);
|
||||
t_u32 ts_lexer__get_column(TSLexer *_self);
|
||||
void ts_lexer__advance(TSLexer *_self, bool skip);
|
||||
void ts_lexer__clear_chunk(Lexer *self);
|
||||
void ts_lexer__get_chunk(Lexer *self);
|
||||
void ts_lexer__get_lookahead(Lexer *self);
|
||||
void ts_lexer__clear_chunk(t_lexer *self);
|
||||
void ts_lexer__get_chunk(t_lexer *self);
|
||||
void ts_lexer__get_lookahead(t_lexer *self);
|
||||
void ts_lexer__mark_end(TSLexer *_self);
|
||||
void ts_lexer_advance_to_end(Lexer *self);
|
||||
void ts_lexer_goto(Lexer *self, Length position);
|
||||
void ts_lexer_advance_to_end(t_lexer *self);
|
||||
void ts_lexer_goto(t_lexer *self, Length position);
|
||||
|
||||
void ts_lexer_init(Lexer *self)
|
||||
void ts_lexer_init(t_lexer *self)
|
||||
{
|
||||
static TSRange default_range = {.start_point = {\
|
||||
.row = 0, .column = 0, }, .end_point = {.row = UINT32_MAX, \
|
||||
.column = UINT32_MAX, }, .start_byte = 0, .end_byte = UINT32_MAX};
|
||||
|
||||
*self = (Lexer){
|
||||
*self = (t_lexer){
|
||||
.data = {
|
||||
.advance = ts_lexer__advance,
|
||||
.mark_end = ts_lexer__mark_end,
|
||||
|
|
@ -49,20 +49,20 @@ void ts_lexer_init(Lexer *self)
|
|||
};
|
||||
}
|
||||
|
||||
void ts_lexer_set_input(Lexer *self, TSInput input)
|
||||
void ts_lexer_set_input(t_lexer *self, TSInput input)
|
||||
{
|
||||
self->input = input;
|
||||
ts_lexer__clear_chunk(self);
|
||||
ts_lexer_goto(self, self->current_position);
|
||||
}
|
||||
|
||||
void ts_lexer_reset(Lexer *self, Length position)
|
||||
void ts_lexer_reset(t_lexer *self, Length position)
|
||||
{
|
||||
if (position.bytes != self->current_position.bytes)
|
||||
ts_lexer_goto(self, position);
|
||||
}
|
||||
|
||||
void ts_lexer_start(Lexer *self)
|
||||
void ts_lexer_start(t_lexer *self)
|
||||
{
|
||||
self->token_start_position = self->current_position;
|
||||
self->token_end_position = LENGTH_UNDEFINED;
|
||||
|
|
@ -80,7 +80,7 @@ void ts_lexer_start(Lexer *self)
|
|||
}
|
||||
}
|
||||
|
||||
void ts_lexer_finish(Lexer *self, t_u32 *lookahead_end_byte)
|
||||
void ts_lexer_finish(t_lexer *self, t_u32 *lookahead_end_byte)
|
||||
{
|
||||
if (length_is_undefined(self->token_end_position))
|
||||
ts_lexer__mark_end(&self->data);
|
||||
|
|
|
|||
|
|
@ -17,15 +17,15 @@
|
|||
bool ts_lexer__eof(const TSLexer *_self);
|
||||
t_u32 ts_lexer__get_column(TSLexer *_self);
|
||||
void ts_lexer__advance(TSLexer *_self, bool skip);
|
||||
void ts_lexer__do_advance(Lexer *self, bool skip);
|
||||
void ts_lexer__clear_chunk(Lexer *self);
|
||||
void ts_lexer__get_chunk(Lexer *self);
|
||||
void ts_lexer__get_lookahead(Lexer *self);
|
||||
void ts_lexer__do_advance(t_lexer *self, bool skip);
|
||||
void ts_lexer__clear_chunk(t_lexer *self);
|
||||
void ts_lexer__get_chunk(t_lexer *self);
|
||||
void ts_lexer__get_lookahead(t_lexer *self);
|
||||
void ts_lexer__mark_end(TSLexer *_self);
|
||||
void ts_lexer_advance_to_end(Lexer *self);
|
||||
void ts_lexer_goto(Lexer *self, Length position);
|
||||
void ts_lexer_advance_to_end(t_lexer *self);
|
||||
void ts_lexer_goto(t_lexer *self, Length position);
|
||||
|
||||
void ts_lexer__get_lookahead(Lexer *self)
|
||||
void ts_lexer__get_lookahead(t_lexer *self)
|
||||
{
|
||||
t_u32 position_in_chunk;
|
||||
t_u32 size;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue