update: almost fully normed parser/src/stack !
This commit is contained in:
parent
bec1320c5f
commit
cff5618664
9 changed files with 316 additions and 253 deletions
|
|
@ -6,12 +6,13 @@
|
|||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/08/31 16:58:39 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/08/31 16:58:51 by maiboyer ### ########.fr */
|
||||
/* Updated: 2024/09/19 18:37:14 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "parser/inner/stack_inner.h"
|
||||
#include "parser/inner/stack_inner.h"
|
||||
#include "parser/language.h"
|
||||
|
||||
t_u32 ts_stack_version_count(const t_stack *self)
|
||||
{
|
||||
|
|
@ -33,3 +34,21 @@ t_subtree ts_stack_last_external_token(const t_stack *self,
|
|||
{
|
||||
return (array_get(&self->heads, version)->last_external_token);
|
||||
}
|
||||
|
||||
/// Get the number of nodes in the subtree, for the purpose of measuring
|
||||
/// how much progress has been made by a given version of the stack.
|
||||
//
|
||||
// Count intermediate error nodes even though they are not visible,
|
||||
// because a stack version's node count is used to check whether it
|
||||
// has made any progress since the last time it encountered an error.
|
||||
t_u32 stack__subtree_node_count(t_subtree subtree)
|
||||
{
|
||||
t_u32 count;
|
||||
|
||||
count = ts_subtree_visible_descendant_count(subtree);
|
||||
if (ts_subtree_visible(subtree))
|
||||
count++;
|
||||
if (ts_subtree_symbol(subtree) == ts_builtin_sym_error_repeat)
|
||||
count++;
|
||||
return (count);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue