Started from buttom go to the sky
This commit is contained in:
parent
96215449bd
commit
f811e55dea
4781 changed files with 10121 additions and 1743 deletions
|
|
@ -1,91 +0,0 @@
|
|||
# **************************************************************************** #
|
||||
# #
|
||||
# ::: :::::::: #
|
||||
# Makefile :+: :+: :+: #
|
||||
# +:+ +:+ +:+ #
|
||||
# By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ #
|
||||
# +#+#+#+#+#+ +#+ #
|
||||
# Created: 2023/11/12 11:05:05 by rparodi #+# #+# #
|
||||
# Updated: 2024/04/28 19:53:00 by maiboyer ### ########.fr #
|
||||
# #
|
||||
# **************************************************************************** #
|
||||
|
||||
# Objdir
|
||||
OBJDIRNAME = ./build
|
||||
|
||||
# Colors
|
||||
GREEN = \033[32m
|
||||
GREY = \033[0;90m
|
||||
RED = \033[0;31m
|
||||
GOLD = \033[38;5;220m
|
||||
END = \033[0m
|
||||
|
||||
# Rules
|
||||
|
||||
NAME = minishell
|
||||
|
||||
# All (make all)
|
||||
all:
|
||||
@$(MAKE) --no-print-directory header OBJDIRNAME=$(OBJDIRNAME)
|
||||
@$(MAKE) --no-print-directory -f./Minishell.mk OBJDIRNAME=$(OBJDIRNAME)
|
||||
@$(MAKE) --no-print-directory footer OBJDIRNAME=$(OBJDIRNAME)
|
||||
|
||||
bonus:
|
||||
@$(MAKE) --no-print-directory header OBJDIRNAME=$(OBJDIRNAME)
|
||||
@$(MAKE) --no-print-directory -f./Minishell.mk OBJDIRNAME=$(OBJDIRNAME) bonus
|
||||
@$(MAKE) --no-print-directory footer OBJDIRNAME=$(OBJDIRNAME)
|
||||
|
||||
# Header
|
||||
header:
|
||||
@clear
|
||||
@printf '\n\n'
|
||||
@printf '$(GOLD) ******* ****** ******* $(END)\n'
|
||||
@printf '$(GOLD) ****** *** ******* $(END)\n'
|
||||
@printf '$(GOLD) ******* * ******* $(END)\n'
|
||||
@printf '$(GOLD) ****** ******* $(END)\n'
|
||||
@printf '$(GOLD) ******* ******* $(END)\n'
|
||||
@printf '$(GOLD) ******************* ******* * $(END)\n'
|
||||
@printf '$(GOLD) ******************* ******* *** $(END)\n'
|
||||
@printf '$(GOLD) ****** ******* ****** $(END)\n'
|
||||
@printf '$(GOLD) ****** $(END)\n'
|
||||
@printf '$(GOLD) ****** $(END)\n'
|
||||
@printf '$(GREY) Made by maiboyerlpb x rparodi$(END)\n\n'
|
||||
|
||||
# Footer
|
||||
footer:
|
||||
@printf "$(GOLD) shcat\n"
|
||||
@printf "$(GOLD) ,_ _,$(END)\n"
|
||||
@printf "$(GOLD) | \\___//|$(END)\n"
|
||||
@printf "$(GOLD) |=6 6=|$(END)\n"
|
||||
@printf "$(GOLD) \\=._Y_.=/$(END)\n"
|
||||
@printf "$(GOLD) ) \` ( ,$(END)\n"
|
||||
@printf "$(GOLD) / \\ (('$(END)\n"
|
||||
@printf "$(GOLD) | | ))$(END)\n"
|
||||
@printf "$(GOLD) /| | | |\\_//$(END)\n"
|
||||
@printf "$(GOLD) \\| |._.| |/-\`$(END)\n"
|
||||
@printf "$(GOLD) '\"' '\"'$(END)\n"
|
||||
@printf ' $(GREY)The compilation is$(END) $(GOLD)finish$(END)\n $(GREY)Have a good $(END)$(GOLD)correction !$(END)\n'
|
||||
|
||||
pull:
|
||||
@printf "$(GREEN)Pulling Submodules$(END)\n"
|
||||
@git submodule init
|
||||
@git submodule update
|
||||
|
||||
# Clean (make clean)
|
||||
clean:
|
||||
@echo -e '$(GREY) Removing $(END)$(RED)Objects$(END)'
|
||||
@echo -e '$(GREY) Removing $(END)$(RED)Objects Folder$(END)'
|
||||
@$(RM) -r $(OBJDIRNAME)
|
||||
|
||||
# Clean (make fclean)
|
||||
fclean: clean
|
||||
@echo -e '$(GREY) Removing $(END)$(RED)Program$(END)'
|
||||
@$(RM) $(NAME)
|
||||
@echo ""
|
||||
|
||||
# Restart (make re)
|
||||
re: header
|
||||
@$(MAKE) --no-print-directory fclean
|
||||
@$(MAKE) --no-print-directory all
|
||||
# phony
|
||||
.PHONY: all bonus clean fclean re
|
||||
|
|
@ -1,87 +0,0 @@
|
|||
# **************************************************************************** #
|
||||
# #
|
||||
# ::: :::::::: #
|
||||
# Minishell.mk :+: :+: :+: #
|
||||
# +:+ +:+ +:+ #
|
||||
# By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ #
|
||||
# +#+#+#+#+#+ +#+ #
|
||||
# Created: 2024/04/28 17:28:30 by maiboyer #+# #+# #
|
||||
# Updated: 2024/04/28 19:52:08 by maiboyer ### ########.fr #
|
||||
# #
|
||||
# **************************************************************************** #
|
||||
|
||||
# Variables
|
||||
|
||||
OBJDIRNAME ?=
|
||||
|
||||
# Flags
|
||||
CFLAGS = -Werror -Wextra -Wall -Wno-unused-command-line-argument -g3 -MMD -lreadline -I./includes
|
||||
# Sources
|
||||
LIB = ./libft/ft_bzero.c \
|
||||
./libft/ft_calloc.c \
|
||||
./libft/ft_memset.c \
|
||||
./libft/ft_split.c \
|
||||
./libft/ft_strcmp.c \
|
||||
./libft/ft_strdup.c \
|
||||
./libft/ft_strlcpy.c \
|
||||
./libft/ft_strjoin.c \
|
||||
./libft/ft_strlen.c
|
||||
|
||||
SRC = ./sources/ft_cmd.c \
|
||||
./sources/ft_echo.c \
|
||||
./sources/ft_exit.c \
|
||||
./sources/ft_pwd.c \
|
||||
./sources/main.c \
|
||||
./sources/node/node.c
|
||||
|
||||
# Name
|
||||
NAME = minishell
|
||||
LIBDIRNAME = libft
|
||||
SRCDIRNAME = sources
|
||||
|
||||
# Commands
|
||||
CC = cc
|
||||
RM = rm -rf
|
||||
|
||||
# Objects
|
||||
OBJ = $(addprefix $(OBJDIRNAME)/,$(SRC:.c=.o))
|
||||
LIB_OBJ = $(addprefix $(OBJDIRNAME)/,$(LIB:.c=.o))
|
||||
|
||||
# Colors
|
||||
GREEN = \033[32m
|
||||
GREY = \033[0;90m
|
||||
RED = \033[0;31m
|
||||
GOLD = \033[38;5;220m
|
||||
END = \033[0m
|
||||
|
||||
.PHONY: all bonus
|
||||
|
||||
all:
|
||||
@$(MAKE) -C ./stdme/ LIB_NAME="$(shell realpath ./stdme)/" "BUILD_DIR=$(shell realpath ./$(OBJDIRNAME))" libme.a
|
||||
@$(MAKE) -C ./parser/ LIB_NAME="$(shell realpath ./parser)/" "BUILD_DIR=$(shell realpath ./$(OBJDIRNAME))" libgmr.a
|
||||
@$(MAKE) -f./Minishell.mk $(NAME)
|
||||
|
||||
__build_final: $(NAME)
|
||||
|
||||
# Bonus (make bonus)
|
||||
bonus: $(OBJ) $(LIB_OBJ) $(OBJDIRNAME)/libme.a $(OBJDIRNAME)/libgmr.a
|
||||
@mkdir -p $(OBJDIRNAME)
|
||||
@mkdir -p $(OBJDIRNAME)/$(LIBDIRNAME)
|
||||
@mkdir -p $(OBJDIRNAME)/$(SRCDIRNAME)
|
||||
@printf '$(GREY) Be Carefull ur in $(END)$(GREEN)Debug Mode$(END)\n'
|
||||
@cc $(CFLAGS) -D DEBUG=42 -o $(NAME) $(OBJ) -L$(OBJDIRNAME) -lme -lgmr
|
||||
|
||||
# Dependences for all
|
||||
$(NAME): $(OBJ) $(LIB_OBJ)
|
||||
@mkdir -p $(OBJDIRNAME)
|
||||
@mkdir -p $(OBJDIRNAME)/$(LIBDIRNAME)
|
||||
@mkdir -p $(OBJDIRNAME)/$(SRCDIRNAME)
|
||||
@cc $(CFLAGS) -o $(NAME) $(OBJ) $(LIB_OBJ) -L$(OBJDIRNAME) -lme -lgmr
|
||||
|
||||
# Creating the objects
|
||||
$(OBJDIRNAME)/%.o: %.c
|
||||
@mkdir -p $(dir $@)
|
||||
@printf '$(GREY) Compiling $(END)$(GREEN)$<$(END)\n'
|
||||
@cc $(CFLAGS) -o $@ -c $<
|
||||
|
||||
-include ${OBJ:.o=.d}
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* node.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/28 18:35:22 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/04/28 18:53:13 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef NODE_H
|
||||
#define NODE_H
|
||||
|
||||
#include "me/types.h"
|
||||
#include "parser/api.h"
|
||||
|
||||
typedef struct s_node
|
||||
{
|
||||
t_u64 kind;
|
||||
const char *kind_str;
|
||||
const char *input;
|
||||
char *single_str;
|
||||
t_usize start;
|
||||
t_usize end;
|
||||
t_usize childs_count;
|
||||
struct s_node *childs;
|
||||
} t_node;
|
||||
|
||||
t_node build_node(TSNode curr, t_const_str input);
|
||||
t_str node_getstr(t_node *node);
|
||||
void free_node(t_node t);
|
||||
|
||||
#endif /* NODE_H */
|
||||
|
|
@ -1 +0,0 @@
|
|||
../stdme/include/me/
|
||||
|
|
@ -1,57 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* minishell.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/03/28 14:41:15 by rparodi #+# #+# */
|
||||
/* Updated: 2024/04/28 18:34:45 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef MINISHELL_H
|
||||
#define MINISHELL_H
|
||||
|
||||
# include "me/types.h"
|
||||
|
||||
# include <unistd.h>
|
||||
# include <fcntl.h>
|
||||
# include <stdlib.h>
|
||||
# include <stdio.h>
|
||||
# include <string.h>
|
||||
# include <sys/types.h>
|
||||
# include <sys/wait.h>
|
||||
# include <stdlib.h>
|
||||
# include <stdarg.h>
|
||||
# include <readline/readline.h>
|
||||
# include <readline/history.h>
|
||||
|
||||
typedef struct s_utils
|
||||
{
|
||||
t_str name_shell;
|
||||
t_str str_input;
|
||||
t_str *strs_input;
|
||||
t_str *path;
|
||||
t_str *envp;
|
||||
} t_utils;
|
||||
|
||||
t_i32 main(t_i32 argc, t_str argv[], t_str arge[]);
|
||||
void ft_other_cmd(t_utils *shcat, t_usize i, t_usize prev_i);
|
||||
t_i32 ft_strcmp(const char *s1, const char *s2);
|
||||
t_i32 ft_check_type_operators(t_str operators);
|
||||
t_str *ft_split(t_const_str s, t_i8 c);
|
||||
t_str ft_strdup(t_const_str s);
|
||||
char *ft_strjoin(char const *s1, char const *s2);
|
||||
void *ft_calloc(t_usize nmemb, t_usize size);
|
||||
size_t ft_strlen(t_const_str s);
|
||||
t_usize ft_strlcpy(t_str dst, t_const_str src, t_usize size);
|
||||
void *ft_memset(void *s, t_i32 c, t_usize n);
|
||||
void ft_bzero(void *s, t_usize n);
|
||||
void ft_free_strs(t_str *strs);
|
||||
void ft_pwd(void);
|
||||
void ft_echo(t_str txt, t_str flag);
|
||||
void ft_exit(t_utils *maiboyerlpb, t_u8 exit_status);
|
||||
void ft_free(void *ptr);
|
||||
|
||||
#endif
|
||||
|
|
@ -1 +0,0 @@
|
|||
../parser/includes/
|
||||
|
|
@ -1,44 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* type_rust.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/03/28 14:44:20 by rparodi #+# #+# */
|
||||
/* Updated: 2024/03/31 20:53:56 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef TYPE_RUST_H
|
||||
#define TYPE_RUST_H
|
||||
|
||||
# include <stdbool.h>
|
||||
# include <stddef.h>
|
||||
# include <unistd.h>
|
||||
|
||||
typedef char *t_str;
|
||||
typedef const char *t_const_str;
|
||||
|
||||
typedef unsigned char t_u8;
|
||||
typedef char t_i8;
|
||||
typedef unsigned short t_u16;
|
||||
typedef short t_i16;
|
||||
typedef int t_i32;
|
||||
typedef unsigned int t_u32;
|
||||
typedef unsigned long long t_u64;
|
||||
typedef long long t_i64;
|
||||
typedef ssize_t t_isize;
|
||||
typedef size_t t_usize;
|
||||
|
||||
typedef float t_f32;
|
||||
typedef double t_f64;
|
||||
|
||||
typedef int t_file;
|
||||
|
||||
typedef bool t_error;
|
||||
|
||||
# define ERROR 1
|
||||
# define NO_ERROR 0
|
||||
|
||||
#endif
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_bzero.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/07 16:43:13 by rparodi #+# #+# */
|
||||
/* Updated: 2024/03/31 22:29:48 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../includes/minishell.h"
|
||||
|
||||
void ft_bzero(void *s, t_usize n)
|
||||
{
|
||||
ft_memset(s, 0, n);
|
||||
}
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_calloc.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/07 16:47:17 by rparodi #+# #+# */
|
||||
/* Updated: 2024/03/31 22:32:48 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../includes/minishell.h"
|
||||
|
||||
void *ft_calloc(t_usize nmemb, t_usize size)
|
||||
{
|
||||
t_usize total;
|
||||
t_str to_return;
|
||||
|
||||
if (nmemb == 0 || size == 0)
|
||||
return ((void *)malloc(1));
|
||||
total = nmemb * size;
|
||||
if (total / nmemb != size && total / size != nmemb)
|
||||
return (NULL);
|
||||
to_return = (char *)malloc(total);
|
||||
if (to_return == NULL)
|
||||
to_return = NULL;
|
||||
else
|
||||
ft_bzero(to_return, total);
|
||||
return (to_return);
|
||||
}
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_memset.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/07 16:50:29 by rparodi #+# #+# */
|
||||
/* Updated: 2024/03/31 22:32:32 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../includes/minishell.h"
|
||||
|
||||
void *ft_memset(void *s, t_i32 c, t_usize n)
|
||||
{
|
||||
t_str str;
|
||||
t_usize i;
|
||||
|
||||
i = 0;
|
||||
str = (t_str)s;
|
||||
while (i < n)
|
||||
{
|
||||
str[i] = c;
|
||||
i++;
|
||||
}
|
||||
return (str);
|
||||
}
|
||||
|
|
@ -1,93 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_split.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/09 13:56:02 by rparodi #+# #+# */
|
||||
/* Updated: 2024/03/31 21:07:40 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../includes/minishell.h"
|
||||
|
||||
static t_i32 count_words(t_const_str str, t_i8 sep)
|
||||
{
|
||||
t_i32 i;
|
||||
t_i32 count;
|
||||
|
||||
i = 0;
|
||||
count = 0;
|
||||
while (str[i])
|
||||
{
|
||||
while (str[i] == sep && str[i])
|
||||
i++;
|
||||
if (str[i] != sep && str[i])
|
||||
{
|
||||
while (str[i] != sep && str[i])
|
||||
i++;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return (count);
|
||||
}
|
||||
|
||||
static t_str ft_strndup(t_const_str s, t_i32 j)
|
||||
{
|
||||
t_i32 i;
|
||||
t_str str;
|
||||
|
||||
i = 0;
|
||||
str = (t_str)malloc((j + 1));
|
||||
if (!str)
|
||||
return (NULL);
|
||||
while (s[i] && i < j)
|
||||
{
|
||||
str[i] = s[i];
|
||||
i++;
|
||||
}
|
||||
str[i] = '\0';
|
||||
return (str);
|
||||
}
|
||||
|
||||
static t_str *ext_w(t_str *words_array, t_const_str str, t_i8 sep, t_i32 size)
|
||||
{
|
||||
t_i32 i;
|
||||
t_i32 j;
|
||||
|
||||
i = 0;
|
||||
j = 0;
|
||||
while (j < size)
|
||||
{
|
||||
while (str[i] == sep && str[i])
|
||||
i++;
|
||||
str = str + i;
|
||||
i = 0;
|
||||
while (str[i] != sep && str[i])
|
||||
i++;
|
||||
words_array[j++] = ft_strndup(str, i);
|
||||
str = str + i;
|
||||
i = 0;
|
||||
}
|
||||
words_array[j] = 0;
|
||||
return (words_array);
|
||||
}
|
||||
|
||||
t_str *ft_split(t_const_str s, t_i8 c)
|
||||
{
|
||||
t_i32 size;
|
||||
t_str *words_array;
|
||||
|
||||
size = count_words(s, c);
|
||||
words_array = (t_str *)malloc(sizeof(char *) * (size + 1));
|
||||
if (!words_array)
|
||||
return (NULL);
|
||||
if (size == 0)
|
||||
{
|
||||
words_array[0] = NULL;
|
||||
return (words_array);
|
||||
}
|
||||
words_array = ext_w(words_array, s, c, size);
|
||||
return (words_array);
|
||||
}
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strcmp.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/07 16:56:56 by rparodi #+# #+# */
|
||||
/* Updated: 2024/03/31 21:57:48 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../includes/minishell.h"
|
||||
|
||||
int ft_strcmp(const char *s1, const char *s2)
|
||||
{
|
||||
size_t i;
|
||||
int diff;
|
||||
|
||||
i = 0;
|
||||
while ((s1[i] || s2[i]))
|
||||
{
|
||||
if (s1[i] != s2[i] && s1 && s2)
|
||||
{
|
||||
diff = (unsigned char)s1[i] - (unsigned char)s2[i];
|
||||
return (diff);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strdup.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/07 16:53:59 by rparodi #+# #+# */
|
||||
/* Updated: 2024/04/01 01:41:35 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../includes/minishell.h"
|
||||
|
||||
t_str ft_strdup(t_const_str s)
|
||||
{
|
||||
t_usize len;
|
||||
t_str to_return;
|
||||
|
||||
len = ft_strlen(s) + 1;
|
||||
to_return = (t_str)malloc(sizeof(t_i8) * len);
|
||||
if (!to_return)
|
||||
return (NULL);
|
||||
ft_strlcpy(to_return, s, len);
|
||||
return (to_return);
|
||||
}
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strjoin.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/09 13:55:15 by rparodi #+# #+# */
|
||||
/* Updated: 2024/04/13 20:16:50 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../includes/minishell.h"
|
||||
|
||||
char *ft_strjoin(char const *s1, char const *s2)
|
||||
{
|
||||
size_t i;
|
||||
size_t save_i;
|
||||
char *str;
|
||||
|
||||
i = 0;
|
||||
str = (char *)malloc((ft_strlen(s1) + ft_strlen(s2)) + 1);
|
||||
if (!str)
|
||||
return (NULL);
|
||||
while (s1[i] != '\0')
|
||||
{
|
||||
str[i] = s1[i];
|
||||
i++;
|
||||
}
|
||||
save_i = i;
|
||||
i = 0;
|
||||
while (s2[i] != '\0')
|
||||
{
|
||||
str[save_i + i] = s2[i];
|
||||
i++;
|
||||
}
|
||||
str[i + save_i] = '\0';
|
||||
return (str);
|
||||
}
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strlcpy.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/07 16:55:25 by rparodi #+# #+# */
|
||||
/* Updated: 2024/04/01 01:38:28 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../includes/minishell.h"
|
||||
|
||||
t_usize ft_strlcpy(t_str dst, t_const_str src, t_usize size)
|
||||
{
|
||||
t_usize i;
|
||||
|
||||
i = 0;
|
||||
while (src[i] && i + 1 < size)
|
||||
{
|
||||
dst[i] = src[i];
|
||||
i++;
|
||||
}
|
||||
if (size > 0)
|
||||
{
|
||||
dst[i] = '\0';
|
||||
i++;
|
||||
}
|
||||
return (ft_strlen(src));
|
||||
}
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strlen.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/07 16:56:24 by rparodi #+# #+# */
|
||||
/* Updated: 2024/04/01 01:37:04 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../includes/minishell.h"
|
||||
|
||||
size_t ft_strlen(t_const_str s)
|
||||
{
|
||||
t_usize i;
|
||||
|
||||
i = 0;
|
||||
while (s[i] != '\0')
|
||||
i++;
|
||||
return (i);
|
||||
}
|
||||
|
|
@ -1 +0,0 @@
|
|||
Alors pour le coup, il faut que j'arrive a separer les strings par commande puis a chaque sep regarder les autres cmd (bisous lpb si tu passe par la ;))
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,80 +0,0 @@
|
|||
# **************************************************************************** #
|
||||
# #
|
||||
# ::: :::::::: #
|
||||
# Makefile :+: :+: :+: #
|
||||
# +:+ +:+ +:+ #
|
||||
# By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ #
|
||||
# +#+#+#+#+#+ +#+ #
|
||||
# Created: 2023/11/03 13:20:01 by maiboyer #+# #+# #
|
||||
# Updated: 2024/04/28 19:05:13 by maiboyer ### ########.fr #
|
||||
# #
|
||||
# **************************************************************************** #
|
||||
|
||||
BUILD_DIR = ./build
|
||||
SRC_DIR = ./
|
||||
|
||||
BONUS_FLAGS =
|
||||
NAME = libgmr.a
|
||||
LIB_NAME ?=
|
||||
TARGET = $(BUILD_DIR)/$(NAME)
|
||||
CC = clang
|
||||
CFLAGS = -Wall -Wextra -Werror -g3 -MMD -I./includes
|
||||
|
||||
include ./Filelist.mk
|
||||
|
||||
SRC = $(addsuffix .c,$(addprefix $(SRC_DIR)/,$(SRC_FILES)))
|
||||
OBJ = $(addsuffix .o,$(addprefix $(BUILD_DIR)/,$(SRC_FILES)))
|
||||
DEPS = $(addsuffix .d,$(addprefix $(BUILD_DIR)/,$(SRC_FILES)))
|
||||
|
||||
INCLUDES =
|
||||
COL_GRAY = \\e[90m
|
||||
COL_WHITE = \\e[37m
|
||||
COL_GREEN = \\e[32m
|
||||
COL_BOLD = \\e[1m
|
||||
COL_RESET = \\e[0m
|
||||
|
||||
.PHONY: all
|
||||
.PHONY: libs_build
|
||||
.PHONY: bonus
|
||||
.PHONY: clean
|
||||
.PHONY: fclean
|
||||
.PHONY: re
|
||||
.PHONY: format
|
||||
.PHONY: subject
|
||||
.PHONY: submit
|
||||
.PHONY: so
|
||||
|
||||
all: $(NAME)
|
||||
|
||||
$(NAME): $(TARGET)
|
||||
|
||||
$(TARGET): $(OBJ)
|
||||
@echo "ar rcs $(BUILD_DIR)/$(NAME) <OBJS...>"
|
||||
@ar rcs $(BUILD_DIR)/$(NAME) $(OBJ)
|
||||
|
||||
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.c
|
||||
@mkdir -p $(dir $@)
|
||||
$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
|
||||
|
||||
clean:
|
||||
@- $(foreach LIB,$(LIBS), \
|
||||
make clean LIB_NAME=$(LIB)/ BUILD_DIR=$(realpath $(BUILD_DIR)) -C $(LIB) --no-print-directory || true;\
|
||||
)
|
||||
$(if $(LIB_NAME),,\
|
||||
rm -rf $(BUILD_DIR) \
|
||||
)
|
||||
|
||||
fclean: clean
|
||||
@- $(foreach LIB,$(LIBS), \
|
||||
make fclean LIB_NAME=$(LIB)/ BUILD_DIR=$(realpath $(BUILD_DIR)) -C $(LIB) --no-print-directory || true;\
|
||||
)
|
||||
rm -f $(BUILD_DIR)/$(NAME)
|
||||
|
||||
re:
|
||||
@$(MAKE) --no-print-directory fclean
|
||||
@$(MAKE) --no-print-directory all
|
||||
|
||||
generate_filelist:
|
||||
@/usr/bin/env zsh -c "tree -iFf --noreport $(SRC_DIR) | rg '^$(SRC_DIR)/(.*)\.c\$$' --replace '\$$1' | sort -u" > ./source_files.list
|
||||
|
||||
-include $(DEPS)
|
||||
|
|
@ -1,101 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* create_language.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/25 16:13:52 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/04/28 17:15:16 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "./includes/parser.h"
|
||||
#include "./static/headers/constants.h"
|
||||
#include "./static/headers/symbols.h"
|
||||
#include "./parse_types.h"
|
||||
|
||||
const uint16_t *create_parse_table(void);
|
||||
const uint16_t *create_small_parse_table(void);
|
||||
const uint32_t *create_small_parse_table_map(void);
|
||||
const t_parse_action_entry *create_parse_actions_entries(void);
|
||||
const char *const *create_symbols_names(void);
|
||||
const char *const *create_field_names(void);
|
||||
const t_field_map_slice *create_field_map_slices(void);
|
||||
const t_field_map_entry *create_field_map_entries(void);
|
||||
const t_symbol_metadata *create_symbols_metadata(void);
|
||||
const t_symbol *create_unique_symbols_map(void);
|
||||
const t_symbol *create_non_terminal_alias_map(void);
|
||||
const t_symbol *create_alias_sequences(void);
|
||||
const t_lex_modes *create_lex_modes(void);
|
||||
const t_state_id *create_primary_state_ids(void);
|
||||
const bool *create_external_scanner_states(void);
|
||||
const t_symbol *create_external_scanner_symbol_map(void);
|
||||
bool lex_normal_main(t_lexer *lexer, t_state_id state);
|
||||
bool lex_keywords_main(t_lexer *lexer, t_state_id state);
|
||||
void *tree_sitter_bash_external_scanner_create(void);
|
||||
void tree_sitter_bash_external_scanner_destroy(void *ctx);
|
||||
bool tree_sitter_bash_external_scanner_scan(void *ctx, t_lexer *lexer,
|
||||
const bool *ret);
|
||||
uint32_t tree_sitter_bash_external_scanner_serialize(void *ctx, char *s);
|
||||
void tree_sitter_bash_external_scanner_deserialize(void *ctx, const char *s,
|
||||
uint32_t val);
|
||||
|
||||
static t_scanner init_scanner(void)
|
||||
{
|
||||
return ((t_scanner){
|
||||
create_external_scanner_states(),
|
||||
create_external_scanner_symbol_map(),
|
||||
tree_sitter_bash_external_scanner_create,
|
||||
tree_sitter_bash_external_scanner_destroy,
|
||||
tree_sitter_bash_external_scanner_scan,
|
||||
tree_sitter_bash_external_scanner_serialize,
|
||||
tree_sitter_bash_external_scanner_deserialize,
|
||||
});
|
||||
}
|
||||
|
||||
static void init_language(t_language *language)
|
||||
{
|
||||
language->parse_table = create_parse_table();
|
||||
language->small_parse_table = create_small_parse_table();
|
||||
language->small_parse_table_map = create_small_parse_table_map();
|
||||
language->parse_actions = create_parse_actions_entries();
|
||||
language->symbol_names = create_symbols_names();
|
||||
language->field_names = create_field_names();
|
||||
language->field_map_slices = create_field_map_slices();
|
||||
language->field_map_entries = create_field_map_entries();
|
||||
language->symbol_metadata = create_symbols_metadata();
|
||||
language->public_symbol_map = create_unique_symbols_map();
|
||||
language->alias_map = create_non_terminal_alias_map();
|
||||
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->keyword_capture_token = sym_word;
|
||||
language->external_scanner = init_scanner();
|
||||
}
|
||||
|
||||
const t_language *tree_sitter_bash(void)
|
||||
{
|
||||
static bool init = false;
|
||||
static t_language language = {
|
||||
.version = LANGUAGE_VERSION,
|
||||
.symbol_count = SYMBOL_COUNT,
|
||||
.alias_count = ALIAS_COUNT,
|
||||
.token_count = TOKEN_COUNT,
|
||||
.external_token_count = EXTERNAL_TOKEN_COUNT,
|
||||
.state_count = STATE_COUNT,
|
||||
.large_state_count = LARGE_STATE_COUNT,
|
||||
.production_id_count = PRODUCTION_ID_COUNT,
|
||||
.field_count = FIELD_COUNT,
|
||||
.max_alias_sequence_length = MAX_ALIAS_SEQUENCE_LENGTH,
|
||||
};
|
||||
|
||||
if (!init)
|
||||
{
|
||||
init_language(&language);
|
||||
init = true;
|
||||
}
|
||||
return ((t_language *)&language);
|
||||
}
|
||||
|
|
@ -1,54 +0,0 @@
|
|||
#ifndef TREE_SITTER_ALLOC_H_
|
||||
#define TREE_SITTER_ALLOC_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
// Allow clients to override allocation functions
|
||||
#ifdef TREE_SITTER_REUSE_ALLOCATOR
|
||||
|
||||
extern void *(*ts_current_malloc)(size_t);
|
||||
extern void *(*ts_current_calloc)(size_t, size_t);
|
||||
extern void *(*ts_current_realloc)(void *, size_t);
|
||||
extern void (*ts_current_free)(void *);
|
||||
|
||||
#ifndef malloc
|
||||
#define malloc ts_current_malloc
|
||||
#endif
|
||||
#ifndef calloc
|
||||
#define calloc ts_current_calloc
|
||||
#endif
|
||||
#ifndef realloc
|
||||
#define realloc ts_current_realloc
|
||||
#endif
|
||||
#ifndef free
|
||||
#define free ts_current_free
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
#ifndef malloc
|
||||
#define malloc malloc
|
||||
#endif
|
||||
#ifndef calloc
|
||||
#define calloc calloc
|
||||
#endif
|
||||
#ifndef realloc
|
||||
#define realloc realloc
|
||||
#endif
|
||||
#ifndef free
|
||||
#define free free
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // TREE_SITTER_ALLOC_H_
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,287 +0,0 @@
|
|||
#ifndef TREE_SITTER_ARRAY_H_
|
||||
#define TREE_SITTER_ARRAY_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable : 4101)
|
||||
#elif defined(__GNUC__) || defined(__clang__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wunused-variable"
|
||||
#endif
|
||||
|
||||
#define Array(T) \
|
||||
struct { \
|
||||
T *contents; \
|
||||
uint32_t size; \
|
||||
uint32_t capacity; \
|
||||
}
|
||||
|
||||
/// Initialize an array.
|
||||
#define array_init(self) \
|
||||
((self)->size = 0, (self)->capacity = 0, (self)->contents = NULL)
|
||||
|
||||
/// Create an empty array.
|
||||
#define array_new() \
|
||||
{ NULL, 0, 0 }
|
||||
|
||||
/// Get a pointer to the element at a given `index` in the array.
|
||||
#define array_get(self, _index) \
|
||||
(assert((uint32_t)(_index) < (self)->size), &(self)->contents[_index])
|
||||
|
||||
/// Get a pointer to the first element in the array.
|
||||
#define array_front(self) array_get(self, 0)
|
||||
|
||||
/// Get a pointer to the last element in the array.
|
||||
#define array_back(self) array_get(self, (self)->size - 1)
|
||||
|
||||
/// Clear the array, setting its size to zero. Note that this does not free any
|
||||
/// memory allocated for the array's contents.
|
||||
#define array_clear(self) ((self)->size = 0)
|
||||
|
||||
/// Reserve `new_capacity` elements of space in the array. If `new_capacity` is
|
||||
/// less than the array's current capacity, this function has no effect.
|
||||
#define array_reserve(self, new_capacity) \
|
||||
_array__reserve((Array *)(self), array_elem_size(self), new_capacity)
|
||||
|
||||
/// Free any memory allocated for this array. Note that this does not free any
|
||||
/// memory allocated for the array's contents.
|
||||
#define array_delete(self) _array__delete((Array *)(self))
|
||||
|
||||
/// Push a new `element` onto the end of the array.
|
||||
#define array_push(self, element) \
|
||||
(_array__grow((Array *)(self), 1, array_elem_size(self)), \
|
||||
(self)->contents[(self)->size++] = (element))
|
||||
|
||||
/// Increase the array's size by `count` elements.
|
||||
/// New elements are zero-initialized.
|
||||
#define array_grow_by(self, count) \
|
||||
(_array__grow((Array *)(self), count, array_elem_size(self)), \
|
||||
memset((self)->contents + (self)->size, 0, (count) * array_elem_size(self)), \
|
||||
(self)->size += (count))
|
||||
|
||||
/// Append all elements from one array to the end of another.
|
||||
#define array_push_all(self, other) \
|
||||
array_extend((self), (other)->size, (other)->contents)
|
||||
|
||||
/// Append `count` elements to the end of the array, reading their values from the
|
||||
/// `contents` pointer.
|
||||
#define array_extend(self, count, contents) \
|
||||
_array__splice( \
|
||||
(Array *)(self), array_elem_size(self), (self)->size, \
|
||||
0, count, contents \
|
||||
)
|
||||
|
||||
/// Remove `old_count` elements from the array starting at the given `index`. At
|
||||
/// the same index, insert `new_count` new elements, reading their values from the
|
||||
/// `new_contents` pointer.
|
||||
#define array_splice(self, _index, old_count, new_count, new_contents) \
|
||||
_array__splice( \
|
||||
(Array *)(self), array_elem_size(self), _index, \
|
||||
old_count, new_count, new_contents \
|
||||
)
|
||||
|
||||
/// Insert one `element` into the array at the given `index`.
|
||||
#define array_insert(self, _index, element) \
|
||||
_array__splice((Array *)(self), array_elem_size(self), _index, 0, 1, &(element))
|
||||
|
||||
/// Remove one element from the array at the given `index`.
|
||||
#define array_erase(self, _index) \
|
||||
_array__erase((Array *)(self), array_elem_size(self), _index)
|
||||
|
||||
/// Pop the last element off the array, returning the element by value.
|
||||
#define array_pop(self) ((self)->contents[--(self)->size])
|
||||
|
||||
/// Assign the contents of one array to another, reallocating if necessary.
|
||||
#define array_assign(self, other) \
|
||||
_array__assign((Array *)(self), (const Array *)(other), array_elem_size(self))
|
||||
|
||||
/// Swap one array with another
|
||||
#define array_swap(self, other) \
|
||||
_array__swap((Array *)(self), (Array *)(other))
|
||||
|
||||
/// Get the size of the array contents
|
||||
#define array_elem_size(self) (sizeof *(self)->contents)
|
||||
|
||||
/// Search a sorted array for a given `needle` value, using the given `compare`
|
||||
/// callback to determine the order.
|
||||
///
|
||||
/// If an existing element is found to be equal to `needle`, then the `index`
|
||||
/// out-parameter is set to the existing value's index, and the `exists`
|
||||
/// out-parameter is set to true. Otherwise, `index` is set to an index where
|
||||
/// `needle` should be inserted in order to preserve the sorting, and `exists`
|
||||
/// is set to false.
|
||||
#define array_search_sorted_with(self, compare, needle, _index, _exists) \
|
||||
_array__search_sorted(self, 0, compare, , needle, _index, _exists)
|
||||
|
||||
/// Search a sorted array for a given `needle` value, using integer comparisons
|
||||
/// of a given struct field (specified with a leading dot) to determine the order.
|
||||
///
|
||||
/// See also `array_search_sorted_with`.
|
||||
#define array_search_sorted_by(self, field, needle, _index, _exists) \
|
||||
_array__search_sorted(self, 0, _compare_int, field, needle, _index, _exists)
|
||||
|
||||
/// Insert a given `value` into a sorted array, using the given `compare`
|
||||
/// callback to determine the order.
|
||||
#define array_insert_sorted_with(self, compare, value) \
|
||||
do { \
|
||||
unsigned _index, _exists; \
|
||||
array_search_sorted_with(self, compare, &(value), &_index, &_exists); \
|
||||
if (!_exists) array_insert(self, _index, value); \
|
||||
} while (0)
|
||||
|
||||
/// Insert a given `value` into a sorted array, using integer comparisons of
|
||||
/// a given struct field (specified with a leading dot) to determine the order.
|
||||
///
|
||||
/// See also `array_search_sorted_by`.
|
||||
#define array_insert_sorted_by(self, field, value) \
|
||||
do { \
|
||||
unsigned _index, _exists; \
|
||||
array_search_sorted_by(self, field, (value) field, &_index, &_exists); \
|
||||
if (!_exists) array_insert(self, _index, value); \
|
||||
} while (0)
|
||||
|
||||
// Private
|
||||
|
||||
typedef Array(void) Array;
|
||||
|
||||
/// This is not what you're looking for, see `array_delete`.
|
||||
static inline void _array__delete(Array *self) {
|
||||
if (self->contents) {
|
||||
free(self->contents);
|
||||
self->contents = NULL;
|
||||
self->size = 0;
|
||||
self->capacity = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// This is not what you're looking for, see `array_erase`.
|
||||
static inline void _array__erase(Array *self, size_t element_size,
|
||||
uint32_t index) {
|
||||
assert(index < self->size);
|
||||
char *contents = (char *)self->contents;
|
||||
memmove(contents + index * element_size, contents + (index + 1) * element_size,
|
||||
(self->size - index - 1) * element_size);
|
||||
self->size--;
|
||||
}
|
||||
|
||||
/// This is not what you're looking for, see `array_reserve`.
|
||||
static inline void _array__reserve(Array *self, size_t element_size, uint32_t new_capacity) {
|
||||
if (new_capacity > self->capacity) {
|
||||
if (self->contents) {
|
||||
self->contents = realloc(self->contents, new_capacity * element_size);
|
||||
} else {
|
||||
self->contents = malloc(new_capacity * element_size);
|
||||
}
|
||||
self->capacity = new_capacity;
|
||||
}
|
||||
}
|
||||
|
||||
/// This is not what you're looking for, see `array_assign`.
|
||||
static inline void _array__assign(Array *self, const Array *other, size_t element_size) {
|
||||
_array__reserve(self, element_size, other->size);
|
||||
self->size = other->size;
|
||||
memcpy(self->contents, other->contents, self->size * element_size);
|
||||
}
|
||||
|
||||
/// This is not what you're looking for, see `array_swap`.
|
||||
static inline void _array__swap(Array *self, Array *other) {
|
||||
Array swap = *other;
|
||||
*other = *self;
|
||||
*self = swap;
|
||||
}
|
||||
|
||||
/// This is not what you're looking for, see `array_push` or `array_grow_by`.
|
||||
static inline void _array__grow(Array *self, uint32_t count, size_t element_size) {
|
||||
uint32_t new_size = self->size + count;
|
||||
if (new_size > self->capacity) {
|
||||
uint32_t new_capacity = self->capacity * 2;
|
||||
if (new_capacity < 8) new_capacity = 8;
|
||||
if (new_capacity < new_size) new_capacity = new_size;
|
||||
_array__reserve(self, element_size, new_capacity);
|
||||
}
|
||||
}
|
||||
|
||||
/// This is not what you're looking for, see `array_splice`.
|
||||
static inline void _array__splice(Array *self, size_t element_size,
|
||||
uint32_t index, uint32_t old_count,
|
||||
uint32_t new_count, const void *elements) {
|
||||
uint32_t new_size = self->size + new_count - old_count;
|
||||
uint32_t old_end = index + old_count;
|
||||
uint32_t new_end = index + new_count;
|
||||
assert(old_end <= self->size);
|
||||
|
||||
_array__reserve(self, element_size, new_size);
|
||||
|
||||
char *contents = (char *)self->contents;
|
||||
if (self->size > old_end) {
|
||||
memmove(
|
||||
contents + new_end * element_size,
|
||||
contents + old_end * element_size,
|
||||
(self->size - old_end) * element_size
|
||||
);
|
||||
}
|
||||
if (new_count > 0) {
|
||||
if (elements) {
|
||||
memcpy(
|
||||
(contents + index * element_size),
|
||||
elements,
|
||||
new_count * element_size
|
||||
);
|
||||
} else {
|
||||
memset(
|
||||
(contents + index * element_size),
|
||||
0,
|
||||
new_count * element_size
|
||||
);
|
||||
}
|
||||
}
|
||||
self->size += new_count - old_count;
|
||||
}
|
||||
|
||||
/// A binary search routine, based on Rust's `std::slice::binary_search_by`.
|
||||
/// This is not what you're looking for, see `array_search_sorted_with` or `array_search_sorted_by`.
|
||||
#define _array__search_sorted(self, start, compare, suffix, needle, _index, _exists) \
|
||||
do { \
|
||||
*(_index) = start; \
|
||||
*(_exists) = false; \
|
||||
uint32_t size = (self)->size - *(_index); \
|
||||
if (size == 0) break; \
|
||||
int comparison; \
|
||||
while (size > 1) { \
|
||||
uint32_t half_size = size / 2; \
|
||||
uint32_t mid_index = *(_index) + half_size; \
|
||||
comparison = compare(&((self)->contents[mid_index] suffix), (needle)); \
|
||||
if (comparison <= 0) *(_index) = mid_index; \
|
||||
size -= half_size; \
|
||||
} \
|
||||
comparison = compare(&((self)->contents[*(_index)] suffix), (needle)); \
|
||||
if (comparison == 0) *(_exists) = true; \
|
||||
else if (comparison < 0) *(_index) += 1; \
|
||||
} while (0)
|
||||
|
||||
/// Helper macro for the `_sorted_by` routines below. This takes the left (existing)
|
||||
/// parameter by reference in order to work with the generic sorting function above.
|
||||
#define _compare_int(a, b) ((int)*(a) - (int)(b))
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(default : 4101)
|
||||
#elif defined(__GNUC__) || defined(__clang__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // TREE_SITTER_ARRAY_H_
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* lexer.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/23 19:51:24 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/04/24 23:03:33 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef LEXER_H
|
||||
#define LEXER_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifndef TREE_SITTER_API_H_
|
||||
typedef uint16_t t_state_id;
|
||||
typedef uint16_t t_symbol;
|
||||
typedef uint16_t t_field_id;
|
||||
typedef struct s_language t_language;
|
||||
#endif
|
||||
|
||||
#endif /* LEXER_H */
|
||||
|
|
@ -1,56 +0,0 @@
|
|||
#ifndef TREE_SITTER_PARSER_H_
|
||||
#define TREE_SITTER_PARSER_H_
|
||||
|
||||
#include "../parse_types.h"
|
||||
#include "./lexer.h"
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#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_
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* parser_raw_types.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/24 17:44:47 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/04/24 17:44:48 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef PARSER_RAW_TYPES_H
|
||||
#define PARSER_RAW_TYPES_H
|
||||
|
||||
|
||||
|
||||
#endif /* PARSER_RAW_TYPES_H */
|
||||
|
|
@ -1,298 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* parse_types.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/24 23:01:45 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/04/26 18:05:40 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef PARSETYPES_H
|
||||
#define PARSETYPES_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
typedef uint16_t t_state_id;
|
||||
typedef uint16_t t_symbol;
|
||||
typedef uint16_t t_field_id;
|
||||
|
||||
typedef struct s_lexer t_lexer;
|
||||
|
||||
#define ts_builtin_sym_end 0
|
||||
#define ts_builtin_sym_error -1
|
||||
|
||||
struct s_lexer
|
||||
{
|
||||
int32_t lookahead;
|
||||
t_symbol result_symbol;
|
||||
void (*advance)(t_lexer *, bool);
|
||||
void (*mark_end)(t_lexer *);
|
||||
uint32_t (*get_column)(t_lexer *);
|
||||
bool (*is_at_included_range_start)(const t_lexer *);
|
||||
bool (*eof)(const t_lexer *);
|
||||
};
|
||||
|
||||
typedef struct s_lexer_state
|
||||
{
|
||||
int32_t lookahead;
|
||||
t_state_id state;
|
||||
bool result;
|
||||
bool skip;
|
||||
bool eof;
|
||||
} t_lexer_state;
|
||||
|
||||
static inline bool lex_skip(t_state_id state_value, t_lexer *lexer,
|
||||
t_lexer_state *s)
|
||||
{
|
||||
(void)(lexer);
|
||||
s->skip = true;
|
||||
s->state = state_value;
|
||||
return (true);
|
||||
};
|
||||
|
||||
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)
|
||||
{
|
||||
s->result = true;
|
||||
lexer->result_symbol = symbol_value;
|
||||
lexer->mark_end(lexer);
|
||||
return (true);
|
||||
};
|
||||
|
||||
static inline bool lex_end_state(t_lexer *lexer, t_lexer_state *s)
|
||||
{
|
||||
(void)(lexer);
|
||||
(void)(s);
|
||||
return (false);
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
t_field_id field_id;
|
||||
uint8_t child_index;
|
||||
bool inherited;
|
||||
} t_field_map_entry;
|
||||
|
||||
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,
|
||||
.child_index = child_index,
|
||||
.inherited = inherited,
|
||||
});
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint16_t index;
|
||||
uint16_t length;
|
||||
} t_field_map_slice;
|
||||
|
||||
static inline t_field_map_slice fmap_slice(uint16_t index, uint16_t length)
|
||||
{
|
||||
return ((t_field_map_slice){
|
||||
.index = index,
|
||||
.length = length,
|
||||
});
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
bool visible;
|
||||
bool named;
|
||||
bool supertype;
|
||||
} t_symbol_metadata;
|
||||
|
||||
static inline t_symbol_metadata sym_metadata(bool visible, bool named,
|
||||
bool supertype)
|
||||
{
|
||||
return ((t_symbol_metadata){
|
||||
.visible = visible,
|
||||
.named = named,
|
||||
.supertype = supertype,
|
||||
});
|
||||
};
|
||||
|
||||
typedef enum
|
||||
{
|
||||
ActionTypeShift,
|
||||
ActionTypeReduce,
|
||||
ActionTypeAccept,
|
||||
ActionTypeRecover,
|
||||
} t_parse_action_type;
|
||||
|
||||
typedef union {
|
||||
struct
|
||||
{
|
||||
uint8_t type;
|
||||
t_state_id state;
|
||||
bool extra;
|
||||
bool repetition;
|
||||
} shift;
|
||||
struct
|
||||
{
|
||||
uint8_t type;
|
||||
uint8_t child_count;
|
||||
t_symbol symbol;
|
||||
int16_t dynamic_precedence;
|
||||
uint16_t production_id;
|
||||
} reduce;
|
||||
uint8_t type;
|
||||
} t_parse_actions;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint16_t lex_state;
|
||||
uint16_t external_lex_state;
|
||||
} t_lex_modes;
|
||||
|
||||
typedef union {
|
||||
t_parse_actions action;
|
||||
struct
|
||||
{
|
||||
uint8_t count;
|
||||
bool reusable;
|
||||
} entry;
|
||||
} t_parse_action_entry;
|
||||
|
||||
static inline t_parse_action_entry entry(uint8_t count, bool reusable)
|
||||
{
|
||||
return ((t_parse_action_entry){
|
||||
.entry = {.count = count, .reusable = reusable}});
|
||||
};
|
||||
|
||||
static inline t_parse_action_entry shift(t_state_id state_value)
|
||||
{
|
||||
return ((t_parse_action_entry){{.shift = {
|
||||
.type = ActionTypeShift,
|
||||
.state = (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}}});
|
||||
};
|
||||
|
||||
static inline t_parse_action_entry shift_extra(void)
|
||||
{
|
||||
return ((t_parse_action_entry){
|
||||
{.shift = {.type = ActionTypeShift, .extra = true}}});
|
||||
};
|
||||
|
||||
static inline t_parse_action_entry reduce(
|
||||
|
||||
t_symbol symbol, uint8_t child_count, int16_t dynamic_precedence,
|
||||
uint16_t 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)
|
||||
{
|
||||
return ((t_parse_action_entry){{.type = ActionTypeRecover}});
|
||||
};
|
||||
|
||||
static inline t_parse_action_entry accept(void)
|
||||
{
|
||||
return ((t_parse_action_entry){{.type = ActionTypeAccept}});
|
||||
};
|
||||
|
||||
typedef struct s_char_range
|
||||
{
|
||||
int32_t start;
|
||||
int32_t end;
|
||||
} t_char_range;
|
||||
|
||||
static inline bool set_contains(t_char_range *ranges, uint32_t len,
|
||||
int32_t lookahead)
|
||||
{
|
||||
uint32_t index = 0;
|
||||
uint32_t size = len - index;
|
||||
while (size > 1)
|
||||
{
|
||||
uint32_t half_size = size / 2;
|
||||
uint32_t mid_index = index + half_size;
|
||||
t_char_range *range = &ranges[mid_index];
|
||||
if (lookahead >= range->start && lookahead <= range->end)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (lookahead > range->end)
|
||||
{
|
||||
index = mid_index;
|
||||
}
|
||||
size -= half_size;
|
||||
}
|
||||
t_char_range *range = &ranges[index];
|
||||
return (lookahead >= range->start && lookahead <= range->end);
|
||||
};
|
||||
|
||||
static inline bool advance_map_inner(uint32_t *map, uint32_t elems, t_lexer *l,
|
||||
t_lexer_state *s)
|
||||
{
|
||||
uint32_t i;
|
||||
|
||||
(void)(l);
|
||||
i = 0;
|
||||
while (i < elems)
|
||||
{
|
||||
if (map[i] == (uint32_t)s->lookahead)
|
||||
{
|
||||
s->state = map[i + 1];
|
||||
return true;
|
||||
}
|
||||
i += 2;
|
||||
}
|
||||
return (false);
|
||||
};
|
||||
|
||||
static inline t_lex_modes lex_mode_external(uint16_t lex_state,
|
||||
uint16_t ext_lex_state)
|
||||
{
|
||||
return ((t_lex_modes){
|
||||
.lex_state = lex_state,
|
||||
.external_lex_state = ext_lex_state,
|
||||
});
|
||||
};
|
||||
|
||||
static inline t_lex_modes lex_mode_normal(uint16_t lex_state)
|
||||
{
|
||||
return ((t_lex_modes){
|
||||
.lex_state = lex_state,
|
||||
});
|
||||
};
|
||||
|
||||
static inline uint16_t actions(uint16_t val)
|
||||
{
|
||||
return (val);
|
||||
};
|
||||
|
||||
static inline uint16_t state(uint16_t val)
|
||||
{
|
||||
return (val);
|
||||
};
|
||||
|
||||
#endif /* PARSETYPES_H */
|
||||
|
|
@ -1,290 +0,0 @@
|
|||
#ifndef TREE_SITTER_ARRAY_H_
|
||||
#define TREE_SITTER_ARRAY_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable : 4101)
|
||||
#elif defined(__GNUC__) || defined(__clang__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wunused-variable"
|
||||
#endif
|
||||
|
||||
#define Array(T) \
|
||||
struct { \
|
||||
T *contents; \
|
||||
uint32_t size; \
|
||||
uint32_t capacity; \
|
||||
}
|
||||
|
||||
/// Initialize an array.
|
||||
#define array_init(self) \
|
||||
((self)->size = 0, (self)->capacity = 0, (self)->contents = NULL)
|
||||
|
||||
/// Create an empty array.
|
||||
#define array_new() \
|
||||
{ NULL, 0, 0 }
|
||||
|
||||
/// Get a pointer to the element at a given `index` in the array.
|
||||
#define array_get(self, _index) \
|
||||
(assert((uint32_t)(_index) < (self)->size), &(self)->contents[_index])
|
||||
|
||||
/// Get a pointer to the first element in the array.
|
||||
#define array_front(self) array_get(self, 0)
|
||||
|
||||
/// Get a pointer to the last element in the array.
|
||||
#define array_back(self) array_get(self, (self)->size - 1)
|
||||
|
||||
/// Clear the array, setting its size to zero. Note that this does not free any
|
||||
/// memory allocated for the array's contents.
|
||||
#define array_clear(self) ((self)->size = 0)
|
||||
|
||||
/// Reserve `new_capacity` elements of space in the array. If `new_capacity` is
|
||||
/// less than the array's current capacity, this function has no effect.
|
||||
#define array_reserve(self, new_capacity) \
|
||||
_array__reserve((Array *)(self), array_elem_size(self), new_capacity)
|
||||
|
||||
/// Free any memory allocated for this array. Note that this does not free any
|
||||
/// memory allocated for the array's contents.
|
||||
#define array_delete(self) _array__delete((Array *)(self))
|
||||
|
||||
/// Push a new `element` onto the end of the array.
|
||||
#define array_push(self, element) \
|
||||
(_array__grow((Array *)(self), 1, array_elem_size(self)), \
|
||||
(self)->contents[(self)->size++] = (element))
|
||||
|
||||
/// Increase the array's size by `count` elements.
|
||||
/// New elements are zero-initialized.
|
||||
#define array_grow_by(self, count) \
|
||||
do { \
|
||||
if ((count) == 0) break; \
|
||||
_array__grow((Array *)(self), count, array_elem_size(self)); \
|
||||
memset((self)->contents + (self)->size, 0, (count) * array_elem_size(self)); \
|
||||
(self)->size += (count); \
|
||||
} while (0)
|
||||
|
||||
/// Append all elements from one array to the end of another.
|
||||
#define array_push_all(self, other) \
|
||||
array_extend((self), (other)->size, (other)->contents)
|
||||
|
||||
/// Append `count` elements to the end of the array, reading their values from the
|
||||
/// `contents` pointer.
|
||||
#define array_extend(self, count, contents) \
|
||||
_array__splice( \
|
||||
(Array *)(self), array_elem_size(self), (self)->size, \
|
||||
0, count, contents \
|
||||
)
|
||||
|
||||
/// Remove `old_count` elements from the array starting at the given `index`. At
|
||||
/// the same index, insert `new_count` new elements, reading their values from the
|
||||
/// `new_contents` pointer.
|
||||
#define array_splice(self, _index, old_count, new_count, new_contents) \
|
||||
_array__splice( \
|
||||
(Array *)(self), array_elem_size(self), _index, \
|
||||
old_count, new_count, new_contents \
|
||||
)
|
||||
|
||||
/// Insert one `element` into the array at the given `index`.
|
||||
#define array_insert(self, _index, element) \
|
||||
_array__splice((Array *)(self), array_elem_size(self), _index, 0, 1, &(element))
|
||||
|
||||
/// Remove one element from the array at the given `index`.
|
||||
#define array_erase(self, _index) \
|
||||
_array__erase((Array *)(self), array_elem_size(self), _index)
|
||||
|
||||
/// Pop the last element off the array, returning the element by value.
|
||||
#define array_pop(self) ((self)->contents[--(self)->size])
|
||||
|
||||
/// Assign the contents of one array to another, reallocating if necessary.
|
||||
#define array_assign(self, other) \
|
||||
_array__assign((Array *)(self), (const Array *)(other), array_elem_size(self))
|
||||
|
||||
/// Swap one array with another
|
||||
#define array_swap(self, other) \
|
||||
_array__swap((Array *)(self), (Array *)(other))
|
||||
|
||||
/// Get the size of the array contents
|
||||
#define array_elem_size(self) (sizeof *(self)->contents)
|
||||
|
||||
/// Search a sorted array for a given `needle` value, using the given `compare`
|
||||
/// callback to determine the order.
|
||||
///
|
||||
/// If an existing element is found to be equal to `needle`, then the `index`
|
||||
/// out-parameter is set to the existing value's index, and the `exists`
|
||||
/// out-parameter is set to true. Otherwise, `index` is set to an index where
|
||||
/// `needle` should be inserted in order to preserve the sorting, and `exists`
|
||||
/// is set to false.
|
||||
#define array_search_sorted_with(self, compare, needle, _index, _exists) \
|
||||
_array__search_sorted(self, 0, compare, , needle, _index, _exists)
|
||||
|
||||
/// Search a sorted array for a given `needle` value, using integer comparisons
|
||||
/// of a given struct field (specified with a leading dot) to determine the order.
|
||||
///
|
||||
/// See also `array_search_sorted_with`.
|
||||
#define array_search_sorted_by(self, field, needle, _index, _exists) \
|
||||
_array__search_sorted(self, 0, _compare_int, field, needle, _index, _exists)
|
||||
|
||||
/// Insert a given `value` into a sorted array, using the given `compare`
|
||||
/// callback to determine the order.
|
||||
#define array_insert_sorted_with(self, compare, value) \
|
||||
do { \
|
||||
unsigned _index, _exists; \
|
||||
array_search_sorted_with(self, compare, &(value), &_index, &_exists); \
|
||||
if (!_exists) array_insert(self, _index, value); \
|
||||
} while (0)
|
||||
|
||||
/// Insert a given `value` into a sorted array, using integer comparisons of
|
||||
/// a given struct field (specified with a leading dot) to determine the order.
|
||||
///
|
||||
/// See also `array_search_sorted_by`.
|
||||
#define array_insert_sorted_by(self, field, value) \
|
||||
do { \
|
||||
unsigned _index, _exists; \
|
||||
array_search_sorted_by(self, field, (value) field, &_index, &_exists); \
|
||||
if (!_exists) array_insert(self, _index, value); \
|
||||
} while (0)
|
||||
|
||||
// Private
|
||||
|
||||
typedef Array(void) Array;
|
||||
|
||||
/// This is not what you're looking for, see `array_delete`.
|
||||
static inline void _array__delete(Array *self) {
|
||||
if (self->contents) {
|
||||
free(self->contents);
|
||||
self->contents = NULL;
|
||||
self->size = 0;
|
||||
self->capacity = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// This is not what you're looking for, see `array_erase`.
|
||||
static inline void _array__erase(Array *self, size_t element_size,
|
||||
uint32_t index) {
|
||||
assert(index < self->size);
|
||||
char *contents = (char *)self->contents;
|
||||
memmove(contents + index * element_size, contents + (index + 1) * element_size,
|
||||
(self->size - index - 1) * element_size);
|
||||
self->size--;
|
||||
}
|
||||
|
||||
/// This is not what you're looking for, see `array_reserve`.
|
||||
static inline void _array__reserve(Array *self, size_t element_size, uint32_t new_capacity) {
|
||||
if (new_capacity > self->capacity) {
|
||||
if (self->contents) {
|
||||
self->contents = realloc(self->contents, new_capacity * element_size);
|
||||
} else {
|
||||
self->contents = malloc(new_capacity * element_size);
|
||||
}
|
||||
self->capacity = new_capacity;
|
||||
}
|
||||
}
|
||||
|
||||
/// This is not what you're looking for, see `array_assign`.
|
||||
static inline void _array__assign(Array *self, const Array *other, size_t element_size) {
|
||||
_array__reserve(self, element_size, other->size);
|
||||
self->size = other->size;
|
||||
memcpy(self->contents, other->contents, self->size * element_size);
|
||||
}
|
||||
|
||||
/// This is not what you're looking for, see `array_swap`.
|
||||
static inline void _array__swap(Array *self, Array *other) {
|
||||
Array swap = *other;
|
||||
*other = *self;
|
||||
*self = swap;
|
||||
}
|
||||
|
||||
/// This is not what you're looking for, see `array_push` or `array_grow_by`.
|
||||
static inline void _array__grow(Array *self, uint32_t count, size_t element_size) {
|
||||
uint32_t new_size = self->size + count;
|
||||
if (new_size > self->capacity) {
|
||||
uint32_t new_capacity = self->capacity * 2;
|
||||
if (new_capacity < 8) new_capacity = 8;
|
||||
if (new_capacity < new_size) new_capacity = new_size;
|
||||
_array__reserve(self, element_size, new_capacity);
|
||||
}
|
||||
}
|
||||
|
||||
/// This is not what you're looking for, see `array_splice`.
|
||||
static inline void _array__splice(Array *self, size_t element_size,
|
||||
uint32_t index, uint32_t old_count,
|
||||
uint32_t new_count, const void *elements) {
|
||||
uint32_t new_size = self->size + new_count - old_count;
|
||||
uint32_t old_end = index + old_count;
|
||||
uint32_t new_end = index + new_count;
|
||||
assert(old_end <= self->size);
|
||||
|
||||
_array__reserve(self, element_size, new_size);
|
||||
|
||||
char *contents = (char *)self->contents;
|
||||
if (self->size > old_end) {
|
||||
memmove(
|
||||
contents + new_end * element_size,
|
||||
contents + old_end * element_size,
|
||||
(self->size - old_end) * element_size
|
||||
);
|
||||
}
|
||||
if (new_count > 0) {
|
||||
if (elements) {
|
||||
memcpy(
|
||||
(contents + index * element_size),
|
||||
elements,
|
||||
new_count * element_size
|
||||
);
|
||||
} else {
|
||||
memset(
|
||||
(contents + index * element_size),
|
||||
0,
|
||||
new_count * element_size
|
||||
);
|
||||
}
|
||||
}
|
||||
self->size += new_count - old_count;
|
||||
}
|
||||
|
||||
/// A binary search routine, based on Rust's `std::slice::binary_search_by`.
|
||||
/// This is not what you're looking for, see `array_search_sorted_with` or `array_search_sorted_by`.
|
||||
#define _array__search_sorted(self, start, compare, suffix, needle, _index, _exists) \
|
||||
do { \
|
||||
*(_index) = start; \
|
||||
*(_exists) = false; \
|
||||
uint32_t size = (self)->size - *(_index); \
|
||||
if (size == 0) break; \
|
||||
int comparison; \
|
||||
while (size > 1) { \
|
||||
uint32_t half_size = size / 2; \
|
||||
uint32_t mid_index = *(_index) + half_size; \
|
||||
comparison = compare(&((self)->contents[mid_index] suffix), (needle)); \
|
||||
if (comparison <= 0) *(_index) = mid_index; \
|
||||
size -= half_size; \
|
||||
} \
|
||||
comparison = compare(&((self)->contents[*(_index)] suffix), (needle)); \
|
||||
if (comparison == 0) *(_exists) = true; \
|
||||
else if (comparison < 0) *(_index) += 1; \
|
||||
} while (0)
|
||||
|
||||
/// Helper macro for the `_sorted_by` routines below. This takes the left (existing)
|
||||
/// parameter by reference in order to work with the generic sorting function above.
|
||||
#define _compare_int(a, b) ((int)*(a) - (int)(b))
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(default : 4101)
|
||||
#elif defined(__GNUC__) || defined(__clang__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // TREE_SITTER_ARRAY_H_
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
#ifndef TREE_SITTER_ERROR_COSTS_H_
|
||||
#define TREE_SITTER_ERROR_COSTS_H_
|
||||
|
||||
#define ERROR_STATE 0
|
||||
#define ERROR_COST_PER_RECOVERY 500
|
||||
#define ERROR_COST_PER_MISSING_TREE 110
|
||||
#define ERROR_COST_PER_SKIPPED_TREE 100
|
||||
#define ERROR_COST_PER_SKIPPED_LINE 30
|
||||
#define ERROR_COST_PER_SKIPPED_CHAR 1
|
||||
|
||||
#endif
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
|
||||
// Determine endian and pointer size based on known defines.
|
||||
// TS_BIG_ENDIAN and TS_PTR_SIZE can be set as -D compiler arguments
|
||||
// to override this.
|
||||
|
||||
#if !defined(TS_BIG_ENDIAN)
|
||||
#if (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) \
|
||||
|| (defined( __APPLE_CC__) && (defined(__ppc__) || defined(__ppc64__)))
|
||||
#define TS_BIG_ENDIAN 1
|
||||
#else
|
||||
#define TS_BIG_ENDIAN 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if !defined(TS_PTR_SIZE)
|
||||
#if UINTPTR_MAX == 0xFFFFFFFF
|
||||
#define TS_PTR_SIZE 32
|
||||
#else
|
||||
#define TS_PTR_SIZE 64
|
||||
#endif
|
||||
#endif
|
||||
|
|
@ -1,215 +0,0 @@
|
|||
#include "./language.h"
|
||||
#include "api.h"
|
||||
#include <string.h>
|
||||
|
||||
const TSLanguage *ts_language_copy(const TSLanguage *self) {
|
||||
return self;
|
||||
}
|
||||
|
||||
void ts_language_delete(const TSLanguage *self) {
|
||||
(void)(self);
|
||||
}
|
||||
|
||||
uint32_t ts_language_symbol_count(const TSLanguage *self) {
|
||||
return self->symbol_count + self->alias_count;
|
||||
}
|
||||
|
||||
uint32_t ts_language_state_count(const TSLanguage *self) {
|
||||
return self->state_count;
|
||||
}
|
||||
|
||||
uint32_t ts_language_version(const TSLanguage *self) {
|
||||
return self->version;
|
||||
}
|
||||
|
||||
uint32_t ts_language_field_count(const TSLanguage *self) {
|
||||
return self->field_count;
|
||||
}
|
||||
|
||||
void ts_language_table_entry(
|
||||
const TSLanguage *self,
|
||||
TSStateId state,
|
||||
TSSymbol symbol,
|
||||
TableEntry *result
|
||||
) {
|
||||
if (symbol == ts_builtin_sym_error || symbol == ts_builtin_sym_error_repeat) {
|
||||
result->action_count = 0;
|
||||
result->is_reusable = false;
|
||||
result->actions = NULL;
|
||||
} else {
|
||||
assert(symbol < self->token_count);
|
||||
uint32_t action_index = ts_language_lookup(self, state, symbol);
|
||||
const TSParseActionEntry *entry = &self->parse_actions[action_index];
|
||||
result->action_count = entry->entry.count;
|
||||
result->is_reusable = entry->entry.reusable;
|
||||
result->actions = (const TSParseAction *)(entry + 1);
|
||||
}
|
||||
}
|
||||
|
||||
TSSymbolMetadata ts_language_symbol_metadata(
|
||||
const TSLanguage *self,
|
||||
TSSymbol symbol
|
||||
) {
|
||||
if (symbol == ts_builtin_sym_error) {
|
||||
return (TSSymbolMetadata) {.visible = true, .named = true};
|
||||
} else if (symbol == ts_builtin_sym_error_repeat) {
|
||||
return (TSSymbolMetadata) {.visible = false, .named = false};
|
||||
} else {
|
||||
return self->symbol_metadata[symbol];
|
||||
}
|
||||
}
|
||||
|
||||
TSSymbol ts_language_public_symbol(
|
||||
const TSLanguage *self,
|
||||
TSSymbol symbol
|
||||
) {
|
||||
if (symbol == ts_builtin_sym_error) return symbol;
|
||||
return self->public_symbol_map[symbol];
|
||||
}
|
||||
|
||||
TSStateId ts_language_next_state(
|
||||
const TSLanguage *self,
|
||||
TSStateId state,
|
||||
TSSymbol symbol
|
||||
) {
|
||||
if (symbol == ts_builtin_sym_error || symbol == ts_builtin_sym_error_repeat) {
|
||||
return 0;
|
||||
} else if (symbol < self->token_count) {
|
||||
uint32_t count;
|
||||
const TSParseAction *actions = ts_language_actions(self, state, symbol, &count);
|
||||
if (count > 0) {
|
||||
TSParseAction action = actions[count - 1];
|
||||
if (action.type == TSParseActionTypeShift) {
|
||||
return action.shift.extra ? state : action.shift.state;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
} else {
|
||||
return ts_language_lookup(self, state, symbol);
|
||||
}
|
||||
}
|
||||
|
||||
const char *ts_language_symbol_name(
|
||||
const TSLanguage *self,
|
||||
TSSymbol symbol
|
||||
) {
|
||||
if (symbol == ts_builtin_sym_error) {
|
||||
return "ERROR";
|
||||
} else if (symbol == ts_builtin_sym_error_repeat) {
|
||||
return "_ERROR";
|
||||
} else if (symbol < ts_language_symbol_count(self)) {
|
||||
return self->symbol_names[symbol];
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
TSSymbol ts_language_symbol_for_name(
|
||||
const TSLanguage *self,
|
||||
const char *string,
|
||||
uint32_t length,
|
||||
bool is_named
|
||||
) {
|
||||
if (!strncmp(string, "ERROR", length)) return ts_builtin_sym_error;
|
||||
uint16_t count = (uint16_t)ts_language_symbol_count(self);
|
||||
for (TSSymbol i = 0; i < count; i++) {
|
||||
TSSymbolMetadata metadata = ts_language_symbol_metadata(self, i);
|
||||
if ((!metadata.visible && !metadata.supertype) || metadata.named != is_named) continue;
|
||||
const char *symbol_name = self->symbol_names[i];
|
||||
if (!strncmp(symbol_name, string, length) && !symbol_name[length]) {
|
||||
return self->public_symbol_map[i];
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
TSSymbolType ts_language_symbol_type(
|
||||
const TSLanguage *self,
|
||||
TSSymbol symbol
|
||||
) {
|
||||
TSSymbolMetadata metadata = ts_language_symbol_metadata(self, symbol);
|
||||
if (metadata.named && metadata.visible) {
|
||||
return TSSymbolTypeRegular;
|
||||
} else if (metadata.visible) {
|
||||
return TSSymbolTypeAnonymous;
|
||||
} else {
|
||||
return TSSymbolTypeAuxiliary;
|
||||
}
|
||||
}
|
||||
|
||||
const char *ts_language_field_name_for_id(
|
||||
const TSLanguage *self,
|
||||
TSFieldId id
|
||||
) {
|
||||
uint32_t count = ts_language_field_count(self);
|
||||
if (count && id <= count) {
|
||||
return self->field_names[id];
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
TSFieldId ts_language_field_id_for_name(
|
||||
const TSLanguage *self,
|
||||
const char *name,
|
||||
uint32_t name_length
|
||||
) {
|
||||
uint16_t count = (uint16_t)ts_language_field_count(self);
|
||||
for (TSSymbol i = 1; i < count + 1; i++) {
|
||||
switch (strncmp(name, self->field_names[i], name_length)) {
|
||||
case 0:
|
||||
if (self->field_names[i][name_length] == 0) return i;
|
||||
break;
|
||||
case -1:
|
||||
return 0;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
TSLookaheadIterator *ts_lookahead_iterator_new(const TSLanguage *self, TSStateId state) {
|
||||
if (state >= self->state_count) return NULL;
|
||||
LookaheadIterator *iterator = malloc(sizeof(LookaheadIterator));
|
||||
*iterator = ts_language_lookaheads(self, state);
|
||||
return (TSLookaheadIterator *)iterator;
|
||||
}
|
||||
|
||||
void ts_lookahead_iterator_delete(TSLookaheadIterator *self) {
|
||||
free(self);
|
||||
}
|
||||
|
||||
bool ts_lookahead_iterator_reset_state(TSLookaheadIterator * self, TSStateId state) {
|
||||
LookaheadIterator *iterator = (LookaheadIterator *)self;
|
||||
if (state >= iterator->language->state_count) return false;
|
||||
*iterator = ts_language_lookaheads(iterator->language, state);
|
||||
return true;
|
||||
}
|
||||
|
||||
const TSLanguage *ts_lookahead_iterator_language(const TSLookaheadIterator *self) {
|
||||
const LookaheadIterator *iterator = (const LookaheadIterator *)self;
|
||||
return iterator->language;
|
||||
}
|
||||
|
||||
bool ts_lookahead_iterator_reset(TSLookaheadIterator *self, const TSLanguage *language, TSStateId state) {
|
||||
if (state >= language->state_count) return false;
|
||||
LookaheadIterator *iterator = (LookaheadIterator *)self;
|
||||
*iterator = ts_language_lookaheads(language, state);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ts_lookahead_iterator_next(TSLookaheadIterator *self) {
|
||||
LookaheadIterator *iterator = (LookaheadIterator *)self;
|
||||
return ts_lookahead_iterator__next(iterator);
|
||||
}
|
||||
|
||||
TSSymbol ts_lookahead_iterator_current_symbol(const TSLookaheadIterator *self) {
|
||||
const LookaheadIterator *iterator = (const LookaheadIterator *)self;
|
||||
return iterator->symbol;
|
||||
}
|
||||
|
||||
const char *ts_lookahead_iterator_current_symbol_name(const TSLookaheadIterator *self) {
|
||||
const LookaheadIterator *iterator = (const LookaheadIterator *)self;
|
||||
return ts_language_symbol_name(iterator->language, iterator->symbol);
|
||||
}
|
||||
|
|
@ -1,299 +0,0 @@
|
|||
#ifndef TREE_SITTER_LANGUAGE_H_
|
||||
#define TREE_SITTER_LANGUAGE_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "./subtree.h"
|
||||
#include "./parser.h"
|
||||
|
||||
#define ts_builtin_sym_error_repeat (ts_builtin_sym_error - 1)
|
||||
|
||||
#define LANGUAGE_VERSION_WITH_PRIMARY_STATES 14
|
||||
#define LANGUAGE_VERSION_USABLE_VIA_WASM 13
|
||||
|
||||
typedef struct {
|
||||
const TSParseAction *actions;
|
||||
uint32_t action_count;
|
||||
bool is_reusable;
|
||||
} TableEntry;
|
||||
|
||||
typedef struct {
|
||||
const TSLanguage *language;
|
||||
const uint16_t *data;
|
||||
const uint16_t *group_end;
|
||||
TSStateId state;
|
||||
uint16_t table_value;
|
||||
uint16_t section_index;
|
||||
uint16_t group_count;
|
||||
bool is_small_state;
|
||||
|
||||
const TSParseAction *actions;
|
||||
TSSymbol symbol;
|
||||
TSStateId next_state;
|
||||
uint16_t action_count;
|
||||
} LookaheadIterator;
|
||||
|
||||
void ts_language_table_entry(const TSLanguage *, TSStateId, TSSymbol, TableEntry *);
|
||||
|
||||
TSSymbolMetadata ts_language_symbol_metadata(const TSLanguage *, TSSymbol);
|
||||
|
||||
TSSymbol ts_language_public_symbol(const TSLanguage *, TSSymbol);
|
||||
|
||||
TSStateId ts_language_next_state(const TSLanguage *self, TSStateId state, TSSymbol symbol);
|
||||
|
||||
static inline bool ts_language_is_symbol_external(const TSLanguage *self, TSSymbol symbol) {
|
||||
return 0 < symbol && symbol < self->external_token_count + 1;
|
||||
}
|
||||
|
||||
static inline const TSParseAction *ts_language_actions(
|
||||
const TSLanguage *self,
|
||||
TSStateId state,
|
||||
TSSymbol symbol,
|
||||
uint32_t *count
|
||||
) {
|
||||
TableEntry entry;
|
||||
ts_language_table_entry(self, state, symbol, &entry);
|
||||
*count = entry.action_count;
|
||||
return entry.actions;
|
||||
}
|
||||
|
||||
static inline bool ts_language_has_reduce_action(
|
||||
const TSLanguage *self,
|
||||
TSStateId state,
|
||||
TSSymbol symbol
|
||||
) {
|
||||
TableEntry entry;
|
||||
ts_language_table_entry(self, state, symbol, &entry);
|
||||
return entry.action_count > 0 && entry.actions[0].type == TSParseActionTypeReduce;
|
||||
}
|
||||
|
||||
// Lookup the table value for a given symbol and state.
|
||||
//
|
||||
// For non-terminal symbols, the table value represents a successor state.
|
||||
// For terminal symbols, it represents an index in the actions table.
|
||||
// For 'large' parse states, this is a direct lookup. For 'small' parse
|
||||
// states, this requires searching through the symbol groups to find
|
||||
// the given symbol.
|
||||
static inline uint16_t ts_language_lookup(
|
||||
const TSLanguage *self,
|
||||
TSStateId state,
|
||||
TSSymbol symbol
|
||||
) {
|
||||
if (state >= self->large_state_count) {
|
||||
uint32_t index = self->small_parse_table_map[state - self->large_state_count];
|
||||
const uint16_t *data = &self->small_parse_table[index];
|
||||
uint16_t group_count = *(data++);
|
||||
for (unsigned i = 0; i < group_count; i++) {
|
||||
uint16_t section_value = *(data++);
|
||||
uint16_t symbol_count = *(data++);
|
||||
for (unsigned j = 0; j < symbol_count; j++) {
|
||||
if (*(data++) == symbol) return section_value;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
} else {
|
||||
return self->parse_table[state * self->symbol_count + symbol];
|
||||
}
|
||||
}
|
||||
|
||||
static inline bool ts_language_has_actions(
|
||||
const TSLanguage *self,
|
||||
TSStateId state,
|
||||
TSSymbol symbol
|
||||
) {
|
||||
return ts_language_lookup(self, state, symbol) != 0;
|
||||
}
|
||||
|
||||
// Iterate over all of the symbols that are valid in the given state.
|
||||
//
|
||||
// For 'large' parse states, this just requires iterating through
|
||||
// all possible symbols and checking the parse table for each one.
|
||||
// For 'small' parse states, this exploits the structure of the
|
||||
// table to only visit the valid symbols.
|
||||
static inline LookaheadIterator ts_language_lookaheads(
|
||||
const TSLanguage *self,
|
||||
TSStateId state
|
||||
) {
|
||||
bool is_small_state = state >= self->large_state_count;
|
||||
const uint16_t *data;
|
||||
const uint16_t *group_end = NULL;
|
||||
uint16_t group_count = 0;
|
||||
if (is_small_state) {
|
||||
uint32_t index = self->small_parse_table_map[state - self->large_state_count];
|
||||
data = &self->small_parse_table[index];
|
||||
group_end = data + 1;
|
||||
group_count = *data;
|
||||
} else {
|
||||
data = &self->parse_table[state * self->symbol_count] - 1;
|
||||
}
|
||||
return (LookaheadIterator) {
|
||||
.language = self,
|
||||
.data = data,
|
||||
.group_end = group_end,
|
||||
.group_count = group_count,
|
||||
.is_small_state = is_small_state,
|
||||
.symbol = UINT16_MAX,
|
||||
.next_state = 0,
|
||||
};
|
||||
}
|
||||
|
||||
static inline bool ts_lookahead_iterator__next(LookaheadIterator *self) {
|
||||
// For small parse states, valid symbols are listed explicitly,
|
||||
// grouped by their value. There's no need to look up the actions
|
||||
// again until moving to the next group.
|
||||
if (self->is_small_state) {
|
||||
self->data++;
|
||||
if (self->data == self->group_end) {
|
||||
if (self->group_count == 0) return false;
|
||||
self->group_count--;
|
||||
self->table_value = *(self->data++);
|
||||
unsigned symbol_count = *(self->data++);
|
||||
self->group_end = self->data + symbol_count;
|
||||
self->symbol = *self->data;
|
||||
} else {
|
||||
self->symbol = *self->data;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// For large parse states, iterate through every symbol until one
|
||||
// is found that has valid actions.
|
||||
else {
|
||||
do {
|
||||
self->data++;
|
||||
self->symbol++;
|
||||
if (self->symbol >= self->language->symbol_count) return false;
|
||||
self->table_value = *self->data;
|
||||
} while (!self->table_value);
|
||||
}
|
||||
|
||||
// Depending on if the symbols is terminal or non-terminal, the table value either
|
||||
// represents a list of actions or a successor state.
|
||||
if (self->symbol < self->language->token_count) {
|
||||
const TSParseActionEntry *entry = &self->language->parse_actions[self->table_value];
|
||||
self->action_count = entry->entry.count;
|
||||
self->actions = (const TSParseAction *)(entry + 1);
|
||||
self->next_state = 0;
|
||||
} else {
|
||||
self->action_count = 0;
|
||||
self->next_state = self->table_value;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Whether the state is a "primary state". If this returns false, it indicates that there exists
|
||||
// another state that behaves identically to this one with respect to query analysis.
|
||||
static inline bool ts_language_state_is_primary(
|
||||
const TSLanguage *self,
|
||||
TSStateId state
|
||||
) {
|
||||
if (self->version >= LANGUAGE_VERSION_WITH_PRIMARY_STATES) {
|
||||
return state == self->primary_state_ids[state];
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
static inline const bool *ts_language_enabled_external_tokens(
|
||||
const TSLanguage *self,
|
||||
unsigned external_scanner_state
|
||||
) {
|
||||
if (external_scanner_state == 0) {
|
||||
return NULL;
|
||||
} else {
|
||||
return self->external_scanner.states + self->external_token_count * external_scanner_state;
|
||||
}
|
||||
}
|
||||
|
||||
static inline const TSSymbol *ts_language_alias_sequence(
|
||||
const TSLanguage *self,
|
||||
uint32_t production_id
|
||||
) {
|
||||
return production_id ?
|
||||
&self->alias_sequences[production_id * self->max_alias_sequence_length] :
|
||||
NULL;
|
||||
}
|
||||
|
||||
static inline TSSymbol ts_language_alias_at(
|
||||
const TSLanguage *self,
|
||||
uint32_t production_id,
|
||||
uint32_t child_index
|
||||
) {
|
||||
return production_id ?
|
||||
self->alias_sequences[production_id * self->max_alias_sequence_length + child_index] :
|
||||
0;
|
||||
}
|
||||
|
||||
static inline void ts_language_field_map(
|
||||
const TSLanguage *self,
|
||||
uint32_t production_id,
|
||||
const TSFieldMapEntry **start,
|
||||
const TSFieldMapEntry **end
|
||||
) {
|
||||
if (self->field_count == 0) {
|
||||
*start = NULL;
|
||||
*end = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
TSFieldMapSlice slice = self->field_map_slices[production_id];
|
||||
*start = &self->field_map_entries[slice.index];
|
||||
*end = &self->field_map_entries[slice.index] + slice.length;
|
||||
}
|
||||
|
||||
static inline void ts_language_aliases_for_symbol(
|
||||
const TSLanguage *self,
|
||||
TSSymbol original_symbol,
|
||||
const TSSymbol **start,
|
||||
const TSSymbol **end
|
||||
) {
|
||||
*start = &self->public_symbol_map[original_symbol];
|
||||
*end = *start + 1;
|
||||
|
||||
unsigned idx = 0;
|
||||
for (;;) {
|
||||
TSSymbol symbol = self->alias_map[idx++];
|
||||
if (symbol == 0 || symbol > original_symbol) break;
|
||||
uint16_t count = self->alias_map[idx++];
|
||||
if (symbol == original_symbol) {
|
||||
*start = &self->alias_map[idx];
|
||||
*end = &self->alias_map[idx + count];
|
||||
break;
|
||||
}
|
||||
idx += count;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void ts_language_write_symbol_as_dot_string(
|
||||
const TSLanguage *self,
|
||||
FILE *f,
|
||||
TSSymbol symbol
|
||||
) {
|
||||
const char *name = ts_language_symbol_name(self, symbol);
|
||||
for (const char *chr = name; *chr; chr++) {
|
||||
switch (*chr) {
|
||||
case '"':
|
||||
case '\\':
|
||||
fputc('\\', f);
|
||||
fputc(*chr, f);
|
||||
break;
|
||||
case '\n':
|
||||
fputs("\\n", f);
|
||||
break;
|
||||
case '\t':
|
||||
fputs("\\t", f);
|
||||
break;
|
||||
default:
|
||||
fputc(*chr, f);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // TREE_SITTER_LANGUAGE_H_
|
||||
|
|
@ -1,52 +0,0 @@
|
|||
#ifndef TREE_SITTER_LENGTH_H_
|
||||
#define TREE_SITTER_LENGTH_H_
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include "./point.h"
|
||||
#include "api.h"
|
||||
|
||||
typedef struct {
|
||||
uint32_t bytes;
|
||||
TSPoint extent;
|
||||
} Length;
|
||||
|
||||
static const Length LENGTH_UNDEFINED = {0, {0, 1}};
|
||||
static const Length LENGTH_MAX = {UINT32_MAX, {UINT32_MAX, UINT32_MAX}};
|
||||
|
||||
static inline bool length_is_undefined(Length length) {
|
||||
return length.bytes == 0 && length.extent.column != 0;
|
||||
}
|
||||
|
||||
static inline Length length_min(Length len1, Length len2) {
|
||||
return (len1.bytes < len2.bytes) ? len1 : len2;
|
||||
}
|
||||
|
||||
static inline Length length_add(Length len1, Length len2) {
|
||||
Length result;
|
||||
result.bytes = len1.bytes + len2.bytes;
|
||||
result.extent = point_add(len1.extent, len2.extent);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline Length length_sub(Length len1, Length len2) {
|
||||
Length result;
|
||||
result.bytes = len1.bytes - len2.bytes;
|
||||
result.extent = point_sub(len1.extent, len2.extent);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline Length length_zero(void) {
|
||||
Length result = {0, {0, 0}};
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline Length length_saturating_sub(Length len1, Length len2) {
|
||||
if (len1.bytes > len2.bytes) {
|
||||
return length_sub(len1, len2);
|
||||
} else {
|
||||
return length_zero();
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,456 +0,0 @@
|
|||
#include "./lexer.h"
|
||||
#include "./length.h"
|
||||
#include "./subtree.h"
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define LOG(message, character) \
|
||||
if (self->logger.log) \
|
||||
{ \
|
||||
snprintf(self->debug_buffer, TREE_SITTER_SERIALIZATION_BUFFER_SIZE, \
|
||||
32 <= character && character < 127 ? message \
|
||||
" character:'%c'" \
|
||||
: message " character:%d", \
|
||||
character); \
|
||||
self->logger.log(self->logger.payload, TSLogTypeLex, \
|
||||
self->debug_buffer); \
|
||||
}
|
||||
|
||||
static const int32_t BYTE_ORDER_MARK = 0xFEFF;
|
||||
|
||||
static const TSRange DEFAULT_RANGE = {.start_point =
|
||||
{
|
||||
.row = 0,
|
||||
.column = 0,
|
||||
},
|
||||
.end_point =
|
||||
{
|
||||
.row = UINT32_MAX,
|
||||
.column = UINT32_MAX,
|
||||
},
|
||||
.start_byte = 0,
|
||||
.end_byte = UINT32_MAX};
|
||||
|
||||
// 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.
|
||||
static bool ts_lexer__eof(const TSLexer *_self)
|
||||
{
|
||||
Lexer *self = (Lexer *)_self;
|
||||
return self->current_included_range_index == self->included_range_count;
|
||||
}
|
||||
|
||||
// Clear the currently stored chunk of source code, because the lexer's
|
||||
// position has changed.
|
||||
static void ts_lexer__clear_chunk(Lexer *self)
|
||||
{
|
||||
self->chunk = NULL;
|
||||
self->chunk_size = 0;
|
||||
self->chunk_start = 0;
|
||||
}
|
||||
|
||||
// Call the lexer's input callback to obtain a new chunk of source code
|
||||
// for the current position.
|
||||
static void ts_lexer__get_chunk(Lexer *self)
|
||||
{
|
||||
self->chunk_start = self->current_position.bytes;
|
||||
self->chunk =
|
||||
self->input.read(self->input.payload, self->current_position.bytes,
|
||||
self->current_position.extent, &self->chunk_size);
|
||||
if (!self->chunk_size)
|
||||
{
|
||||
self->current_included_range_index = self->included_range_count;
|
||||
self->chunk = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
typedef uint32_t (*UnicodeDecodeFunction)(const uint8_t *chunk, uint32_t size,
|
||||
int32_t *lookahead);
|
||||
|
||||
uint32_t my_decode(const uint8_t *chunk, uint32_t size, int32_t *lookahead)
|
||||
{
|
||||
(void)(size);
|
||||
*((uint32_t *)lookahead) = *chunk;
|
||||
return (1);
|
||||
}
|
||||
|
||||
#define TS_DECODE_ERROR -1
|
||||
|
||||
// Decode the next unicode character in the current chunk of source code.
|
||||
// This assumes that the lexer has already retrieved a chunk of source
|
||||
// code that spans the current position.
|
||||
static void ts_lexer__get_lookahead(Lexer *self)
|
||||
{
|
||||
uint32_t position_in_chunk =
|
||||
self->current_position.bytes - self->chunk_start;
|
||||
uint32_t size = self->chunk_size - position_in_chunk;
|
||||
|
||||
if (size == 0)
|
||||
{
|
||||
self->lookahead_size = 1;
|
||||
self->data.lookahead = '\0';
|
||||
return;
|
||||
}
|
||||
|
||||
const uint8_t *chunk = (const uint8_t *)self->chunk + position_in_chunk;
|
||||
UnicodeDecodeFunction decode = my_decode;
|
||||
|
||||
self->lookahead_size = decode(chunk, size, &self->data.lookahead);
|
||||
|
||||
// If this chunk ended in the middle of a multi-byte character,
|
||||
// try again with a fresh chunk.
|
||||
if (self->data.lookahead == TS_DECODE_ERROR && size < 4)
|
||||
{
|
||||
ts_lexer__get_chunk(self);
|
||||
chunk = (const uint8_t *)self->chunk;
|
||||
size = self->chunk_size;
|
||||
self->lookahead_size = decode(chunk, size, &self->data.lookahead);
|
||||
}
|
||||
|
||||
if (self->data.lookahead == TS_DECODE_ERROR)
|
||||
{
|
||||
self->lookahead_size = 1;
|
||||
}
|
||||
}
|
||||
|
||||
static void ts_lexer_goto(Lexer *self, Length position)
|
||||
{
|
||||
self->current_position = position;
|
||||
|
||||
// Move to the first valid position at or after the given position.
|
||||
bool found_included_range = false;
|
||||
for (unsigned i = 0; i < self->included_range_count; i++)
|
||||
{
|
||||
TSRange *included_range = &self->included_ranges[i];
|
||||
if (included_range->end_byte > self->current_position.bytes &&
|
||||
included_range->end_byte > included_range->start_byte)
|
||||
{
|
||||
if (included_range->start_byte >= self->current_position.bytes)
|
||||
{
|
||||
self->current_position = (Length){
|
||||
.bytes = included_range->start_byte,
|
||||
.extent = included_range->start_point,
|
||||
};
|
||||
}
|
||||
|
||||
self->current_included_range_index = i;
|
||||
found_included_range = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (found_included_range)
|
||||
{
|
||||
// If the current position is outside of the current chunk of text,
|
||||
// then clear out the current chunk of text.
|
||||
if (self->chunk && (self->current_position.bytes < self->chunk_start ||
|
||||
self->current_position.bytes >=
|
||||
self->chunk_start + self->chunk_size))
|
||||
{
|
||||
ts_lexer__clear_chunk(self);
|
||||
}
|
||||
|
||||
self->lookahead_size = 0;
|
||||
self->data.lookahead = '\0';
|
||||
}
|
||||
|
||||
// If the given position is beyond any of included ranges, move to the EOF
|
||||
// state - past the end of the included ranges.
|
||||
else
|
||||
{
|
||||
self->current_included_range_index = self->included_range_count;
|
||||
TSRange *last_included_range =
|
||||
&self->included_ranges[self->included_range_count - 1];
|
||||
self->current_position = (Length){
|
||||
.bytes = last_included_range->end_byte,
|
||||
.extent = last_included_range->end_point,
|
||||
};
|
||||
ts_lexer__clear_chunk(self);
|
||||
self->lookahead_size = 1;
|
||||
self->data.lookahead = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
// Intended to be called only from functions that control logging.
|
||||
static void ts_lexer__do_advance(Lexer *self, bool skip)
|
||||
{
|
||||
if (self->lookahead_size)
|
||||
{
|
||||
self->current_position.bytes += self->lookahead_size;
|
||||
if (self->data.lookahead == '\n')
|
||||
{
|
||||
self->current_position.extent.row++;
|
||||
self->current_position.extent.column = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
self->current_position.extent.column += self->lookahead_size;
|
||||
}
|
||||
}
|
||||
|
||||
const TSRange *current_range =
|
||||
&self->included_ranges[self->current_included_range_index];
|
||||
while (self->current_position.bytes >= current_range->end_byte ||
|
||||
current_range->end_byte == current_range->start_byte)
|
||||
{
|
||||
if (self->current_included_range_index < self->included_range_count)
|
||||
{
|
||||
self->current_included_range_index++;
|
||||
}
|
||||
if (self->current_included_range_index < self->included_range_count)
|
||||
{
|
||||
current_range++;
|
||||
self->current_position = (Length){
|
||||
current_range->start_byte,
|
||||
current_range->start_point,
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
current_range = NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (skip)
|
||||
self->token_start_position = self->current_position;
|
||||
|
||||
if (current_range)
|
||||
{
|
||||
if (self->current_position.bytes < self->chunk_start ||
|
||||
self->current_position.bytes >=
|
||||
self->chunk_start + self->chunk_size)
|
||||
{
|
||||
ts_lexer__get_chunk(self);
|
||||
}
|
||||
ts_lexer__get_lookahead(self);
|
||||
}
|
||||
else
|
||||
{
|
||||
ts_lexer__clear_chunk(self);
|
||||
self->data.lookahead = '\0';
|
||||
self->lookahead_size = 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Advance to the next character in the source code, retrieving a new
|
||||
// chunk of source code if needed.
|
||||
static void ts_lexer__advance(TSLexer *_self, bool skip)
|
||||
{
|
||||
Lexer *self = (Lexer *)_self;
|
||||
if (!self->chunk)
|
||||
return;
|
||||
ts_lexer__do_advance(self, skip);
|
||||
}
|
||||
|
||||
// Mark that a token match has completed. This can be called multiple
|
||||
// times if a longer match is found later.
|
||||
static void ts_lexer__mark_end(TSLexer *_self)
|
||||
{
|
||||
Lexer *self = (Lexer *)_self;
|
||||
if (!ts_lexer__eof(&self->data))
|
||||
{
|
||||
// If the lexer is right at the beginning of included range,
|
||||
// then the token should be considered to end at the *end* of the
|
||||
// previous included range, rather than here.
|
||||
TSRange *current_included_range =
|
||||
&self->included_ranges[self->current_included_range_index];
|
||||
if (self->current_included_range_index > 0 &&
|
||||
self->current_position.bytes == current_included_range->start_byte)
|
||||
{
|
||||
TSRange *previous_included_range = current_included_range - 1;
|
||||
self->token_end_position = (Length){
|
||||
previous_included_range->end_byte,
|
||||
previous_included_range->end_point,
|
||||
};
|
||||
return;
|
||||
}
|
||||
}
|
||||
self->token_end_position = self->current_position;
|
||||
}
|
||||
|
||||
static uint32_t ts_lexer__get_column(TSLexer *_self)
|
||||
{
|
||||
Lexer *self = (Lexer *)_self;
|
||||
|
||||
uint32_t goal_byte = self->current_position.bytes;
|
||||
|
||||
self->did_get_column = true;
|
||||
self->current_position.bytes -= self->current_position.extent.column;
|
||||
self->current_position.extent.column = 0;
|
||||
|
||||
if (self->current_position.bytes < self->chunk_start)
|
||||
{
|
||||
ts_lexer__get_chunk(self);
|
||||
}
|
||||
|
||||
uint32_t result = 0;
|
||||
if (!ts_lexer__eof(_self))
|
||||
{
|
||||
ts_lexer__get_lookahead(self);
|
||||
while (self->current_position.bytes < goal_byte && self->chunk)
|
||||
{
|
||||
result++;
|
||||
ts_lexer__do_advance(self, false);
|
||||
if (ts_lexer__eof(_self))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Is the lexer at a boundary between two disjoint included ranges of
|
||||
// source code? This is exposed as an API because some languages' external
|
||||
// scanners need to perform custom actions at these boundaries.
|
||||
static bool ts_lexer__is_at_included_range_start(const TSLexer *_self)
|
||||
{
|
||||
const Lexer *self = (const Lexer *)_self;
|
||||
if (self->current_included_range_index < self->included_range_count)
|
||||
{
|
||||
TSRange *current_range =
|
||||
&self->included_ranges[self->current_included_range_index];
|
||||
return self->current_position.bytes == current_range->start_byte;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void ts_lexer_init(Lexer *self)
|
||||
{
|
||||
*self = (Lexer){
|
||||
.data =
|
||||
{
|
||||
// The lexer's methods are stored as struct fields so that
|
||||
// generated
|
||||
// parsers can call them without needing to be linked against
|
||||
// this
|
||||
// library.
|
||||
.advance = ts_lexer__advance,
|
||||
.mark_end = ts_lexer__mark_end,
|
||||
.get_column = ts_lexer__get_column,
|
||||
.is_at_included_range_start =
|
||||
ts_lexer__is_at_included_range_start,
|
||||
.eof = ts_lexer__eof,
|
||||
.lookahead = 0,
|
||||
.result_symbol = 0,
|
||||
},
|
||||
.chunk = NULL,
|
||||
.chunk_size = 0,
|
||||
.chunk_start = 0,
|
||||
.current_position = {0, {0, 0}},
|
||||
.logger = {.payload = NULL, .log = NULL},
|
||||
.included_ranges = NULL,
|
||||
.included_range_count = 0,
|
||||
.current_included_range_index = 0,
|
||||
};
|
||||
ts_lexer_set_included_ranges(self, NULL, 0);
|
||||
}
|
||||
|
||||
void ts_lexer_delete(Lexer *self)
|
||||
{
|
||||
free(self->included_ranges);
|
||||
}
|
||||
|
||||
void ts_lexer_set_input(Lexer *self, TSInput input)
|
||||
{
|
||||
self->input = input;
|
||||
ts_lexer__clear_chunk(self);
|
||||
ts_lexer_goto(self, self->current_position);
|
||||
}
|
||||
|
||||
// Move the lexer to the given position. This doesn't do any work
|
||||
// if the parser is already at the given position.
|
||||
void ts_lexer_reset(Lexer *self, Length position)
|
||||
{
|
||||
if (position.bytes != self->current_position.bytes)
|
||||
{
|
||||
ts_lexer_goto(self, position);
|
||||
}
|
||||
}
|
||||
|
||||
void ts_lexer_start(Lexer *self)
|
||||
{
|
||||
self->token_start_position = self->current_position;
|
||||
self->token_end_position = LENGTH_UNDEFINED;
|
||||
self->data.result_symbol = 0;
|
||||
self->did_get_column = false;
|
||||
if (!ts_lexer__eof(&self->data))
|
||||
{
|
||||
if (!self->chunk_size)
|
||||
ts_lexer__get_chunk(self);
|
||||
if (!self->lookahead_size)
|
||||
ts_lexer__get_lookahead(self);
|
||||
if (self->current_position.bytes == 0 &&
|
||||
self->data.lookahead == BYTE_ORDER_MARK)
|
||||
ts_lexer__advance(&self->data, true);
|
||||
}
|
||||
}
|
||||
|
||||
void ts_lexer_finish(Lexer *self, uint32_t *lookahead_end_byte)
|
||||
{
|
||||
if (length_is_undefined(self->token_end_position))
|
||||
{
|
||||
ts_lexer__mark_end(&self->data);
|
||||
}
|
||||
|
||||
// If the token ended at an included range boundary, then its end position
|
||||
// will have been reset to the end of the preceding range. Reset the start
|
||||
// position to match.
|
||||
if (self->token_end_position.bytes < self->token_start_position.bytes)
|
||||
{
|
||||
self->token_start_position = self->token_end_position;
|
||||
}
|
||||
|
||||
uint32_t current_lookahead_end_byte = self->current_position.bytes + 1;
|
||||
|
||||
// In order to determine that a byte sequence is invalid UTF8 or UTF16,
|
||||
// the character decoding algorithm may have looked at the following byte.
|
||||
// Therefore, the next byte *after* the current (invalid) character
|
||||
// affects the interpretation of the current character.
|
||||
if (self->data.lookahead == TS_DECODE_ERROR)
|
||||
{
|
||||
current_lookahead_end_byte++;
|
||||
}
|
||||
|
||||
if (current_lookahead_end_byte > *lookahead_end_byte)
|
||||
{
|
||||
*lookahead_end_byte = current_lookahead_end_byte;
|
||||
}
|
||||
}
|
||||
|
||||
void ts_lexer_advance_to_end(Lexer *self)
|
||||
{
|
||||
while (self->chunk)
|
||||
{
|
||||
ts_lexer__advance(&self->data, false);
|
||||
}
|
||||
}
|
||||
|
||||
void ts_lexer_mark_end(Lexer *self)
|
||||
{
|
||||
ts_lexer__mark_end(&self->data);
|
||||
}
|
||||
|
||||
bool ts_lexer_set_included_ranges(Lexer *self, const TSRange *ranges,
|
||||
uint32_t count)
|
||||
{
|
||||
ranges = &DEFAULT_RANGE;
|
||||
count = 1;
|
||||
size_t size = count * sizeof(TSRange);
|
||||
self->included_ranges = realloc(self->included_ranges, size);
|
||||
memcpy(self->included_ranges, ranges, size);
|
||||
self->included_range_count = count;
|
||||
ts_lexer_goto(self, self->current_position);
|
||||
return true;
|
||||
}
|
||||
|
||||
TSRange *ts_lexer_included_ranges(const Lexer *self, uint32_t *count)
|
||||
{
|
||||
*count = self->included_range_count;
|
||||
return self->included_ranges;
|
||||
}
|
||||
|
||||
#undef LOG
|
||||
|
|
@ -1,49 +0,0 @@
|
|||
#ifndef TREE_SITTER_LEXER_H_
|
||||
#define TREE_SITTER_LEXER_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "./length.h"
|
||||
#include "./subtree.h"
|
||||
#include "api.h"
|
||||
#include "./parser.h"
|
||||
|
||||
typedef struct {
|
||||
TSLexer data;
|
||||
Length current_position;
|
||||
Length token_start_position;
|
||||
Length token_end_position;
|
||||
|
||||
TSRange *included_ranges;
|
||||
const char *chunk;
|
||||
TSInput input;
|
||||
TSLogger logger;
|
||||
|
||||
uint32_t included_range_count;
|
||||
uint32_t current_included_range_index;
|
||||
uint32_t chunk_start;
|
||||
uint32_t chunk_size;
|
||||
uint32_t lookahead_size;
|
||||
bool did_get_column;
|
||||
|
||||
char debug_buffer[TREE_SITTER_SERIALIZATION_BUFFER_SIZE];
|
||||
} Lexer;
|
||||
|
||||
void ts_lexer_init(Lexer *);
|
||||
void ts_lexer_delete(Lexer *);
|
||||
void ts_lexer_set_input(Lexer *, TSInput);
|
||||
void ts_lexer_reset(Lexer *, Length);
|
||||
void ts_lexer_start(Lexer *);
|
||||
void ts_lexer_finish(Lexer *, uint32_t *);
|
||||
void ts_lexer_advance_to_end(Lexer *);
|
||||
void ts_lexer_mark_end(Lexer *);
|
||||
bool ts_lexer_set_included_ranges(Lexer *self, const TSRange *ranges, uint32_t count);
|
||||
TSRange *ts_lexer_included_ranges(const Lexer *self, uint32_t *count);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // TREE_SITTER_LEXER_H_
|
||||
|
|
@ -1,774 +0,0 @@
|
|||
#include <stdbool.h>
|
||||
#include "./subtree.h"
|
||||
#include "./tree.h"
|
||||
#include "./language.h"
|
||||
|
||||
typedef struct {
|
||||
Subtree parent;
|
||||
const TSTree *tree;
|
||||
Length position;
|
||||
uint32_t child_index;
|
||||
uint32_t structural_child_index;
|
||||
const TSSymbol *alias_sequence;
|
||||
} NodeChildIterator;
|
||||
|
||||
// TSNode - constructors
|
||||
|
||||
TSNode ts_node_new(
|
||||
const TSTree *tree,
|
||||
const Subtree *subtree,
|
||||
Length position,
|
||||
TSSymbol alias
|
||||
) {
|
||||
return (TSNode) {
|
||||
{position.bytes, position.extent.row, position.extent.column, alias},
|
||||
subtree,
|
||||
tree,
|
||||
};
|
||||
}
|
||||
|
||||
static inline TSNode ts_node__null(void) {
|
||||
return ts_node_new(NULL, NULL, length_zero(), 0);
|
||||
}
|
||||
|
||||
// TSNode - accessors
|
||||
|
||||
uint32_t ts_node_start_byte(TSNode self) {
|
||||
return self.context[0];
|
||||
}
|
||||
|
||||
TSPoint ts_node_start_point(TSNode self) {
|
||||
return (TSPoint) {self.context[1], self.context[2]};
|
||||
}
|
||||
|
||||
static inline uint32_t ts_node__alias(const TSNode *self) {
|
||||
return self->context[3];
|
||||
}
|
||||
|
||||
static inline Subtree ts_node__subtree(TSNode self) {
|
||||
return *(const Subtree *)self.id;
|
||||
}
|
||||
|
||||
// NodeChildIterator
|
||||
|
||||
static inline NodeChildIterator ts_node_iterate_children(const TSNode *node) {
|
||||
Subtree subtree = ts_node__subtree(*node);
|
||||
if (ts_subtree_child_count(subtree) == 0) {
|
||||
return (NodeChildIterator) {NULL_SUBTREE, node->tree, length_zero(), 0, 0, NULL};
|
||||
}
|
||||
const TSSymbol *alias_sequence = ts_language_alias_sequence(
|
||||
node->tree->language,
|
||||
subtree.ptr->production_id
|
||||
);
|
||||
return (NodeChildIterator) {
|
||||
.tree = node->tree,
|
||||
.parent = subtree,
|
||||
.position = {ts_node_start_byte(*node), ts_node_start_point(*node)},
|
||||
.child_index = 0,
|
||||
.structural_child_index = 0,
|
||||
.alias_sequence = alias_sequence,
|
||||
};
|
||||
}
|
||||
|
||||
static inline bool ts_node_child_iterator_done(NodeChildIterator *self) {
|
||||
return self->child_index == self->parent.ptr->child_count;
|
||||
}
|
||||
|
||||
static inline bool ts_node_child_iterator_next(
|
||||
NodeChildIterator *self,
|
||||
TSNode *result
|
||||
) {
|
||||
if (!self->parent.ptr || ts_node_child_iterator_done(self)) return false;
|
||||
const Subtree *child = &ts_subtree_children(self->parent)[self->child_index];
|
||||
TSSymbol alias_symbol = 0;
|
||||
if (!ts_subtree_extra(*child)) {
|
||||
if (self->alias_sequence) {
|
||||
alias_symbol = self->alias_sequence[self->structural_child_index];
|
||||
}
|
||||
self->structural_child_index++;
|
||||
}
|
||||
if (self->child_index > 0) {
|
||||
self->position = length_add(self->position, ts_subtree_padding(*child));
|
||||
}
|
||||
*result = ts_node_new(
|
||||
self->tree,
|
||||
child,
|
||||
self->position,
|
||||
alias_symbol
|
||||
);
|
||||
self->position = length_add(self->position, ts_subtree_size(*child));
|
||||
self->child_index++;
|
||||
return true;
|
||||
}
|
||||
|
||||
// TSNode - private
|
||||
|
||||
static inline bool ts_node__is_relevant(TSNode self, bool include_anonymous) {
|
||||
Subtree tree = ts_node__subtree(self);
|
||||
if (include_anonymous) {
|
||||
return ts_subtree_visible(tree) || ts_node__alias(&self);
|
||||
} else {
|
||||
TSSymbol alias = ts_node__alias(&self);
|
||||
if (alias) {
|
||||
return ts_language_symbol_metadata(self.tree->language, alias).named;
|
||||
} else {
|
||||
return ts_subtree_visible(tree) && ts_subtree_named(tree);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static inline uint32_t ts_node__relevant_child_count(
|
||||
TSNode self,
|
||||
bool include_anonymous
|
||||
) {
|
||||
Subtree tree = ts_node__subtree(self);
|
||||
if (ts_subtree_child_count(tree) > 0) {
|
||||
if (include_anonymous) {
|
||||
return tree.ptr->visible_child_count;
|
||||
} else {
|
||||
return tree.ptr->named_child_count;
|
||||
}
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static inline TSNode ts_node__child(
|
||||
TSNode self,
|
||||
uint32_t child_index,
|
||||
bool include_anonymous
|
||||
) {
|
||||
TSNode result = self;
|
||||
bool did_descend = true;
|
||||
|
||||
while (did_descend) {
|
||||
did_descend = false;
|
||||
|
||||
TSNode child;
|
||||
uint32_t index = 0;
|
||||
NodeChildIterator iterator = ts_node_iterate_children(&result);
|
||||
while (ts_node_child_iterator_next(&iterator, &child)) {
|
||||
if (ts_node__is_relevant(child, include_anonymous)) {
|
||||
if (index == child_index) {
|
||||
return child;
|
||||
}
|
||||
index++;
|
||||
} else {
|
||||
uint32_t grandchild_index = child_index - index;
|
||||
uint32_t grandchild_count = ts_node__relevant_child_count(child, include_anonymous);
|
||||
if (grandchild_index < grandchild_count) {
|
||||
did_descend = true;
|
||||
result = child;
|
||||
child_index = grandchild_index;
|
||||
break;
|
||||
}
|
||||
index += grandchild_count;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ts_node__null();
|
||||
}
|
||||
|
||||
static bool ts_subtree_has_trailing_empty_descendant(
|
||||
Subtree self,
|
||||
Subtree other
|
||||
) {
|
||||
for (unsigned i = ts_subtree_child_count(self) - 1; i + 1 > 0; i--) {
|
||||
Subtree child = ts_subtree_children(self)[i];
|
||||
if (ts_subtree_total_bytes(child) > 0) break;
|
||||
if (child.ptr == other.ptr || ts_subtree_has_trailing_empty_descendant(child, other)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static inline TSNode ts_node__prev_sibling(TSNode self, bool include_anonymous) {
|
||||
Subtree self_subtree = ts_node__subtree(self);
|
||||
bool self_is_empty = ts_subtree_total_bytes(self_subtree) == 0;
|
||||
uint32_t target_end_byte = ts_node_end_byte(self);
|
||||
|
||||
TSNode node = ts_node_parent(self);
|
||||
TSNode earlier_node = ts_node__null();
|
||||
bool earlier_node_is_relevant = false;
|
||||
|
||||
while (!ts_node_is_null(node)) {
|
||||
TSNode earlier_child = ts_node__null();
|
||||
bool earlier_child_is_relevant = false;
|
||||
bool found_child_containing_target = false;
|
||||
|
||||
TSNode child;
|
||||
NodeChildIterator iterator = ts_node_iterate_children(&node);
|
||||
while (ts_node_child_iterator_next(&iterator, &child)) {
|
||||
if (child.id == self.id) break;
|
||||
if (iterator.position.bytes > target_end_byte) {
|
||||
found_child_containing_target = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (iterator.position.bytes == target_end_byte &&
|
||||
(!self_is_empty ||
|
||||
ts_subtree_has_trailing_empty_descendant(ts_node__subtree(child), self_subtree))) {
|
||||
found_child_containing_target = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (ts_node__is_relevant(child, include_anonymous)) {
|
||||
earlier_child = child;
|
||||
earlier_child_is_relevant = true;
|
||||
} else if (ts_node__relevant_child_count(child, include_anonymous) > 0) {
|
||||
earlier_child = child;
|
||||
earlier_child_is_relevant = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (found_child_containing_target) {
|
||||
if (!ts_node_is_null(earlier_child)) {
|
||||
earlier_node = earlier_child;
|
||||
earlier_node_is_relevant = earlier_child_is_relevant;
|
||||
}
|
||||
node = child;
|
||||
} else if (earlier_child_is_relevant) {
|
||||
return earlier_child;
|
||||
} else if (!ts_node_is_null(earlier_child)) {
|
||||
node = earlier_child;
|
||||
} else if (earlier_node_is_relevant) {
|
||||
return earlier_node;
|
||||
} else {
|
||||
node = earlier_node;
|
||||
earlier_node = ts_node__null();
|
||||
earlier_node_is_relevant = false;
|
||||
}
|
||||
}
|
||||
|
||||
return ts_node__null();
|
||||
}
|
||||
|
||||
static inline TSNode ts_node__next_sibling(TSNode self, bool include_anonymous) {
|
||||
uint32_t target_end_byte = ts_node_end_byte(self);
|
||||
|
||||
TSNode node = ts_node_parent(self);
|
||||
TSNode later_node = ts_node__null();
|
||||
bool later_node_is_relevant = false;
|
||||
|
||||
while (!ts_node_is_null(node)) {
|
||||
TSNode later_child = ts_node__null();
|
||||
bool later_child_is_relevant = false;
|
||||
TSNode child_containing_target = ts_node__null();
|
||||
|
||||
TSNode child;
|
||||
NodeChildIterator iterator = ts_node_iterate_children(&node);
|
||||
while (ts_node_child_iterator_next(&iterator, &child)) {
|
||||
if (iterator.position.bytes < target_end_byte) continue;
|
||||
if (ts_node_start_byte(child) <= ts_node_start_byte(self)) {
|
||||
if (ts_node__subtree(child).ptr != ts_node__subtree(self).ptr) {
|
||||
child_containing_target = child;
|
||||
}
|
||||
} else if (ts_node__is_relevant(child, include_anonymous)) {
|
||||
later_child = child;
|
||||
later_child_is_relevant = true;
|
||||
break;
|
||||
} else if (ts_node__relevant_child_count(child, include_anonymous) > 0) {
|
||||
later_child = child;
|
||||
later_child_is_relevant = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!ts_node_is_null(child_containing_target)) {
|
||||
if (!ts_node_is_null(later_child)) {
|
||||
later_node = later_child;
|
||||
later_node_is_relevant = later_child_is_relevant;
|
||||
}
|
||||
node = child_containing_target;
|
||||
} else if (later_child_is_relevant) {
|
||||
return later_child;
|
||||
} else if (!ts_node_is_null(later_child)) {
|
||||
node = later_child;
|
||||
} else if (later_node_is_relevant) {
|
||||
return later_node;
|
||||
} else {
|
||||
node = later_node;
|
||||
}
|
||||
}
|
||||
|
||||
return ts_node__null();
|
||||
}
|
||||
|
||||
static inline TSNode ts_node__first_child_for_byte(
|
||||
TSNode self,
|
||||
uint32_t goal,
|
||||
bool include_anonymous
|
||||
) {
|
||||
TSNode node = self;
|
||||
bool did_descend = true;
|
||||
|
||||
while (did_descend) {
|
||||
did_descend = false;
|
||||
|
||||
TSNode child;
|
||||
NodeChildIterator iterator = ts_node_iterate_children(&node);
|
||||
while (ts_node_child_iterator_next(&iterator, &child)) {
|
||||
if (ts_node_end_byte(child) > goal) {
|
||||
if (ts_node__is_relevant(child, include_anonymous)) {
|
||||
return child;
|
||||
} else if (ts_node_child_count(child) > 0) {
|
||||
did_descend = true;
|
||||
node = child;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ts_node__null();
|
||||
}
|
||||
|
||||
static inline TSNode ts_node__descendant_for_byte_range(
|
||||
TSNode self,
|
||||
uint32_t range_start,
|
||||
uint32_t range_end,
|
||||
bool include_anonymous
|
||||
) {
|
||||
TSNode node = self;
|
||||
TSNode last_visible_node = self;
|
||||
|
||||
bool did_descend = true;
|
||||
while (did_descend) {
|
||||
did_descend = false;
|
||||
|
||||
TSNode child;
|
||||
NodeChildIterator iterator = ts_node_iterate_children(&node);
|
||||
while (ts_node_child_iterator_next(&iterator, &child)) {
|
||||
uint32_t node_end = iterator.position.bytes;
|
||||
|
||||
// The end of this node must extend far enough forward to touch
|
||||
// the end of the range and exceed the start of the range.
|
||||
if (node_end < range_end) continue;
|
||||
if (node_end <= range_start) continue;
|
||||
|
||||
// The start of this node must extend far enough backward to
|
||||
// touch the start of the range.
|
||||
if (range_start < ts_node_start_byte(child)) break;
|
||||
|
||||
node = child;
|
||||
if (ts_node__is_relevant(node, include_anonymous)) {
|
||||
last_visible_node = node;
|
||||
}
|
||||
did_descend = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return last_visible_node;
|
||||
}
|
||||
|
||||
static inline TSNode ts_node__descendant_for_point_range(
|
||||
TSNode self,
|
||||
TSPoint range_start,
|
||||
TSPoint range_end,
|
||||
bool include_anonymous
|
||||
) {
|
||||
TSNode node = self;
|
||||
TSNode last_visible_node = self;
|
||||
|
||||
bool did_descend = true;
|
||||
while (did_descend) {
|
||||
did_descend = false;
|
||||
|
||||
TSNode child;
|
||||
NodeChildIterator iterator = ts_node_iterate_children(&node);
|
||||
while (ts_node_child_iterator_next(&iterator, &child)) {
|
||||
TSPoint node_end = iterator.position.extent;
|
||||
|
||||
// The end of this node must extend far enough forward to touch
|
||||
// the end of the range and exceed the start of the range.
|
||||
if (point_lt(node_end, range_end)) continue;
|
||||
if (point_lte(node_end, range_start)) continue;
|
||||
|
||||
// The start of this node must extend far enough backward to
|
||||
// touch the start of the range.
|
||||
if (point_lt(range_start, ts_node_start_point(child))) break;
|
||||
|
||||
node = child;
|
||||
if (ts_node__is_relevant(node, include_anonymous)) {
|
||||
last_visible_node = node;
|
||||
}
|
||||
did_descend = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return last_visible_node;
|
||||
}
|
||||
|
||||
// TSNode - public
|
||||
|
||||
uint32_t ts_node_end_byte(TSNode self) {
|
||||
return ts_node_start_byte(self) + ts_subtree_size(ts_node__subtree(self)).bytes;
|
||||
}
|
||||
|
||||
TSPoint ts_node_end_point(TSNode self) {
|
||||
return point_add(ts_node_start_point(self), ts_subtree_size(ts_node__subtree(self)).extent);
|
||||
}
|
||||
|
||||
TSSymbol ts_node_symbol(TSNode self) {
|
||||
TSSymbol symbol = ts_node__alias(&self);
|
||||
if (!symbol) symbol = ts_subtree_symbol(ts_node__subtree(self));
|
||||
return ts_language_public_symbol(self.tree->language, symbol);
|
||||
}
|
||||
|
||||
const char *ts_node_type(TSNode self) {
|
||||
TSSymbol symbol = ts_node__alias(&self);
|
||||
if (!symbol) symbol = ts_subtree_symbol(ts_node__subtree(self));
|
||||
return ts_language_symbol_name(self.tree->language, symbol);
|
||||
}
|
||||
|
||||
const TSLanguage *ts_node_language(TSNode self) {
|
||||
return self.tree->language;
|
||||
}
|
||||
|
||||
TSSymbol ts_node_grammar_symbol(TSNode self) {
|
||||
return ts_subtree_symbol(ts_node__subtree(self));
|
||||
}
|
||||
|
||||
const char *ts_node_grammar_type(TSNode self) {
|
||||
TSSymbol symbol = ts_subtree_symbol(ts_node__subtree(self));
|
||||
return ts_language_symbol_name(self.tree->language, symbol);
|
||||
}
|
||||
|
||||
char *ts_node_string(TSNode self) {
|
||||
TSSymbol alias_symbol = ts_node__alias(&self);
|
||||
return ts_subtree_string(
|
||||
ts_node__subtree(self),
|
||||
alias_symbol,
|
||||
ts_language_symbol_metadata(self.tree->language, alias_symbol).visible,
|
||||
self.tree->language,
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
bool ts_node_eq(TSNode self, TSNode other) {
|
||||
return self.tree == other.tree && self.id == other.id;
|
||||
}
|
||||
|
||||
bool ts_node_is_null(TSNode self) {
|
||||
return self.id == 0;
|
||||
}
|
||||
|
||||
bool ts_node_is_extra(TSNode self) {
|
||||
return ts_subtree_extra(ts_node__subtree(self));
|
||||
}
|
||||
|
||||
bool ts_node_is_named(TSNode self) {
|
||||
TSSymbol alias = ts_node__alias(&self);
|
||||
return alias
|
||||
? ts_language_symbol_metadata(self.tree->language, alias).named
|
||||
: ts_subtree_named(ts_node__subtree(self));
|
||||
}
|
||||
|
||||
bool ts_node_is_missing(TSNode self) {
|
||||
return ts_subtree_missing(ts_node__subtree(self));
|
||||
}
|
||||
|
||||
bool ts_node_has_changes(TSNode self) {
|
||||
return ts_subtree_has_changes(ts_node__subtree(self));
|
||||
}
|
||||
|
||||
bool ts_node_has_error(TSNode self) {
|
||||
return ts_subtree_error_cost(ts_node__subtree(self)) > 0;
|
||||
}
|
||||
|
||||
bool ts_node_is_error(TSNode self) {
|
||||
TSSymbol symbol = ts_node_symbol(self);
|
||||
return symbol == ts_builtin_sym_error;
|
||||
}
|
||||
|
||||
uint32_t ts_node_descendant_count(TSNode self) {
|
||||
return ts_subtree_visible_descendant_count(ts_node__subtree(self)) + 1;
|
||||
}
|
||||
|
||||
TSStateId ts_node_parse_state(TSNode self) {
|
||||
return ts_subtree_parse_state(ts_node__subtree(self));
|
||||
}
|
||||
|
||||
TSStateId ts_node_next_parse_state(TSNode self) {
|
||||
const TSLanguage *language = self.tree->language;
|
||||
uint16_t state = ts_node_parse_state(self);
|
||||
if (state == TS_TREE_STATE_NONE) {
|
||||
return TS_TREE_STATE_NONE;
|
||||
}
|
||||
uint16_t symbol = ts_node_grammar_symbol(self);
|
||||
return ts_language_next_state(language, state, symbol);
|
||||
}
|
||||
|
||||
TSNode ts_node_parent(TSNode self) {
|
||||
TSNode node = ts_tree_root_node(self.tree);
|
||||
uint32_t end_byte = ts_node_end_byte(self);
|
||||
if (node.id == self.id) return ts_node__null();
|
||||
|
||||
TSNode last_visible_node = node;
|
||||
bool did_descend = true;
|
||||
while (did_descend) {
|
||||
did_descend = false;
|
||||
|
||||
TSNode child;
|
||||
NodeChildIterator iterator = ts_node_iterate_children(&node);
|
||||
while (ts_node_child_iterator_next(&iterator, &child)) {
|
||||
if (
|
||||
ts_node_start_byte(child) > ts_node_start_byte(self) ||
|
||||
child.id == self.id
|
||||
) break;
|
||||
if (iterator.position.bytes >= end_byte && ts_node_child_count(child) > 0) {
|
||||
node = child;
|
||||
if (ts_node__is_relevant(child, true)) {
|
||||
last_visible_node = node;
|
||||
}
|
||||
did_descend = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return last_visible_node;
|
||||
}
|
||||
|
||||
TSNode ts_node_child(TSNode self, uint32_t child_index) {
|
||||
return ts_node__child(self, child_index, true);
|
||||
}
|
||||
|
||||
TSNode ts_node_named_child(TSNode self, uint32_t child_index) {
|
||||
return ts_node__child(self, child_index, false);
|
||||
}
|
||||
|
||||
TSNode ts_node_child_by_field_id(TSNode self, TSFieldId field_id) {
|
||||
recur:
|
||||
if (!field_id || ts_node_child_count(self) == 0) return ts_node__null();
|
||||
|
||||
const TSFieldMapEntry *field_map, *field_map_end;
|
||||
ts_language_field_map(
|
||||
self.tree->language,
|
||||
ts_node__subtree(self).ptr->production_id,
|
||||
&field_map,
|
||||
&field_map_end
|
||||
);
|
||||
if (field_map == field_map_end) return ts_node__null();
|
||||
|
||||
// The field mappings are sorted by their field id. Scan all
|
||||
// the mappings to find the ones for the given field id.
|
||||
while (field_map->field_id < field_id) {
|
||||
field_map++;
|
||||
if (field_map == field_map_end) return ts_node__null();
|
||||
}
|
||||
while (field_map_end[-1].field_id > field_id) {
|
||||
field_map_end--;
|
||||
if (field_map == field_map_end) return ts_node__null();
|
||||
}
|
||||
|
||||
TSNode child;
|
||||
NodeChildIterator iterator = ts_node_iterate_children(&self);
|
||||
while (ts_node_child_iterator_next(&iterator, &child)) {
|
||||
if (!ts_subtree_extra(ts_node__subtree(child))) {
|
||||
uint32_t index = iterator.structural_child_index - 1;
|
||||
if (index < field_map->child_index) continue;
|
||||
|
||||
// Hidden nodes' fields are "inherited" by their visible parent.
|
||||
if (field_map->inherited) {
|
||||
|
||||
// If this is the *last* possible child node for this field,
|
||||
// then perform a tail call to avoid recursion.
|
||||
if (field_map + 1 == field_map_end) {
|
||||
self = child;
|
||||
goto recur;
|
||||
}
|
||||
|
||||
// Otherwise, descend into this child, but if it doesn't contain
|
||||
// the field, continue searching subsequent children.
|
||||
else {
|
||||
TSNode result = ts_node_child_by_field_id(child, field_id);
|
||||
if (result.id) return result;
|
||||
field_map++;
|
||||
if (field_map == field_map_end) return ts_node__null();
|
||||
}
|
||||
}
|
||||
|
||||
else if (ts_node__is_relevant(child, true)) {
|
||||
return child;
|
||||
}
|
||||
|
||||
// If the field refers to a hidden node with visible children,
|
||||
// return the first visible child.
|
||||
else if (ts_node_child_count(child) > 0 ) {
|
||||
return ts_node_child(child, 0);
|
||||
}
|
||||
|
||||
// Otherwise, continue searching subsequent children.
|
||||
else {
|
||||
field_map++;
|
||||
if (field_map == field_map_end) return ts_node__null();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ts_node__null();
|
||||
}
|
||||
|
||||
static inline const char *ts_node__field_name_from_language(TSNode self, uint32_t structural_child_index) {
|
||||
const TSFieldMapEntry *field_map, *field_map_end;
|
||||
ts_language_field_map(
|
||||
self.tree->language,
|
||||
ts_node__subtree(self).ptr->production_id,
|
||||
&field_map,
|
||||
&field_map_end
|
||||
);
|
||||
for (; field_map != field_map_end; field_map++) {
|
||||
if (!field_map->inherited && field_map->child_index == structural_child_index) {
|
||||
return self.tree->language->field_names[field_map->field_id];
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char *ts_node_field_name_for_child(TSNode self, uint32_t child_index) {
|
||||
TSNode result = self;
|
||||
bool did_descend = true;
|
||||
const char *inherited_field_name = NULL;
|
||||
|
||||
while (did_descend) {
|
||||
did_descend = false;
|
||||
|
||||
TSNode child;
|
||||
uint32_t index = 0;
|
||||
NodeChildIterator iterator = ts_node_iterate_children(&result);
|
||||
while (ts_node_child_iterator_next(&iterator, &child)) {
|
||||
if (ts_node__is_relevant(child, true)) {
|
||||
if (index == child_index) {
|
||||
const char *field_name = ts_node__field_name_from_language(result, iterator.structural_child_index - 1);
|
||||
if (field_name) return field_name;
|
||||
return inherited_field_name;
|
||||
}
|
||||
index++;
|
||||
} else {
|
||||
uint32_t grandchild_index = child_index - index;
|
||||
uint32_t grandchild_count = ts_node__relevant_child_count(child, true);
|
||||
if (grandchild_index < grandchild_count) {
|
||||
const char *field_name = ts_node__field_name_from_language(result, iterator.structural_child_index - 1);
|
||||
if (field_name) inherited_field_name = field_name;
|
||||
|
||||
did_descend = true;
|
||||
result = child;
|
||||
child_index = grandchild_index;
|
||||
break;
|
||||
}
|
||||
index += grandchild_count;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
TSNode ts_node_child_by_field_name(
|
||||
TSNode self,
|
||||
const char *name,
|
||||
uint32_t name_length
|
||||
) {
|
||||
TSFieldId field_id = ts_language_field_id_for_name(
|
||||
self.tree->language,
|
||||
name,
|
||||
name_length
|
||||
);
|
||||
return ts_node_child_by_field_id(self, field_id);
|
||||
}
|
||||
|
||||
uint32_t ts_node_child_count(TSNode self) {
|
||||
Subtree tree = ts_node__subtree(self);
|
||||
if (ts_subtree_child_count(tree) > 0) {
|
||||
return tree.ptr->visible_child_count;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t ts_node_named_child_count(TSNode self) {
|
||||
Subtree tree = ts_node__subtree(self);
|
||||
if (ts_subtree_child_count(tree) > 0) {
|
||||
return tree.ptr->named_child_count;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
TSNode ts_node_next_sibling(TSNode self) {
|
||||
return ts_node__next_sibling(self, true);
|
||||
}
|
||||
|
||||
TSNode ts_node_next_named_sibling(TSNode self) {
|
||||
return ts_node__next_sibling(self, false);
|
||||
}
|
||||
|
||||
TSNode ts_node_prev_sibling(TSNode self) {
|
||||
return ts_node__prev_sibling(self, true);
|
||||
}
|
||||
|
||||
TSNode ts_node_prev_named_sibling(TSNode self) {
|
||||
return ts_node__prev_sibling(self, false);
|
||||
}
|
||||
|
||||
TSNode ts_node_first_child_for_byte(TSNode self, uint32_t byte) {
|
||||
return ts_node__first_child_for_byte(self, byte, true);
|
||||
}
|
||||
|
||||
TSNode ts_node_first_named_child_for_byte(TSNode self, uint32_t byte) {
|
||||
return ts_node__first_child_for_byte(self, byte, false);
|
||||
}
|
||||
|
||||
TSNode ts_node_descendant_for_byte_range(
|
||||
TSNode self,
|
||||
uint32_t start,
|
||||
uint32_t end
|
||||
) {
|
||||
return ts_node__descendant_for_byte_range(self, start, end, true);
|
||||
}
|
||||
|
||||
TSNode ts_node_named_descendant_for_byte_range(
|
||||
TSNode self,
|
||||
uint32_t start,
|
||||
uint32_t end
|
||||
) {
|
||||
return ts_node__descendant_for_byte_range(self, start, end, false);
|
||||
}
|
||||
|
||||
TSNode ts_node_descendant_for_point_range(
|
||||
TSNode self,
|
||||
TSPoint start,
|
||||
TSPoint end
|
||||
) {
|
||||
return ts_node__descendant_for_point_range(self, start, end, true);
|
||||
}
|
||||
|
||||
TSNode ts_node_named_descendant_for_point_range(
|
||||
TSNode self,
|
||||
TSPoint start,
|
||||
TSPoint end
|
||||
) {
|
||||
return ts_node__descendant_for_point_range(self, start, end, false);
|
||||
}
|
||||
|
||||
void ts_node_edit(TSNode *self, const TSInputEdit *edit) {
|
||||
uint32_t start_byte = ts_node_start_byte(*self);
|
||||
TSPoint start_point = ts_node_start_point(*self);
|
||||
|
||||
if (start_byte >= edit->old_end_byte) {
|
||||
start_byte = edit->new_end_byte + (start_byte - edit->old_end_byte);
|
||||
start_point = point_add(edit->new_end_point, point_sub(start_point, edit->old_end_point));
|
||||
} else if (start_byte > edit->start_byte) {
|
||||
start_byte = edit->new_end_byte;
|
||||
start_point = edit->new_end_point;
|
||||
}
|
||||
|
||||
self->context[0] = start_byte;
|
||||
self->context[1] = start_point.row;
|
||||
self->context[2] = start_point.column;
|
||||
}
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,265 +0,0 @@
|
|||
#ifndef TREE_SITTER_PARSER_H_
|
||||
#define TREE_SITTER_PARSER_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define ts_builtin_sym_error ((TSSymbol)-1)
|
||||
#define ts_builtin_sym_end 0
|
||||
#define TREE_SITTER_SERIALIZATION_BUFFER_SIZE 1024
|
||||
|
||||
#ifndef TREE_SITTER_API_H_
|
||||
typedef uint16_t TSStateId;
|
||||
typedef uint16_t TSSymbol;
|
||||
typedef uint16_t TSFieldId;
|
||||
typedef struct TSLanguage TSLanguage;
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
TSFieldId field_id;
|
||||
uint8_t child_index;
|
||||
bool inherited;
|
||||
} TSFieldMapEntry;
|
||||
|
||||
typedef struct {
|
||||
uint16_t index;
|
||||
uint16_t length;
|
||||
} TSFieldMapSlice;
|
||||
|
||||
typedef struct {
|
||||
bool visible;
|
||||
bool named;
|
||||
bool supertype;
|
||||
} TSSymbolMetadata;
|
||||
|
||||
typedef struct TSLexer TSLexer;
|
||||
|
||||
struct TSLexer {
|
||||
int32_t lookahead;
|
||||
TSSymbol result_symbol;
|
||||
void (*advance)(TSLexer *, bool);
|
||||
void (*mark_end)(TSLexer *);
|
||||
uint32_t (*get_column)(TSLexer *);
|
||||
bool (*is_at_included_range_start)(const TSLexer *);
|
||||
bool (*eof)(const TSLexer *);
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
TSParseActionTypeShift,
|
||||
TSParseActionTypeReduce,
|
||||
TSParseActionTypeAccept,
|
||||
TSParseActionTypeRecover,
|
||||
} TSParseActionType;
|
||||
|
||||
typedef union {
|
||||
struct {
|
||||
uint8_t type;
|
||||
TSStateId state;
|
||||
bool extra;
|
||||
bool repetition;
|
||||
} shift;
|
||||
struct {
|
||||
uint8_t type;
|
||||
uint8_t child_count;
|
||||
TSSymbol symbol;
|
||||
int16_t dynamic_precedence;
|
||||
uint16_t production_id;
|
||||
} reduce;
|
||||
uint8_t type;
|
||||
} TSParseAction;
|
||||
|
||||
typedef struct {
|
||||
uint16_t lex_state;
|
||||
uint16_t external_lex_state;
|
||||
} TSLexMode;
|
||||
|
||||
typedef union {
|
||||
TSParseAction action;
|
||||
struct {
|
||||
uint8_t count;
|
||||
bool reusable;
|
||||
} entry;
|
||||
} TSParseActionEntry;
|
||||
|
||||
typedef struct {
|
||||
int32_t start;
|
||||
int32_t end;
|
||||
} TSCharacterRange;
|
||||
|
||||
struct TSLanguage {
|
||||
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 TSParseActionEntry *parse_actions;
|
||||
const char * const *symbol_names;
|
||||
const char * const *field_names;
|
||||
const TSFieldMapSlice *field_map_slices;
|
||||
const TSFieldMapEntry *field_map_entries;
|
||||
const TSSymbolMetadata *symbol_metadata;
|
||||
const TSSymbol *public_symbol_map;
|
||||
const uint16_t *alias_map;
|
||||
const TSSymbol *alias_sequences;
|
||||
const TSLexMode *lex_modes;
|
||||
bool (*lex_fn)(TSLexer *, TSStateId);
|
||||
bool (*keyword_lex_fn)(TSLexer *, TSStateId);
|
||||
TSSymbol keyword_capture_token;
|
||||
struct {
|
||||
const bool *states;
|
||||
const TSSymbol *symbol_map;
|
||||
void *(*create)(void);
|
||||
void (*destroy)(void *);
|
||||
bool (*scan)(void *, TSLexer *, const bool *symbol_whitelist);
|
||||
unsigned (*serialize)(void *, char *);
|
||||
void (*deserialize)(void *, const char *, unsigned);
|
||||
} external_scanner;
|
||||
const TSStateId *primary_state_ids;
|
||||
};
|
||||
|
||||
static inline bool set_contains(TSCharacterRange *ranges, uint32_t len, int32_t lookahead) {
|
||||
uint32_t index = 0;
|
||||
uint32_t size = len - index;
|
||||
while (size > 1) {
|
||||
uint32_t half_size = size / 2;
|
||||
uint32_t mid_index = index + half_size;
|
||||
TSCharacterRange *range = &ranges[mid_index];
|
||||
if (lookahead >= range->start && lookahead <= range->end) {
|
||||
return true;
|
||||
} else if (lookahead > range->end) {
|
||||
index = mid_index;
|
||||
}
|
||||
size -= half_size;
|
||||
}
|
||||
TSCharacterRange *range = &ranges[index];
|
||||
return (lookahead >= range->start && lookahead <= range->end);
|
||||
}
|
||||
|
||||
/*
|
||||
* Lexer Macros
|
||||
*/
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define UNUSED __pragma(warning(suppress : 4101))
|
||||
#else
|
||||
#define UNUSED __attribute__((unused))
|
||||
#endif
|
||||
|
||||
#define START_LEXER() \
|
||||
bool result = false; \
|
||||
bool skip = false; \
|
||||
UNUSED \
|
||||
bool eof = false; \
|
||||
int32_t lookahead; \
|
||||
goto start; \
|
||||
next_state: \
|
||||
lexer->advance(lexer, skip); \
|
||||
start: \
|
||||
skip = false; \
|
||||
lookahead = lexer->lookahead;
|
||||
|
||||
#define ADVANCE(state_value) \
|
||||
{ \
|
||||
state = state_value; \
|
||||
goto next_state; \
|
||||
}
|
||||
|
||||
#define ADVANCE_MAP(...) \
|
||||
{ \
|
||||
static const uint16_t map[] = { __VA_ARGS__ }; \
|
||||
for (uint32_t i = 0; i < sizeof(map) / sizeof(map[0]); i += 2) { \
|
||||
if (map[i] == lookahead) { \
|
||||
state = map[i + 1]; \
|
||||
goto next_state; \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
#define SKIP(state_value) \
|
||||
{ \
|
||||
skip = true; \
|
||||
state = state_value; \
|
||||
goto next_state; \
|
||||
}
|
||||
|
||||
#define ACCEPT_TOKEN(symbol_value) \
|
||||
result = true; \
|
||||
lexer->result_symbol = symbol_value; \
|
||||
lexer->mark_end(lexer);
|
||||
|
||||
#define END_STATE() return result;
|
||||
|
||||
/*
|
||||
* Parse Table Macros
|
||||
*/
|
||||
|
||||
#define SMALL_STATE(id) ((id) - LARGE_STATE_COUNT)
|
||||
|
||||
#define STATE(id) id
|
||||
|
||||
#define ACTIONS(id) id
|
||||
|
||||
#define SHIFT(state_value) \
|
||||
{{ \
|
||||
.shift = { \
|
||||
.type = TSParseActionTypeShift, \
|
||||
.state = (state_value) \
|
||||
} \
|
||||
}}
|
||||
|
||||
#define SHIFT_REPEAT(state_value) \
|
||||
{{ \
|
||||
.shift = { \
|
||||
.type = TSParseActionTypeShift, \
|
||||
.state = (state_value), \
|
||||
.repetition = true \
|
||||
} \
|
||||
}}
|
||||
|
||||
#define SHIFT_EXTRA() \
|
||||
{{ \
|
||||
.shift = { \
|
||||
.type = TSParseActionTypeShift, \
|
||||
.extra = true \
|
||||
} \
|
||||
}}
|
||||
|
||||
#define REDUCE(symbol_name, children, precedence, prod_id) \
|
||||
{{ \
|
||||
.reduce = { \
|
||||
.type = TSParseActionTypeReduce, \
|
||||
.symbol = symbol_name, \
|
||||
.child_count = children, \
|
||||
.dynamic_precedence = precedence, \
|
||||
.production_id = prod_id \
|
||||
}, \
|
||||
}}
|
||||
|
||||
#define RECOVER() \
|
||||
{{ \
|
||||
.type = TSParseActionTypeRecover \
|
||||
}}
|
||||
|
||||
#define ACCEPT_INPUT() \
|
||||
{{ \
|
||||
.type = TSParseActionTypeAccept \
|
||||
}}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // TREE_SITTER_PARSER_H_
|
||||
|
|
@ -1,62 +0,0 @@
|
|||
#ifndef TREE_SITTER_POINT_H_
|
||||
#define TREE_SITTER_POINT_H_
|
||||
|
||||
#include "api.h"
|
||||
|
||||
#define POINT_ZERO ((TSPoint) {0, 0})
|
||||
#define POINT_MAX ((TSPoint) {UINT32_MAX, UINT32_MAX})
|
||||
|
||||
static inline TSPoint point__new(unsigned row, unsigned column) {
|
||||
TSPoint result = {row, column};
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline TSPoint point_add(TSPoint a, TSPoint b) {
|
||||
if (b.row > 0)
|
||||
return point__new(a.row + b.row, b.column);
|
||||
else
|
||||
return point__new(a.row, a.column + b.column);
|
||||
}
|
||||
|
||||
static inline TSPoint point_sub(TSPoint a, TSPoint b) {
|
||||
if (a.row > b.row)
|
||||
return point__new(a.row - b.row, a.column);
|
||||
else
|
||||
return point__new(0, a.column - b.column);
|
||||
}
|
||||
|
||||
static inline bool point_lte(TSPoint a, TSPoint b) {
|
||||
return (a.row < b.row) || (a.row == b.row && a.column <= b.column);
|
||||
}
|
||||
|
||||
static inline bool point_lt(TSPoint a, TSPoint b) {
|
||||
return (a.row < b.row) || (a.row == b.row && a.column < b.column);
|
||||
}
|
||||
|
||||
static inline bool point_gt(TSPoint a, TSPoint b) {
|
||||
return (a.row > b.row) || (a.row == b.row && a.column > b.column);
|
||||
}
|
||||
|
||||
static inline bool point_gte(TSPoint a, TSPoint b) {
|
||||
return (a.row > b.row) || (a.row == b.row && a.column >= b.column);
|
||||
}
|
||||
|
||||
static inline bool point_eq(TSPoint a, TSPoint b) {
|
||||
return a.row == b.row && a.column == b.column;
|
||||
}
|
||||
|
||||
static inline TSPoint point_min(TSPoint a, TSPoint b) {
|
||||
if (a.row < b.row || (a.row == b.row && a.column < b.column))
|
||||
return a;
|
||||
else
|
||||
return b;
|
||||
}
|
||||
|
||||
static inline TSPoint point_max(TSPoint a, TSPoint b) {
|
||||
if (a.row > b.row || (a.row == b.row && a.column > b.column))
|
||||
return a;
|
||||
else
|
||||
return b;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
#ifndef TREE_SITTER_REDUCE_ACTION_H_
|
||||
#define TREE_SITTER_REDUCE_ACTION_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "./array.h"
|
||||
#include "api.h"
|
||||
|
||||
typedef struct {
|
||||
uint32_t count;
|
||||
TSSymbol symbol;
|
||||
int dynamic_precedence;
|
||||
unsigned short production_id;
|
||||
} ReduceAction;
|
||||
|
||||
typedef Array(ReduceAction) ReduceActionSet;
|
||||
|
||||
static inline void ts_reduce_action_set_add(ReduceActionSet *self,
|
||||
ReduceAction new_action) {
|
||||
for (uint32_t i = 0; i < self->size; i++) {
|
||||
ReduceAction action = self->contents[i];
|
||||
if (action.symbol == new_action.symbol && action.count == new_action.count)
|
||||
return;
|
||||
}
|
||||
array_push(self, new_action);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // TREE_SITTER_REDUCE_ACTION_H_
|
||||
|
|
@ -1,95 +0,0 @@
|
|||
#include "./subtree.h"
|
||||
|
||||
typedef struct {
|
||||
Subtree tree;
|
||||
uint32_t child_index;
|
||||
uint32_t byte_offset;
|
||||
} StackEntry;
|
||||
|
||||
typedef struct {
|
||||
Array(StackEntry) stack;
|
||||
Subtree last_external_token;
|
||||
} ReusableNode;
|
||||
|
||||
static inline ReusableNode reusable_node_new(void) {
|
||||
return (ReusableNode) {array_new(), NULL_SUBTREE};
|
||||
}
|
||||
|
||||
static inline void reusable_node_clear(ReusableNode *self) {
|
||||
array_clear(&self->stack);
|
||||
self->last_external_token = NULL_SUBTREE;
|
||||
}
|
||||
|
||||
static inline Subtree reusable_node_tree(ReusableNode *self) {
|
||||
return self->stack.size > 0
|
||||
? self->stack.contents[self->stack.size - 1].tree
|
||||
: NULL_SUBTREE;
|
||||
}
|
||||
|
||||
static inline uint32_t reusable_node_byte_offset(ReusableNode *self) {
|
||||
return self->stack.size > 0
|
||||
? self->stack.contents[self->stack.size - 1].byte_offset
|
||||
: UINT32_MAX;
|
||||
}
|
||||
|
||||
static inline void reusable_node_delete(ReusableNode *self) {
|
||||
array_delete(&self->stack);
|
||||
}
|
||||
|
||||
static inline void reusable_node_advance(ReusableNode *self) {
|
||||
StackEntry last_entry = *array_back(&self->stack);
|
||||
uint32_t byte_offset = last_entry.byte_offset + ts_subtree_total_bytes(last_entry.tree);
|
||||
if (ts_subtree_has_external_tokens(last_entry.tree)) {
|
||||
self->last_external_token = ts_subtree_last_external_token(last_entry.tree);
|
||||
}
|
||||
|
||||
Subtree tree;
|
||||
uint32_t next_index;
|
||||
do {
|
||||
StackEntry popped_entry = array_pop(&self->stack);
|
||||
next_index = popped_entry.child_index + 1;
|
||||
if (self->stack.size == 0) return;
|
||||
tree = array_back(&self->stack)->tree;
|
||||
} while (ts_subtree_child_count(tree) <= next_index);
|
||||
|
||||
array_push(&self->stack, ((StackEntry) {
|
||||
.tree = ts_subtree_children(tree)[next_index],
|
||||
.child_index = next_index,
|
||||
.byte_offset = byte_offset,
|
||||
}));
|
||||
}
|
||||
|
||||
static inline bool reusable_node_descend(ReusableNode *self) {
|
||||
StackEntry last_entry = *array_back(&self->stack);
|
||||
if (ts_subtree_child_count(last_entry.tree) > 0) {
|
||||
array_push(&self->stack, ((StackEntry) {
|
||||
.tree = ts_subtree_children(last_entry.tree)[0],
|
||||
.child_index = 0,
|
||||
.byte_offset = last_entry.byte_offset,
|
||||
}));
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void reusable_node_advance_past_leaf(ReusableNode *self) {
|
||||
while (reusable_node_descend(self)) {}
|
||||
reusable_node_advance(self);
|
||||
}
|
||||
|
||||
static inline void reusable_node_reset(ReusableNode *self, Subtree tree) {
|
||||
reusable_node_clear(self);
|
||||
array_push(&self->stack, ((StackEntry) {
|
||||
.tree = tree,
|
||||
.child_index = 0,
|
||||
.byte_offset = 0,
|
||||
}));
|
||||
|
||||
// Never reuse the root node, because it has a non-standard internal structure
|
||||
// due to transformations that are applied when it is accepted: adding the EOF
|
||||
// child and any extra children.
|
||||
if (!reusable_node_descend(self)) {
|
||||
reusable_node_clear(self);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,899 +0,0 @@
|
|||
|
||||
#include "./language.h"
|
||||
#include "./subtree.h"
|
||||
#include "./array.h"
|
||||
#include "./stack.h"
|
||||
#include "./length.h"
|
||||
#include <assert.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define MAX_LINK_COUNT 8
|
||||
#define MAX_NODE_POOL_SIZE 50
|
||||
#define MAX_ITERATOR_COUNT 64
|
||||
|
||||
#if defined _WIN32 && !defined __GNUC__
|
||||
#define forceinline __forceinline
|
||||
#else
|
||||
#define forceinline static inline __attribute__((always_inline))
|
||||
#endif
|
||||
|
||||
typedef struct StackNode StackNode;
|
||||
|
||||
typedef struct {
|
||||
StackNode *node;
|
||||
Subtree subtree;
|
||||
bool is_pending;
|
||||
} StackLink;
|
||||
|
||||
struct StackNode {
|
||||
TSStateId state;
|
||||
Length position;
|
||||
StackLink links[MAX_LINK_COUNT];
|
||||
short unsigned int link_count;
|
||||
uint32_t ref_count;
|
||||
unsigned error_cost;
|
||||
unsigned node_count;
|
||||
int dynamic_precedence;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
StackNode *node;
|
||||
SubtreeArray subtrees;
|
||||
uint32_t subtree_count;
|
||||
bool is_pending;
|
||||
} StackIterator;
|
||||
|
||||
typedef Array(StackNode *) StackNodeArray;
|
||||
|
||||
typedef enum {
|
||||
StackStatusActive,
|
||||
StackStatusPaused,
|
||||
StackStatusHalted,
|
||||
} StackStatus;
|
||||
|
||||
typedef struct {
|
||||
StackNode *node;
|
||||
StackSummary *summary;
|
||||
unsigned node_count_at_last_error;
|
||||
Subtree last_external_token;
|
||||
Subtree lookahead_when_paused;
|
||||
StackStatus status;
|
||||
} StackHead;
|
||||
|
||||
struct Stack {
|
||||
Array(StackHead) heads;
|
||||
StackSliceArray slices;
|
||||
Array(StackIterator) iterators;
|
||||
StackNodeArray node_pool;
|
||||
StackNode *base_node;
|
||||
SubtreePool *subtree_pool;
|
||||
};
|
||||
|
||||
typedef unsigned StackAction;
|
||||
enum {
|
||||
StackActionNone,
|
||||
StackActionStop = 1,
|
||||
StackActionPop = 2,
|
||||
};
|
||||
|
||||
typedef StackAction (*StackCallback)(void *, const StackIterator *);
|
||||
|
||||
static void stack_node_retain(StackNode *self) {
|
||||
if (!self)
|
||||
return;
|
||||
assert(self->ref_count > 0);
|
||||
self->ref_count++;
|
||||
assert(self->ref_count != 0);
|
||||
}
|
||||
|
||||
static void stack_node_release(
|
||||
StackNode *self,
|
||||
StackNodeArray *pool,
|
||||
SubtreePool *subtree_pool
|
||||
) {
|
||||
recur:
|
||||
assert(self->ref_count != 0);
|
||||
self->ref_count--;
|
||||
if (self->ref_count > 0) return;
|
||||
|
||||
StackNode *first_predecessor = NULL;
|
||||
if (self->link_count > 0) {
|
||||
for (unsigned i = self->link_count - 1; i > 0; i--) {
|
||||
StackLink link = self->links[i];
|
||||
if (link.subtree.ptr) ts_subtree_release(subtree_pool, link.subtree);
|
||||
stack_node_release(link.node, pool, subtree_pool);
|
||||
}
|
||||
StackLink link = self->links[0];
|
||||
if (link.subtree.ptr) ts_subtree_release(subtree_pool, link.subtree);
|
||||
first_predecessor = self->links[0].node;
|
||||
}
|
||||
|
||||
if (pool->size < MAX_NODE_POOL_SIZE) {
|
||||
array_push(pool, self);
|
||||
} else {
|
||||
free(self);
|
||||
}
|
||||
|
||||
if (first_predecessor) {
|
||||
self = first_predecessor;
|
||||
goto recur;
|
||||
}
|
||||
}
|
||||
|
||||
/// 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.
|
||||
static uint32_t stack__subtree_node_count(Subtree subtree) {
|
||||
uint32_t count = ts_subtree_visible_descendant_count(subtree);
|
||||
if (ts_subtree_visible(subtree)) count++;
|
||||
|
||||
// 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.
|
||||
if (ts_subtree_symbol(subtree) == ts_builtin_sym_error_repeat) count++;
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
static StackNode *stack_node_new(
|
||||
StackNode *previous_node,
|
||||
Subtree subtree,
|
||||
bool is_pending,
|
||||
TSStateId state,
|
||||
StackNodeArray *pool
|
||||
) {
|
||||
StackNode *node = pool->size > 0
|
||||
? array_pop(pool)
|
||||
: malloc(sizeof(StackNode));
|
||||
*node = (StackNode) {
|
||||
.ref_count = 1,
|
||||
.link_count = 0,
|
||||
.state = state
|
||||
};
|
||||
|
||||
if (previous_node) {
|
||||
node->link_count = 1;
|
||||
node->links[0] = (StackLink) {
|
||||
.node = previous_node,
|
||||
.subtree = subtree,
|
||||
.is_pending = is_pending,
|
||||
};
|
||||
|
||||
node->position = previous_node->position;
|
||||
node->error_cost = previous_node->error_cost;
|
||||
node->dynamic_precedence = previous_node->dynamic_precedence;
|
||||
node->node_count = previous_node->node_count;
|
||||
|
||||
if (subtree.ptr) {
|
||||
node->error_cost += ts_subtree_error_cost(subtree);
|
||||
node->position = length_add(node->position, ts_subtree_total_size(subtree));
|
||||
node->node_count += stack__subtree_node_count(subtree);
|
||||
node->dynamic_precedence += ts_subtree_dynamic_precedence(subtree);
|
||||
}
|
||||
} else {
|
||||
node->position = length_zero();
|
||||
node->error_cost = 0;
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
static bool stack__subtree_is_equivalent(Subtree left, Subtree right) {
|
||||
if (left.ptr == right.ptr) return true;
|
||||
if (!left.ptr || !right.ptr) return false;
|
||||
|
||||
// Symbols must match
|
||||
if (ts_subtree_symbol(left) != ts_subtree_symbol(right)) return false;
|
||||
|
||||
// If both have errors, don't bother keeping both.
|
||||
if (ts_subtree_error_cost(left) > 0 && ts_subtree_error_cost(right) > 0) return true;
|
||||
|
||||
return (
|
||||
ts_subtree_padding(left).bytes == ts_subtree_padding(right).bytes &&
|
||||
ts_subtree_size(left).bytes == ts_subtree_size(right).bytes &&
|
||||
ts_subtree_child_count(left) == ts_subtree_child_count(right) &&
|
||||
ts_subtree_extra(left) == ts_subtree_extra(right) &&
|
||||
ts_subtree_external_scanner_state_eq(left, right)
|
||||
);
|
||||
}
|
||||
|
||||
static void stack_node_add_link(
|
||||
StackNode *self,
|
||||
StackLink link,
|
||||
SubtreePool *subtree_pool
|
||||
) {
|
||||
if (link.node == self) return;
|
||||
|
||||
for (int i = 0; i < self->link_count; i++) {
|
||||
StackLink *existing_link = &self->links[i];
|
||||
if (stack__subtree_is_equivalent(existing_link->subtree, link.subtree)) {
|
||||
// In general, we preserve ambiguities until they are removed from the stack
|
||||
// during a pop operation where multiple paths lead to the same node. But in
|
||||
// the special case where two links directly connect the same pair of nodes,
|
||||
// we can safely remove the ambiguity ahead of time without changing behavior.
|
||||
if (existing_link->node == link.node) {
|
||||
if (
|
||||
ts_subtree_dynamic_precedence(link.subtree) >
|
||||
ts_subtree_dynamic_precedence(existing_link->subtree)
|
||||
) {
|
||||
ts_subtree_retain(link.subtree);
|
||||
ts_subtree_release(subtree_pool, existing_link->subtree);
|
||||
existing_link->subtree = link.subtree;
|
||||
self->dynamic_precedence =
|
||||
link.node->dynamic_precedence + ts_subtree_dynamic_precedence(link.subtree);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// If the previous nodes are mergeable, merge them recursively.
|
||||
if (
|
||||
existing_link->node->state == link.node->state &&
|
||||
existing_link->node->position.bytes == link.node->position.bytes &&
|
||||
existing_link->node->error_cost == link.node->error_cost
|
||||
) {
|
||||
for (int j = 0; j < link.node->link_count; j++) {
|
||||
stack_node_add_link(existing_link->node, link.node->links[j], subtree_pool);
|
||||
}
|
||||
int32_t dynamic_precedence = link.node->dynamic_precedence;
|
||||
if (link.subtree.ptr) {
|
||||
dynamic_precedence += ts_subtree_dynamic_precedence(link.subtree);
|
||||
}
|
||||
if (dynamic_precedence > self->dynamic_precedence) {
|
||||
self->dynamic_precedence = dynamic_precedence;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (self->link_count == MAX_LINK_COUNT) return;
|
||||
|
||||
stack_node_retain(link.node);
|
||||
unsigned node_count = link.node->node_count;
|
||||
int dynamic_precedence = link.node->dynamic_precedence;
|
||||
self->links[self->link_count++] = link;
|
||||
|
||||
if (link.subtree.ptr) {
|
||||
ts_subtree_retain(link.subtree);
|
||||
node_count += stack__subtree_node_count(link.subtree);
|
||||
dynamic_precedence += ts_subtree_dynamic_precedence(link.subtree);
|
||||
}
|
||||
|
||||
if (node_count > self->node_count) self->node_count = node_count;
|
||||
if (dynamic_precedence > self->dynamic_precedence) self->dynamic_precedence = dynamic_precedence;
|
||||
}
|
||||
|
||||
static void stack_head_delete(
|
||||
StackHead *self,
|
||||
StackNodeArray *pool,
|
||||
SubtreePool *subtree_pool
|
||||
) {
|
||||
if (self->node) {
|
||||
if (self->last_external_token.ptr) {
|
||||
ts_subtree_release(subtree_pool, self->last_external_token);
|
||||
}
|
||||
if (self->lookahead_when_paused.ptr) {
|
||||
ts_subtree_release(subtree_pool, self->lookahead_when_paused);
|
||||
}
|
||||
if (self->summary) {
|
||||
array_delete(self->summary);
|
||||
free(self->summary);
|
||||
}
|
||||
stack_node_release(self->node, pool, subtree_pool);
|
||||
}
|
||||
}
|
||||
|
||||
static StackVersion ts_stack__add_version(
|
||||
Stack *self,
|
||||
StackVersion original_version,
|
||||
StackNode *node
|
||||
) {
|
||||
StackHead head = {
|
||||
.node = node,
|
||||
.node_count_at_last_error = self->heads.contents[original_version].node_count_at_last_error,
|
||||
.last_external_token = self->heads.contents[original_version].last_external_token,
|
||||
.status = StackStatusActive,
|
||||
.lookahead_when_paused = NULL_SUBTREE,
|
||||
};
|
||||
array_push(&self->heads, head);
|
||||
stack_node_retain(node);
|
||||
if (head.last_external_token.ptr) ts_subtree_retain(head.last_external_token);
|
||||
return (StackVersion)(self->heads.size - 1);
|
||||
}
|
||||
|
||||
static void ts_stack__add_slice(
|
||||
Stack *self,
|
||||
StackVersion original_version,
|
||||
StackNode *node,
|
||||
SubtreeArray *subtrees
|
||||
) {
|
||||
for (uint32_t i = self->slices.size - 1; i + 1 > 0; i--) {
|
||||
StackVersion version = self->slices.contents[i].version;
|
||||
if (self->heads.contents[version].node == node) {
|
||||
StackSlice slice = {*subtrees, version};
|
||||
array_insert(&self->slices, i + 1, slice);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
StackVersion version = ts_stack__add_version(self, original_version, node);
|
||||
StackSlice slice = { *subtrees, version };
|
||||
array_push(&self->slices, slice);
|
||||
}
|
||||
|
||||
static StackSliceArray stack__iter(
|
||||
Stack *self,
|
||||
StackVersion version,
|
||||
StackCallback callback,
|
||||
void *payload,
|
||||
int goal_subtree_count
|
||||
) {
|
||||
array_clear(&self->slices);
|
||||
array_clear(&self->iterators);
|
||||
|
||||
StackHead *head = array_get(&self->heads, version);
|
||||
StackIterator new_iterator = {
|
||||
.node = head->node,
|
||||
.subtrees = array_new(),
|
||||
.subtree_count = 0,
|
||||
.is_pending = true,
|
||||
};
|
||||
|
||||
bool include_subtrees = false;
|
||||
if (goal_subtree_count >= 0) {
|
||||
include_subtrees = true;
|
||||
array_reserve(&new_iterator.subtrees, (uint32_t)ts_subtree_alloc_size(goal_subtree_count) / sizeof(Subtree));
|
||||
}
|
||||
|
||||
array_push(&self->iterators, new_iterator);
|
||||
|
||||
while (self->iterators.size > 0) {
|
||||
for (uint32_t i = 0, size = self->iterators.size; i < size; i++) {
|
||||
StackIterator *iterator = &self->iterators.contents[i];
|
||||
StackNode *node = iterator->node;
|
||||
|
||||
StackAction action = callback(payload, iterator);
|
||||
bool should_pop = action & StackActionPop;
|
||||
bool should_stop = action & StackActionStop || node->link_count == 0;
|
||||
|
||||
if (should_pop) {
|
||||
SubtreeArray subtrees = iterator->subtrees;
|
||||
if (!should_stop) {
|
||||
ts_subtree_array_copy(subtrees, &subtrees);
|
||||
}
|
||||
ts_subtree_array_reverse(&subtrees);
|
||||
ts_stack__add_slice(
|
||||
self,
|
||||
version,
|
||||
node,
|
||||
&subtrees
|
||||
);
|
||||
}
|
||||
|
||||
if (should_stop) {
|
||||
if (!should_pop) {
|
||||
ts_subtree_array_delete(self->subtree_pool, &iterator->subtrees);
|
||||
}
|
||||
array_erase(&self->iterators, i);
|
||||
i--, size--;
|
||||
continue;
|
||||
}
|
||||
|
||||
for (uint32_t j = 1; j <= node->link_count; j++) {
|
||||
StackIterator *next_iterator;
|
||||
StackLink link;
|
||||
if (j == node->link_count) {
|
||||
link = node->links[0];
|
||||
next_iterator = &self->iterators.contents[i];
|
||||
} else {
|
||||
if (self->iterators.size >= MAX_ITERATOR_COUNT) continue;
|
||||
link = node->links[j];
|
||||
StackIterator current_iterator = self->iterators.contents[i];
|
||||
array_push(&self->iterators, current_iterator);
|
||||
next_iterator = array_back(&self->iterators);
|
||||
ts_subtree_array_copy(next_iterator->subtrees, &next_iterator->subtrees);
|
||||
}
|
||||
|
||||
next_iterator->node = link.node;
|
||||
if (link.subtree.ptr) {
|
||||
if (include_subtrees) {
|
||||
array_push(&next_iterator->subtrees, link.subtree);
|
||||
ts_subtree_retain(link.subtree);
|
||||
}
|
||||
|
||||
if (!ts_subtree_extra(link.subtree)) {
|
||||
next_iterator->subtree_count++;
|
||||
if (!link.is_pending) {
|
||||
next_iterator->is_pending = false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
next_iterator->subtree_count++;
|
||||
next_iterator->is_pending = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return self->slices;
|
||||
}
|
||||
|
||||
Stack *ts_stack_new(SubtreePool *subtree_pool) {
|
||||
Stack *self = calloc(1, sizeof(Stack));
|
||||
|
||||
array_init(&self->heads);
|
||||
array_init(&self->slices);
|
||||
array_init(&self->iterators);
|
||||
array_init(&self->node_pool);
|
||||
array_reserve(&self->heads, 4);
|
||||
array_reserve(&self->slices, 4);
|
||||
array_reserve(&self->iterators, 4);
|
||||
array_reserve(&self->node_pool, MAX_NODE_POOL_SIZE);
|
||||
|
||||
self->subtree_pool = subtree_pool;
|
||||
self->base_node = stack_node_new(NULL, NULL_SUBTREE, false, 1, &self->node_pool);
|
||||
ts_stack_clear(self);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
void ts_stack_delete(Stack *self) {
|
||||
if (self->slices.contents)
|
||||
array_delete(&self->slices);
|
||||
if (self->iterators.contents)
|
||||
array_delete(&self->iterators);
|
||||
stack_node_release(self->base_node, &self->node_pool, self->subtree_pool);
|
||||
for (uint32_t i = 0; i < self->heads.size; i++) {
|
||||
stack_head_delete(&self->heads.contents[i], &self->node_pool, self->subtree_pool);
|
||||
}
|
||||
array_clear(&self->heads);
|
||||
if (self->node_pool.contents) {
|
||||
for (uint32_t i = 0; i < self->node_pool.size; i++)
|
||||
free(self->node_pool.contents[i]);
|
||||
array_delete(&self->node_pool);
|
||||
}
|
||||
array_delete(&self->heads);
|
||||
free(self);
|
||||
}
|
||||
|
||||
uint32_t ts_stack_version_count(const Stack *self) {
|
||||
return self->heads.size;
|
||||
}
|
||||
|
||||
TSStateId ts_stack_state(const Stack *self, StackVersion version) {
|
||||
return array_get(&self->heads, version)->node->state;
|
||||
}
|
||||
|
||||
Length ts_stack_position(const Stack *self, StackVersion version) {
|
||||
return array_get(&self->heads, version)->node->position;
|
||||
}
|
||||
|
||||
Subtree ts_stack_last_external_token(const Stack *self, StackVersion version) {
|
||||
return array_get(&self->heads, version)->last_external_token;
|
||||
}
|
||||
|
||||
void ts_stack_set_last_external_token(Stack *self, StackVersion version, Subtree token) {
|
||||
StackHead *head = array_get(&self->heads, version);
|
||||
if (token.ptr) ts_subtree_retain(token);
|
||||
if (head->last_external_token.ptr) ts_subtree_release(self->subtree_pool, head->last_external_token);
|
||||
head->last_external_token = token;
|
||||
}
|
||||
|
||||
unsigned ts_stack_error_cost(const Stack *self, StackVersion version) {
|
||||
StackHead *head = array_get(&self->heads, version);
|
||||
unsigned result = head->node->error_cost;
|
||||
if (
|
||||
head->status == StackStatusPaused ||
|
||||
(head->node->state == ERROR_STATE && !head->node->links[0].subtree.ptr)) {
|
||||
result += ERROR_COST_PER_RECOVERY;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
unsigned ts_stack_node_count_since_error(const Stack *self, StackVersion version) {
|
||||
StackHead *head = array_get(&self->heads, version);
|
||||
if (head->node->node_count < head->node_count_at_last_error) {
|
||||
head->node_count_at_last_error = head->node->node_count;
|
||||
}
|
||||
return head->node->node_count - head->node_count_at_last_error;
|
||||
}
|
||||
|
||||
void ts_stack_push(
|
||||
Stack *self,
|
||||
StackVersion version,
|
||||
Subtree subtree,
|
||||
bool pending,
|
||||
TSStateId state
|
||||
) {
|
||||
StackHead *head = array_get(&self->heads, version);
|
||||
StackNode *new_node = stack_node_new(head->node, subtree, pending, state, &self->node_pool);
|
||||
if (!subtree.ptr) head->node_count_at_last_error = new_node->node_count;
|
||||
head->node = new_node;
|
||||
}
|
||||
|
||||
forceinline StackAction pop_count_callback(void *payload, const StackIterator *iterator) {
|
||||
unsigned *goal_subtree_count = payload;
|
||||
if (iterator->subtree_count == *goal_subtree_count) {
|
||||
return StackActionPop | StackActionStop;
|
||||
} else {
|
||||
return StackActionNone;
|
||||
}
|
||||
}
|
||||
|
||||
StackSliceArray ts_stack_pop_count(Stack *self, StackVersion version, uint32_t count) {
|
||||
return stack__iter(self, version, pop_count_callback, &count, (int)count);
|
||||
}
|
||||
|
||||
forceinline StackAction pop_pending_callback(void *payload, const StackIterator *iterator) {
|
||||
(void)payload;
|
||||
if (iterator->subtree_count >= 1) {
|
||||
if (iterator->is_pending) {
|
||||
return StackActionPop | StackActionStop;
|
||||
} else {
|
||||
return StackActionStop;
|
||||
}
|
||||
} else {
|
||||
return StackActionNone;
|
||||
}
|
||||
}
|
||||
|
||||
StackSliceArray ts_stack_pop_pending(Stack *self, StackVersion version) {
|
||||
StackSliceArray pop = stack__iter(self, version, pop_pending_callback, NULL, 0);
|
||||
if (pop.size > 0) {
|
||||
ts_stack_renumber_version(self, pop.contents[0].version, version);
|
||||
pop.contents[0].version = version;
|
||||
}
|
||||
return pop;
|
||||
}
|
||||
|
||||
forceinline StackAction pop_error_callback(void *payload, const StackIterator *iterator) {
|
||||
if (iterator->subtrees.size > 0) {
|
||||
bool *found_error = payload;
|
||||
if (!*found_error && ts_subtree_is_error(iterator->subtrees.contents[0])) {
|
||||
*found_error = true;
|
||||
return StackActionPop | StackActionStop;
|
||||
} else {
|
||||
return StackActionStop;
|
||||
}
|
||||
} else {
|
||||
return StackActionNone;
|
||||
}
|
||||
}
|
||||
|
||||
SubtreeArray ts_stack_pop_error(Stack *self, StackVersion version) {
|
||||
StackNode *node = array_get(&self->heads, version)->node;
|
||||
for (unsigned i = 0; i < node->link_count; i++) {
|
||||
if (node->links[i].subtree.ptr && ts_subtree_is_error(node->links[i].subtree)) {
|
||||
bool found_error = false;
|
||||
StackSliceArray pop = stack__iter(self, version, pop_error_callback, &found_error, 1);
|
||||
if (pop.size > 0) {
|
||||
assert(pop.size == 1);
|
||||
ts_stack_renumber_version(self, pop.contents[0].version, version);
|
||||
return pop.contents[0].subtrees;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return (SubtreeArray) {.size = 0};
|
||||
}
|
||||
|
||||
forceinline StackAction pop_all_callback(void *payload, const StackIterator *iterator) {
|
||||
(void)payload;
|
||||
return iterator->node->link_count == 0 ? StackActionPop : StackActionNone;
|
||||
}
|
||||
|
||||
StackSliceArray ts_stack_pop_all(Stack *self, StackVersion version) {
|
||||
return stack__iter(self, version, pop_all_callback, NULL, 0);
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
StackSummary *summary;
|
||||
unsigned max_depth;
|
||||
} SummarizeStackSession;
|
||||
|
||||
forceinline StackAction summarize_stack_callback(void *payload, const StackIterator *iterator) {
|
||||
SummarizeStackSession *session = payload;
|
||||
TSStateId state = iterator->node->state;
|
||||
unsigned depth = iterator->subtree_count;
|
||||
if (depth > session->max_depth) return StackActionStop;
|
||||
for (unsigned i = session->summary->size - 1; i + 1 > 0; i--) {
|
||||
StackSummaryEntry entry = session->summary->contents[i];
|
||||
if (entry.depth < depth) break;
|
||||
if (entry.depth == depth && entry.state == state) return StackActionNone;
|
||||
}
|
||||
array_push(session->summary, ((StackSummaryEntry) {
|
||||
.position = iterator->node->position,
|
||||
.depth = depth,
|
||||
.state = state,
|
||||
}));
|
||||
return StackActionNone;
|
||||
}
|
||||
|
||||
void ts_stack_record_summary(Stack *self, StackVersion version, unsigned max_depth) {
|
||||
SummarizeStackSession session = {
|
||||
.summary = malloc(sizeof(StackSummary)),
|
||||
.max_depth = max_depth
|
||||
};
|
||||
array_init(session.summary);
|
||||
stack__iter(self, version, summarize_stack_callback, &session, -1);
|
||||
StackHead *head = &self->heads.contents[version];
|
||||
if (head->summary) {
|
||||
array_delete(head->summary);
|
||||
free(head->summary);
|
||||
}
|
||||
head->summary = session.summary;
|
||||
}
|
||||
|
||||
StackSummary *ts_stack_get_summary(Stack *self, StackVersion version) {
|
||||
return array_get(&self->heads, version)->summary;
|
||||
}
|
||||
|
||||
int ts_stack_dynamic_precedence(Stack *self, StackVersion version) {
|
||||
return array_get(&self->heads, version)->node->dynamic_precedence;
|
||||
}
|
||||
|
||||
bool ts_stack_has_advanced_since_error(const Stack *self, StackVersion version) {
|
||||
const StackHead *head = array_get(&self->heads, version);
|
||||
const StackNode *node = head->node;
|
||||
if (node->error_cost == 0) return true;
|
||||
while (node) {
|
||||
if (node->link_count > 0) {
|
||||
Subtree subtree = node->links[0].subtree;
|
||||
if (subtree.ptr) {
|
||||
if (ts_subtree_total_bytes(subtree) > 0) {
|
||||
return true;
|
||||
} else if (
|
||||
node->node_count > head->node_count_at_last_error &&
|
||||
ts_subtree_error_cost(subtree) == 0
|
||||
) {
|
||||
node = node->links[0].node;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void ts_stack_remove_version(Stack *self, StackVersion version) {
|
||||
stack_head_delete(array_get(&self->heads, version), &self->node_pool, self->subtree_pool);
|
||||
array_erase(&self->heads, version);
|
||||
}
|
||||
|
||||
void ts_stack_renumber_version(Stack *self, StackVersion v1, StackVersion v2) {
|
||||
if (v1 == v2) return;
|
||||
assert(v2 < v1);
|
||||
assert((uint32_t)v1 < self->heads.size);
|
||||
StackHead *source_head = &self->heads.contents[v1];
|
||||
StackHead *target_head = &self->heads.contents[v2];
|
||||
if (target_head->summary && !source_head->summary) {
|
||||
source_head->summary = target_head->summary;
|
||||
target_head->summary = NULL;
|
||||
}
|
||||
stack_head_delete(target_head, &self->node_pool, self->subtree_pool);
|
||||
*target_head = *source_head;
|
||||
array_erase(&self->heads, v1);
|
||||
}
|
||||
|
||||
void ts_stack_swap_versions(Stack *self, StackVersion v1, StackVersion v2) {
|
||||
StackHead temporary_head = self->heads.contents[v1];
|
||||
self->heads.contents[v1] = self->heads.contents[v2];
|
||||
self->heads.contents[v2] = temporary_head;
|
||||
}
|
||||
|
||||
StackVersion ts_stack_copy_version(Stack *self, StackVersion version) {
|
||||
assert(version < self->heads.size);
|
||||
array_push(&self->heads, self->heads.contents[version]);
|
||||
StackHead *head = array_back(&self->heads);
|
||||
stack_node_retain(head->node);
|
||||
if (head->last_external_token.ptr) ts_subtree_retain(head->last_external_token);
|
||||
head->summary = NULL;
|
||||
return self->heads.size - 1;
|
||||
}
|
||||
|
||||
bool ts_stack_merge(Stack *self, StackVersion version1, StackVersion version2) {
|
||||
if (!ts_stack_can_merge(self, version1, version2)) return false;
|
||||
StackHead *head1 = &self->heads.contents[version1];
|
||||
StackHead *head2 = &self->heads.contents[version2];
|
||||
for (uint32_t i = 0; i < head2->node->link_count; i++) {
|
||||
stack_node_add_link(head1->node, head2->node->links[i], self->subtree_pool);
|
||||
}
|
||||
if (head1->node->state == ERROR_STATE) {
|
||||
head1->node_count_at_last_error = head1->node->node_count;
|
||||
}
|
||||
ts_stack_remove_version(self, version2);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ts_stack_can_merge(Stack *self, StackVersion version1, StackVersion version2) {
|
||||
StackHead *head1 = &self->heads.contents[version1];
|
||||
StackHead *head2 = &self->heads.contents[version2];
|
||||
return
|
||||
head1->status == StackStatusActive &&
|
||||
head2->status == StackStatusActive &&
|
||||
head1->node->state == head2->node->state &&
|
||||
head1->node->position.bytes == head2->node->position.bytes &&
|
||||
head1->node->error_cost == head2->node->error_cost &&
|
||||
ts_subtree_external_scanner_state_eq(head1->last_external_token, head2->last_external_token);
|
||||
}
|
||||
|
||||
void ts_stack_halt(Stack *self, StackVersion version) {
|
||||
array_get(&self->heads, version)->status = StackStatusHalted;
|
||||
}
|
||||
|
||||
void ts_stack_pause(Stack *self, StackVersion version, Subtree lookahead) {
|
||||
StackHead *head = array_get(&self->heads, version);
|
||||
head->status = StackStatusPaused;
|
||||
head->lookahead_when_paused = lookahead;
|
||||
head->node_count_at_last_error = head->node->node_count;
|
||||
}
|
||||
|
||||
bool ts_stack_is_active(const Stack *self, StackVersion version) {
|
||||
return array_get(&self->heads, version)->status == StackStatusActive;
|
||||
}
|
||||
|
||||
bool ts_stack_is_halted(const Stack *self, StackVersion version) {
|
||||
return array_get(&self->heads, version)->status == StackStatusHalted;
|
||||
}
|
||||
|
||||
bool ts_stack_is_paused(const Stack *self, StackVersion version) {
|
||||
return array_get(&self->heads, version)->status == StackStatusPaused;
|
||||
}
|
||||
|
||||
Subtree ts_stack_resume(Stack *self, StackVersion version) {
|
||||
StackHead *head = array_get(&self->heads, version);
|
||||
assert(head->status == StackStatusPaused);
|
||||
Subtree result = head->lookahead_when_paused;
|
||||
head->status = StackStatusActive;
|
||||
head->lookahead_when_paused = NULL_SUBTREE;
|
||||
return result;
|
||||
}
|
||||
|
||||
void ts_stack_clear(Stack *self) {
|
||||
stack_node_retain(self->base_node);
|
||||
for (uint32_t i = 0; i < self->heads.size; i++) {
|
||||
stack_head_delete(&self->heads.contents[i], &self->node_pool, self->subtree_pool);
|
||||
}
|
||||
array_clear(&self->heads);
|
||||
array_push(&self->heads, ((StackHead) {
|
||||
.node = self->base_node,
|
||||
.status = StackStatusActive,
|
||||
.last_external_token = NULL_SUBTREE,
|
||||
.lookahead_when_paused = NULL_SUBTREE,
|
||||
}));
|
||||
}
|
||||
|
||||
bool ts_stack_print_dot_graph(Stack *self, const TSLanguage *language, FILE *f) {
|
||||
array_reserve(&self->iterators, 32);
|
||||
if (!f) f = stderr;
|
||||
|
||||
fprintf(f, "digraph stack {\n");
|
||||
fprintf(f, "rankdir=\"RL\";\n");
|
||||
fprintf(f, "edge [arrowhead=none]\n");
|
||||
|
||||
Array(StackNode *) visited_nodes = array_new();
|
||||
|
||||
array_clear(&self->iterators);
|
||||
for (uint32_t i = 0; i < self->heads.size; i++) {
|
||||
StackHead *head = &self->heads.contents[i];
|
||||
if (head->status == StackStatusHalted) continue;
|
||||
|
||||
fprintf(f, "node_head_%u [shape=none, label=\"\"]\n", i);
|
||||
fprintf(f, "node_head_%u -> node_%p [", i, (void *)head->node);
|
||||
|
||||
if (head->status == StackStatusPaused) {
|
||||
fprintf(f, "color=red ");
|
||||
}
|
||||
fprintf(f,
|
||||
"label=%u, fontcolor=blue, weight=10000, labeltooltip=\"node_count: %u\nerror_cost: %u",
|
||||
i,
|
||||
ts_stack_node_count_since_error(self, i),
|
||||
ts_stack_error_cost(self, i)
|
||||
);
|
||||
|
||||
if (head->summary) {
|
||||
fprintf(f, "\nsummary:");
|
||||
for (uint32_t j = 0; j < head->summary->size; j++) fprintf(f, " %u", head->summary->contents[j].state);
|
||||
}
|
||||
|
||||
if (head->last_external_token.ptr) {
|
||||
const ExternalScannerState *state = &head->last_external_token.ptr->external_scanner_state;
|
||||
const char *data = ts_external_scanner_state_data(state);
|
||||
fprintf(f, "\nexternal_scanner_state:");
|
||||
for (uint32_t j = 0; j < state->length; j++) fprintf(f, " %2X", data[j]);
|
||||
}
|
||||
|
||||
fprintf(f, "\"]\n");
|
||||
array_push(&self->iterators, ((StackIterator) {
|
||||
.node = head->node
|
||||
}));
|
||||
}
|
||||
|
||||
bool all_iterators_done = false;
|
||||
while (!all_iterators_done) {
|
||||
all_iterators_done = true;
|
||||
|
||||
for (uint32_t i = 0; i < self->iterators.size; i++) {
|
||||
StackIterator iterator = self->iterators.contents[i];
|
||||
StackNode *node = iterator.node;
|
||||
|
||||
for (uint32_t j = 0; j < visited_nodes.size; j++) {
|
||||
if (visited_nodes.contents[j] == node) {
|
||||
node = NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!node) continue;
|
||||
all_iterators_done = false;
|
||||
|
||||
fprintf(f, "node_%p [", (void *)node);
|
||||
if (node->state == ERROR_STATE) {
|
||||
fprintf(f, "label=\"?\"");
|
||||
} else if (
|
||||
node->link_count == 1 &&
|
||||
node->links[0].subtree.ptr &&
|
||||
ts_subtree_extra(node->links[0].subtree)
|
||||
) {
|
||||
fprintf(f, "shape=point margin=0 label=\"\"");
|
||||
} else {
|
||||
fprintf(f, "label=\"%d\"", node->state);
|
||||
}
|
||||
|
||||
fprintf(
|
||||
f,
|
||||
" tooltip=\"position: %u,%u\nnode_count:%u\nerror_cost: %u\ndynamic_precedence: %d\"];\n",
|
||||
node->position.extent.row + 1,
|
||||
node->position.extent.column,
|
||||
node->node_count,
|
||||
node->error_cost,
|
||||
node->dynamic_precedence
|
||||
);
|
||||
|
||||
for (int j = 0; j < node->link_count; j++) {
|
||||
StackLink link = node->links[j];
|
||||
fprintf(f, "node_%p -> node_%p [", (void *)node, (void *)link.node);
|
||||
if (link.is_pending) fprintf(f, "style=dashed ");
|
||||
if (link.subtree.ptr && ts_subtree_extra(link.subtree)) fprintf(f, "fontcolor=gray ");
|
||||
|
||||
if (!link.subtree.ptr) {
|
||||
fprintf(f, "color=red");
|
||||
} else {
|
||||
fprintf(f, "label=\"");
|
||||
bool quoted = ts_subtree_visible(link.subtree) && !ts_subtree_named(link.subtree);
|
||||
if (quoted) fprintf(f, "'");
|
||||
ts_language_write_symbol_as_dot_string(language, f, ts_subtree_symbol(link.subtree));
|
||||
if (quoted) fprintf(f, "'");
|
||||
fprintf(f, "\"");
|
||||
fprintf(
|
||||
f,
|
||||
"labeltooltip=\"error_cost: %u\ndynamic_precedence: %" PRId32 "\"",
|
||||
ts_subtree_error_cost(link.subtree),
|
||||
ts_subtree_dynamic_precedence(link.subtree)
|
||||
);
|
||||
}
|
||||
|
||||
fprintf(f, "];\n");
|
||||
|
||||
StackIterator *next_iterator;
|
||||
if (j == 0) {
|
||||
next_iterator = &self->iterators.contents[i];
|
||||
} else {
|
||||
array_push(&self->iterators, iterator);
|
||||
next_iterator = array_back(&self->iterators);
|
||||
}
|
||||
next_iterator->node = link.node;
|
||||
}
|
||||
|
||||
array_push(&visited_nodes, node);
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(f, "}\n");
|
||||
|
||||
array_delete(&visited_nodes);
|
||||
return true;
|
||||
}
|
||||
|
||||
#undef forceinline
|
||||
|
|
@ -1,133 +0,0 @@
|
|||
#ifndef TREE_SITTER_PARSE_STACK_H_
|
||||
#define TREE_SITTER_PARSE_STACK_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "./array.h"
|
||||
#include "./subtree.h"
|
||||
#include "./error_costs.h"
|
||||
#include <stdio.h>
|
||||
|
||||
typedef struct Stack Stack;
|
||||
|
||||
typedef unsigned StackVersion;
|
||||
#define STACK_VERSION_NONE ((StackVersion)-1)
|
||||
|
||||
typedef struct {
|
||||
SubtreeArray subtrees;
|
||||
StackVersion version;
|
||||
} StackSlice;
|
||||
typedef Array(StackSlice) StackSliceArray;
|
||||
|
||||
typedef struct {
|
||||
Length position;
|
||||
unsigned depth;
|
||||
TSStateId state;
|
||||
} StackSummaryEntry;
|
||||
typedef Array(StackSummaryEntry) StackSummary;
|
||||
|
||||
// Create a stack.
|
||||
Stack *ts_stack_new(SubtreePool *);
|
||||
|
||||
// Release the memory reserved for a given stack.
|
||||
void ts_stack_delete(Stack *);
|
||||
|
||||
// Get the stack's current number of versions.
|
||||
uint32_t ts_stack_version_count(const Stack *);
|
||||
|
||||
// Get the state at the top of the given version of the stack. If the stack is
|
||||
// empty, this returns the initial state, 0.
|
||||
TSStateId ts_stack_state(const Stack *, StackVersion);
|
||||
|
||||
// Get the last external token associated with a given version of the stack.
|
||||
Subtree ts_stack_last_external_token(const Stack *, StackVersion);
|
||||
|
||||
// Set the last external token associated with a given version of the stack.
|
||||
void ts_stack_set_last_external_token(Stack *, StackVersion, Subtree );
|
||||
|
||||
// Get the position of the given version of the stack within the document.
|
||||
Length ts_stack_position(const Stack *, StackVersion);
|
||||
|
||||
// Push a tree and state onto the given version of the stack.
|
||||
//
|
||||
// This transfers ownership of the tree to the Stack. Callers that
|
||||
// need to retain ownership of the tree for their own purposes should
|
||||
// first retain the tree.
|
||||
void ts_stack_push(Stack *, StackVersion, Subtree , bool, TSStateId);
|
||||
|
||||
// Pop the given number of entries from the given version of the stack. This
|
||||
// operation can increase the number of stack versions by revealing multiple
|
||||
// versions which had previously been merged. It returns an array that
|
||||
// specifies the index of each revealed version and the trees that were
|
||||
// removed from that version.
|
||||
StackSliceArray ts_stack_pop_count(Stack *, StackVersion, uint32_t count);
|
||||
|
||||
// Remove an error at the top of the given version of the stack.
|
||||
SubtreeArray ts_stack_pop_error(Stack *, StackVersion);
|
||||
|
||||
// Remove any pending trees from the top of the given version of the stack.
|
||||
StackSliceArray ts_stack_pop_pending(Stack *, StackVersion);
|
||||
|
||||
// Remove any all trees from the given version of the stack.
|
||||
StackSliceArray ts_stack_pop_all(Stack *, StackVersion);
|
||||
|
||||
// Get the maximum number of tree nodes reachable from this version of the stack
|
||||
// since the last error was detected.
|
||||
unsigned ts_stack_node_count_since_error(const Stack *, StackVersion);
|
||||
|
||||
int ts_stack_dynamic_precedence(Stack *, StackVersion);
|
||||
|
||||
bool ts_stack_has_advanced_since_error(const Stack *, StackVersion);
|
||||
|
||||
// Compute a summary of all the parse states near the top of the given
|
||||
// version of the stack and store the summary for later retrieval.
|
||||
void ts_stack_record_summary(Stack *, StackVersion, unsigned max_depth);
|
||||
|
||||
// Retrieve a summary of all the parse states near the top of the
|
||||
// given version of the stack.
|
||||
StackSummary *ts_stack_get_summary(Stack *, StackVersion);
|
||||
|
||||
// Get the total cost of all errors on the given version of the stack.
|
||||
unsigned ts_stack_error_cost(const Stack *, StackVersion version);
|
||||
|
||||
// Merge the given two stack versions if possible, returning true
|
||||
// if they were successfully merged and false otherwise.
|
||||
bool ts_stack_merge(Stack *, StackVersion, StackVersion);
|
||||
|
||||
// Determine whether the given two stack versions can be merged.
|
||||
bool ts_stack_can_merge(Stack *, StackVersion, StackVersion);
|
||||
|
||||
Subtree ts_stack_resume(Stack *, StackVersion);
|
||||
|
||||
void ts_stack_pause(Stack *, StackVersion, Subtree);
|
||||
|
||||
void ts_stack_halt(Stack *, StackVersion);
|
||||
|
||||
bool ts_stack_is_active(const Stack *, StackVersion);
|
||||
|
||||
bool ts_stack_is_paused(const Stack *, StackVersion);
|
||||
|
||||
bool ts_stack_is_halted(const Stack *, StackVersion);
|
||||
|
||||
void ts_stack_renumber_version(Stack *, StackVersion, StackVersion);
|
||||
|
||||
void ts_stack_swap_versions(Stack *, StackVersion, StackVersion);
|
||||
|
||||
StackVersion ts_stack_copy_version(Stack *, StackVersion);
|
||||
|
||||
// Remove the given version from the stack.
|
||||
void ts_stack_remove_version(Stack *, StackVersion);
|
||||
|
||||
void ts_stack_clear(Stack *);
|
||||
|
||||
bool ts_stack_print_dot_graph(Stack *, const TSLanguage *, FILE *);
|
||||
|
||||
typedef void (*StackIterateCallback)(void *, TSStateId, uint32_t);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // TREE_SITTER_PARSE_STACK_H_
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,382 +0,0 @@
|
|||
#ifndef TREE_SITTER_SUBTREE_H_
|
||||
#define TREE_SITTER_SUBTREE_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <limits.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include "./length.h"
|
||||
#include "./array.h"
|
||||
#include "./error_costs.h"
|
||||
#include "./host.h"
|
||||
#include "api.h"
|
||||
#include "./parser.h"
|
||||
|
||||
#define TS_TREE_STATE_NONE USHRT_MAX
|
||||
#define NULL_SUBTREE ((Subtree) {.ptr = NULL})
|
||||
|
||||
// The serialized state of an external scanner.
|
||||
//
|
||||
// Every time an external token subtree is created after a call to an
|
||||
// external scanner, the scanner's `serialize` function is called to
|
||||
// retrieve a serialized copy of its state. The bytes are then copied
|
||||
// onto the subtree itself so that the scanner's state can later be
|
||||
// restored using its `deserialize` function.
|
||||
//
|
||||
// Small byte arrays are stored inline, and long ones are allocated
|
||||
// separately on the heap.
|
||||
typedef struct {
|
||||
union {
|
||||
char *long_data;
|
||||
char short_data[24];
|
||||
};
|
||||
uint32_t length;
|
||||
} ExternalScannerState;
|
||||
|
||||
// A compact representation of a subtree.
|
||||
//
|
||||
// This representation is used for small leaf nodes that are not
|
||||
// errors, and were not created by an external scanner.
|
||||
//
|
||||
// The idea behind the layout of this struct is that the `is_inline`
|
||||
// bit will fall exactly into the same location as the least significant
|
||||
// bit of the pointer in `Subtree` or `MutableSubtree`, respectively.
|
||||
// Because of alignment, for any valid pointer this will be 0, giving
|
||||
// us the opportunity to make use of this bit to signify whether to use
|
||||
// the pointer or the inline struct.
|
||||
typedef struct SubtreeInlineData SubtreeInlineData;
|
||||
|
||||
#define SUBTREE_BITS \
|
||||
bool visible : 1; \
|
||||
bool named : 1; \
|
||||
bool extra : 1; \
|
||||
bool has_changes : 1; \
|
||||
bool is_missing : 1; \
|
||||
bool is_keyword : 1;
|
||||
|
||||
#define SUBTREE_SIZE \
|
||||
uint8_t padding_columns; \
|
||||
uint8_t padding_rows : 4; \
|
||||
uint8_t lookahead_bytes : 4; \
|
||||
uint8_t padding_bytes; \
|
||||
uint8_t size_bytes;
|
||||
|
||||
#if TS_BIG_ENDIAN
|
||||
#if TS_PTR_SIZE == 32
|
||||
|
||||
struct SubtreeInlineData {
|
||||
uint16_t parse_state;
|
||||
uint8_t symbol;
|
||||
SUBTREE_BITS
|
||||
bool unused : 1;
|
||||
bool is_inline : 1;
|
||||
SUBTREE_SIZE
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
struct SubtreeInlineData {
|
||||
SUBTREE_SIZE
|
||||
uint16_t parse_state;
|
||||
uint8_t symbol;
|
||||
SUBTREE_BITS
|
||||
bool unused : 1;
|
||||
bool is_inline : 1;
|
||||
};
|
||||
|
||||
#endif
|
||||
#else
|
||||
|
||||
struct SubtreeInlineData {
|
||||
bool is_inline : 1;
|
||||
SUBTREE_BITS
|
||||
uint8_t symbol;
|
||||
uint16_t parse_state;
|
||||
SUBTREE_SIZE
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#undef SUBTREE_BITS
|
||||
#undef SUBTREE_SIZE
|
||||
|
||||
// A heap-allocated representation of a subtree.
|
||||
//
|
||||
// This representation is used for parent nodes, external tokens,
|
||||
// errors, and other leaf nodes whose data is too large to fit into
|
||||
// the inline representation.
|
||||
typedef struct {
|
||||
volatile uint32_t ref_count;
|
||||
Length padding;
|
||||
Length size;
|
||||
uint32_t lookahead_bytes;
|
||||
uint32_t error_cost;
|
||||
uint32_t child_count;
|
||||
TSSymbol symbol;
|
||||
TSStateId parse_state;
|
||||
|
||||
bool visible : 1;
|
||||
bool named : 1;
|
||||
bool extra : 1;
|
||||
bool fragile_left : 1;
|
||||
bool fragile_right : 1;
|
||||
bool has_changes : 1;
|
||||
bool has_external_tokens : 1;
|
||||
bool has_external_scanner_state_change : 1;
|
||||
bool depends_on_column: 1;
|
||||
bool is_missing : 1;
|
||||
bool is_keyword : 1;
|
||||
|
||||
union {
|
||||
// Non-terminal subtrees (`child_count > 0`)
|
||||
struct {
|
||||
uint32_t visible_child_count;
|
||||
uint32_t named_child_count;
|
||||
uint32_t visible_descendant_count;
|
||||
int32_t dynamic_precedence;
|
||||
uint16_t repeat_depth;
|
||||
uint16_t production_id;
|
||||
struct {
|
||||
TSSymbol symbol;
|
||||
TSStateId parse_state;
|
||||
} first_leaf;
|
||||
};
|
||||
|
||||
// External terminal subtrees (`child_count == 0 && has_external_tokens`)
|
||||
ExternalScannerState external_scanner_state;
|
||||
|
||||
// Error terminal subtrees (`child_count == 0 && symbol == ts_builtin_sym_error`)
|
||||
int32_t lookahead_char;
|
||||
};
|
||||
} SubtreeHeapData;
|
||||
|
||||
// The fundamental building block of a syntax tree.
|
||||
typedef union {
|
||||
SubtreeInlineData data;
|
||||
const SubtreeHeapData *ptr;
|
||||
} Subtree;
|
||||
|
||||
// Like Subtree, but mutable.
|
||||
typedef union {
|
||||
SubtreeInlineData data;
|
||||
SubtreeHeapData *ptr;
|
||||
} MutableSubtree;
|
||||
|
||||
typedef Array(Subtree) SubtreeArray;
|
||||
typedef Array(MutableSubtree) MutableSubtreeArray;
|
||||
|
||||
typedef struct {
|
||||
MutableSubtreeArray free_trees;
|
||||
MutableSubtreeArray tree_stack;
|
||||
} SubtreePool;
|
||||
|
||||
void ts_external_scanner_state_init(ExternalScannerState *, const char *, unsigned);
|
||||
const char *ts_external_scanner_state_data(const ExternalScannerState *);
|
||||
bool ts_external_scanner_state_eq(const ExternalScannerState *self, const char *, unsigned);
|
||||
void ts_external_scanner_state_delete(ExternalScannerState *self);
|
||||
|
||||
void ts_subtree_array_copy(SubtreeArray, SubtreeArray *);
|
||||
void ts_subtree_array_clear(SubtreePool *, SubtreeArray *);
|
||||
void ts_subtree_array_delete(SubtreePool *, SubtreeArray *);
|
||||
void ts_subtree_array_remove_trailing_extras(SubtreeArray *, SubtreeArray *);
|
||||
void ts_subtree_array_reverse(SubtreeArray *);
|
||||
|
||||
SubtreePool ts_subtree_pool_new(uint32_t capacity);
|
||||
void ts_subtree_pool_delete(SubtreePool *);
|
||||
|
||||
Subtree ts_subtree_new_leaf(
|
||||
SubtreePool *, TSSymbol, Length, Length, uint32_t,
|
||||
TSStateId, bool, bool, bool, const TSLanguage *
|
||||
);
|
||||
Subtree ts_subtree_new_error(
|
||||
SubtreePool *, int32_t, Length, Length, uint32_t, TSStateId, const TSLanguage *
|
||||
);
|
||||
MutableSubtree ts_subtree_new_node(TSSymbol, SubtreeArray *, unsigned, const TSLanguage *);
|
||||
Subtree ts_subtree_new_error_node(SubtreeArray *, bool, const TSLanguage *);
|
||||
Subtree ts_subtree_new_missing_leaf(SubtreePool *, TSSymbol, Length, uint32_t, const TSLanguage *);
|
||||
MutableSubtree ts_subtree_make_mut(SubtreePool *, Subtree);
|
||||
void ts_subtree_retain(Subtree);
|
||||
void ts_subtree_release(SubtreePool *, Subtree);
|
||||
int ts_subtree_compare(Subtree, Subtree, SubtreePool *);
|
||||
void ts_subtree_set_symbol(MutableSubtree *, TSSymbol, const TSLanguage *);
|
||||
void ts_subtree_summarize(MutableSubtree, const Subtree *, uint32_t, const TSLanguage *);
|
||||
void ts_subtree_summarize_children(MutableSubtree, const TSLanguage *);
|
||||
void ts_subtree_balance(Subtree, SubtreePool *, const TSLanguage *);
|
||||
Subtree ts_subtree_edit(Subtree, const TSInputEdit *edit, SubtreePool *);
|
||||
char *ts_subtree_string(Subtree, TSSymbol, bool, const TSLanguage *, bool include_all);
|
||||
void ts_subtree_print_dot_graph(Subtree, const TSLanguage *, FILE *);
|
||||
Subtree ts_subtree_last_external_token(Subtree);
|
||||
const ExternalScannerState *ts_subtree_external_scanner_state(Subtree self);
|
||||
bool ts_subtree_external_scanner_state_eq(Subtree, Subtree);
|
||||
|
||||
#define SUBTREE_GET(self, name) ((self).data.is_inline ? (self).data.name : (self).ptr->name)
|
||||
|
||||
static inline TSSymbol ts_subtree_symbol(Subtree self) { return SUBTREE_GET(self, symbol); }
|
||||
static inline bool ts_subtree_visible(Subtree self) { return SUBTREE_GET(self, visible); }
|
||||
static inline bool ts_subtree_named(Subtree self) { return SUBTREE_GET(self, named); }
|
||||
static inline bool ts_subtree_extra(Subtree self) { return SUBTREE_GET(self, extra); }
|
||||
static inline bool ts_subtree_has_changes(Subtree self) { return SUBTREE_GET(self, has_changes); }
|
||||
static inline bool ts_subtree_missing(Subtree self) { return SUBTREE_GET(self, is_missing); }
|
||||
static inline bool ts_subtree_is_keyword(Subtree self) { return SUBTREE_GET(self, is_keyword); }
|
||||
static inline TSStateId ts_subtree_parse_state(Subtree self) { return SUBTREE_GET(self, parse_state); }
|
||||
static inline uint32_t ts_subtree_lookahead_bytes(Subtree self) { return SUBTREE_GET(self, lookahead_bytes); }
|
||||
|
||||
#undef SUBTREE_GET
|
||||
|
||||
// Get the size needed to store a heap-allocated subtree with the given
|
||||
// number of children.
|
||||
static inline size_t ts_subtree_alloc_size(uint32_t child_count) {
|
||||
return child_count * sizeof(Subtree) + sizeof(SubtreeHeapData);
|
||||
}
|
||||
|
||||
// Get a subtree's children, which are allocated immediately before the
|
||||
// tree's own heap data.
|
||||
#define ts_subtree_children(self) \
|
||||
((self).data.is_inline ? NULL : (Subtree *)((self).ptr) - (self).ptr->child_count)
|
||||
|
||||
static inline void ts_subtree_set_extra(MutableSubtree *self, bool is_extra) {
|
||||
if (self->data.is_inline) {
|
||||
self->data.extra = is_extra;
|
||||
} else {
|
||||
self->ptr->extra = is_extra;
|
||||
}
|
||||
}
|
||||
|
||||
static inline TSSymbol ts_subtree_leaf_symbol(Subtree self) {
|
||||
if (self.data.is_inline) return self.data.symbol;
|
||||
if (self.ptr->child_count == 0) return self.ptr->symbol;
|
||||
return self.ptr->first_leaf.symbol;
|
||||
}
|
||||
|
||||
static inline TSStateId ts_subtree_leaf_parse_state(Subtree self) {
|
||||
if (self.data.is_inline) return self.data.parse_state;
|
||||
if (self.ptr->child_count == 0) return self.ptr->parse_state;
|
||||
return self.ptr->first_leaf.parse_state;
|
||||
}
|
||||
|
||||
static inline Length ts_subtree_padding(Subtree self) {
|
||||
if (self.data.is_inline) {
|
||||
Length result = {self.data.padding_bytes, {self.data.padding_rows, self.data.padding_columns}};
|
||||
return result;
|
||||
} else {
|
||||
return self.ptr->padding;
|
||||
}
|
||||
}
|
||||
|
||||
static inline Length ts_subtree_size(Subtree self) {
|
||||
if (self.data.is_inline) {
|
||||
Length result = {self.data.size_bytes, {0, self.data.size_bytes}};
|
||||
return result;
|
||||
} else {
|
||||
return self.ptr->size;
|
||||
}
|
||||
}
|
||||
|
||||
static inline Length ts_subtree_total_size(Subtree self) {
|
||||
return length_add(ts_subtree_padding(self), ts_subtree_size(self));
|
||||
}
|
||||
|
||||
static inline uint32_t ts_subtree_total_bytes(Subtree self) {
|
||||
return ts_subtree_total_size(self).bytes;
|
||||
}
|
||||
|
||||
static inline uint32_t ts_subtree_child_count(Subtree self) {
|
||||
return self.data.is_inline ? 0 : self.ptr->child_count;
|
||||
}
|
||||
|
||||
static inline uint32_t ts_subtree_repeat_depth(Subtree self) {
|
||||
return self.data.is_inline ? 0 : self.ptr->repeat_depth;
|
||||
}
|
||||
|
||||
static inline uint32_t ts_subtree_is_repetition(Subtree self) {
|
||||
return self.data.is_inline
|
||||
? 0
|
||||
: !self.ptr->named && !self.ptr->visible && self.ptr->child_count != 0;
|
||||
}
|
||||
|
||||
static inline uint32_t ts_subtree_visible_descendant_count(Subtree self) {
|
||||
return (self.data.is_inline || self.ptr->child_count == 0)
|
||||
? 0
|
||||
: self.ptr->visible_descendant_count;
|
||||
}
|
||||
|
||||
static inline uint32_t ts_subtree_visible_child_count(Subtree self) {
|
||||
if (ts_subtree_child_count(self) > 0) {
|
||||
return self.ptr->visible_child_count;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static inline uint32_t ts_subtree_error_cost(Subtree self) {
|
||||
if (ts_subtree_missing(self)) {
|
||||
return ERROR_COST_PER_MISSING_TREE + ERROR_COST_PER_RECOVERY;
|
||||
} else {
|
||||
return self.data.is_inline ? 0 : self.ptr->error_cost;
|
||||
}
|
||||
}
|
||||
|
||||
static inline int32_t ts_subtree_dynamic_precedence(Subtree self) {
|
||||
return (self.data.is_inline || self.ptr->child_count == 0) ? 0 : self.ptr->dynamic_precedence;
|
||||
}
|
||||
|
||||
static inline uint16_t ts_subtree_production_id(Subtree self) {
|
||||
if (ts_subtree_child_count(self) > 0) {
|
||||
return self.ptr->production_id;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static inline bool ts_subtree_fragile_left(Subtree self) {
|
||||
return self.data.is_inline ? false : self.ptr->fragile_left;
|
||||
}
|
||||
|
||||
static inline bool ts_subtree_fragile_right(Subtree self) {
|
||||
return self.data.is_inline ? false : self.ptr->fragile_right;
|
||||
}
|
||||
|
||||
static inline bool ts_subtree_has_external_tokens(Subtree self) {
|
||||
return self.data.is_inline ? false : self.ptr->has_external_tokens;
|
||||
}
|
||||
|
||||
static inline bool ts_subtree_has_external_scanner_state_change(Subtree self) {
|
||||
return self.data.is_inline ? false : self.ptr->has_external_scanner_state_change;
|
||||
}
|
||||
|
||||
static inline bool ts_subtree_depends_on_column(Subtree self) {
|
||||
return self.data.is_inline ? false : self.ptr->depends_on_column;
|
||||
}
|
||||
|
||||
static inline bool ts_subtree_is_fragile(Subtree self) {
|
||||
return self.data.is_inline ? false : (self.ptr->fragile_left || self.ptr->fragile_right);
|
||||
}
|
||||
|
||||
static inline bool ts_subtree_is_error(Subtree self) {
|
||||
return ts_subtree_symbol(self) == ts_builtin_sym_error;
|
||||
}
|
||||
|
||||
static inline bool ts_subtree_is_eof(Subtree self) {
|
||||
return ts_subtree_symbol(self) == ts_builtin_sym_end;
|
||||
}
|
||||
|
||||
static inline Subtree ts_subtree_from_mut(MutableSubtree self) {
|
||||
Subtree result;
|
||||
result.data = self.data;
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline MutableSubtree ts_subtree_to_mut_unsafe(Subtree self) {
|
||||
MutableSubtree result;
|
||||
result.data = self.data;
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // TREE_SITTER_SUBTREE_H_
|
||||
|
|
@ -1,140 +0,0 @@
|
|||
#define _POSIX_C_SOURCE 200112L
|
||||
|
||||
#include "api.h"
|
||||
#include "./array.h"
|
||||
|
||||
#include "./length.h"
|
||||
#include "./subtree.h"
|
||||
#include "./tree_cursor.h"
|
||||
#include "./tree.h"
|
||||
|
||||
TSTree *ts_tree_new(
|
||||
Subtree root, const TSLanguage *language,
|
||||
const TSRange *included_ranges, unsigned included_range_count
|
||||
) {
|
||||
TSTree *result = malloc(sizeof(TSTree));
|
||||
result->root = root;
|
||||
result->language = ts_language_copy(language);
|
||||
result->included_ranges = calloc(included_range_count, sizeof(TSRange));
|
||||
memcpy(result->included_ranges, included_ranges, included_range_count * sizeof(TSRange));
|
||||
result->included_range_count = included_range_count;
|
||||
return result;
|
||||
}
|
||||
|
||||
TSTree *ts_tree_copy(const TSTree *self) {
|
||||
ts_subtree_retain(self->root);
|
||||
return ts_tree_new(self->root, self->language, self->included_ranges, self->included_range_count);
|
||||
}
|
||||
|
||||
void ts_tree_delete(TSTree *self) {
|
||||
if (!self) return;
|
||||
|
||||
SubtreePool pool = ts_subtree_pool_new(0);
|
||||
ts_subtree_release(&pool, self->root);
|
||||
ts_subtree_pool_delete(&pool);
|
||||
ts_language_delete(self->language);
|
||||
free(self->included_ranges);
|
||||
free(self);
|
||||
}
|
||||
|
||||
TSNode ts_tree_root_node(const TSTree *self) {
|
||||
return ts_node_new(self, &self->root, ts_subtree_padding(self->root), 0);
|
||||
}
|
||||
|
||||
TSNode ts_tree_root_node_with_offset(
|
||||
const TSTree *self,
|
||||
uint32_t offset_bytes,
|
||||
TSPoint offset_extent
|
||||
) {
|
||||
Length offset = {offset_bytes, offset_extent};
|
||||
return ts_node_new(self, &self->root, length_add(offset, ts_subtree_padding(self->root)), 0);
|
||||
}
|
||||
|
||||
const TSLanguage *ts_tree_language(const TSTree *self) {
|
||||
return self->language;
|
||||
}
|
||||
|
||||
void ts_tree_edit(TSTree *self, const TSInputEdit *edit) {
|
||||
for (unsigned i = 0; i < self->included_range_count; i++) {
|
||||
TSRange *range = &self->included_ranges[i];
|
||||
if (range->end_byte >= edit->old_end_byte) {
|
||||
if (range->end_byte != UINT32_MAX) {
|
||||
range->end_byte = edit->new_end_byte + (range->end_byte - edit->old_end_byte);
|
||||
range->end_point = point_add(
|
||||
edit->new_end_point,
|
||||
point_sub(range->end_point, edit->old_end_point)
|
||||
);
|
||||
if (range->end_byte < edit->new_end_byte) {
|
||||
range->end_byte = UINT32_MAX;
|
||||
range->end_point = POINT_MAX;
|
||||
}
|
||||
}
|
||||
} else if (range->end_byte > edit->start_byte) {
|
||||
range->end_byte = edit->start_byte;
|
||||
range->end_point = edit->start_point;
|
||||
}
|
||||
if (range->start_byte >= edit->old_end_byte) {
|
||||
range->start_byte = edit->new_end_byte + (range->start_byte - edit->old_end_byte);
|
||||
range->start_point = point_add(
|
||||
edit->new_end_point,
|
||||
point_sub(range->start_point, edit->old_end_point)
|
||||
);
|
||||
if (range->start_byte < edit->new_end_byte) {
|
||||
range->start_byte = UINT32_MAX;
|
||||
range->start_point = POINT_MAX;
|
||||
}
|
||||
} else if (range->start_byte > edit->start_byte) {
|
||||
range->start_byte = edit->start_byte;
|
||||
range->start_point = edit->start_point;
|
||||
}
|
||||
}
|
||||
|
||||
SubtreePool pool = ts_subtree_pool_new(0);
|
||||
self->root = ts_subtree_edit(self->root, edit, &pool);
|
||||
ts_subtree_pool_delete(&pool);
|
||||
}
|
||||
|
||||
TSRange *ts_tree_included_ranges(const TSTree *self, uint32_t *length) {
|
||||
*length = self->included_range_count;
|
||||
TSRange *ranges = calloc(self->included_range_count, sizeof(TSRange));
|
||||
memcpy(ranges, self->included_ranges, self->included_range_count * sizeof(TSRange));
|
||||
return ranges;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#include <io.h>
|
||||
#include <windows.h>
|
||||
|
||||
int _ts_dup(HANDLE handle) {
|
||||
HANDLE dup_handle;
|
||||
if (!DuplicateHandle(
|
||||
GetCurrentProcess(), handle,
|
||||
GetCurrentProcess(), &dup_handle,
|
||||
0, FALSE, DUPLICATE_SAME_ACCESS
|
||||
)) return -1;
|
||||
|
||||
return _open_osfhandle((intptr_t)dup_handle, 0);
|
||||
}
|
||||
|
||||
void ts_tree_print_dot_graph(const TSTree *self, int fd) {
|
||||
FILE *file = _fdopen(_ts_dup((HANDLE)_get_osfhandle(fd)), "a");
|
||||
ts_subtree_print_dot_graph(self->root, self->language, file);
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
int _ts_dup(int file_descriptor) {
|
||||
return dup(file_descriptor);
|
||||
}
|
||||
|
||||
void ts_tree_print_dot_graph(const TSTree *self, int file_descriptor) {
|
||||
FILE *file = fdopen(_ts_dup(file_descriptor), "a");
|
||||
ts_subtree_print_dot_graph(self->root, self->language, file);
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
#ifndef TREE_SITTER_TREE_H_
|
||||
#define TREE_SITTER_TREE_H_
|
||||
|
||||
#include "./subtree.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
const Subtree *child;
|
||||
const Subtree *parent;
|
||||
Length position;
|
||||
TSSymbol alias_symbol;
|
||||
} ParentCacheEntry;
|
||||
|
||||
struct TSTree {
|
||||
Subtree root;
|
||||
const TSLanguage *language;
|
||||
TSRange *included_ranges;
|
||||
unsigned included_range_count;
|
||||
};
|
||||
|
||||
TSTree *ts_tree_new(Subtree root, const TSLanguage *language, const TSRange *, unsigned);
|
||||
TSNode ts_node_new(const TSTree *, const Subtree *, Length, TSSymbol);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // TREE_SITTER_TREE_H_
|
||||
|
|
@ -1,714 +0,0 @@
|
|||
#include "api.h"
|
||||
|
||||
#include "./tree_cursor.h"
|
||||
#include "./language.h"
|
||||
#include "./tree.h"
|
||||
|
||||
typedef struct {
|
||||
Subtree parent;
|
||||
const TSTree *tree;
|
||||
Length position;
|
||||
uint32_t child_index;
|
||||
uint32_t structural_child_index;
|
||||
uint32_t descendant_index;
|
||||
const TSSymbol *alias_sequence;
|
||||
} CursorChildIterator;
|
||||
|
||||
// CursorChildIterator
|
||||
|
||||
static inline bool ts_tree_cursor_is_entry_visible(const TreeCursor *self, uint32_t index) {
|
||||
TreeCursorEntry *entry = &self->stack.contents[index];
|
||||
if (index == 0 || ts_subtree_visible(*entry->subtree)) {
|
||||
return true;
|
||||
} else if (!ts_subtree_extra(*entry->subtree)) {
|
||||
TreeCursorEntry *parent_entry = &self->stack.contents[index - 1];
|
||||
return ts_language_alias_at(
|
||||
self->tree->language,
|
||||
parent_entry->subtree->ptr->production_id,
|
||||
entry->structural_child_index
|
||||
);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static inline CursorChildIterator ts_tree_cursor_iterate_children(const TreeCursor *self) {
|
||||
TreeCursorEntry *last_entry = array_back(&self->stack);
|
||||
if (ts_subtree_child_count(*last_entry->subtree) == 0) {
|
||||
return (CursorChildIterator) {NULL_SUBTREE, self->tree, length_zero(), 0, 0, 0, NULL};
|
||||
}
|
||||
const TSSymbol *alias_sequence = ts_language_alias_sequence(
|
||||
self->tree->language,
|
||||
last_entry->subtree->ptr->production_id
|
||||
);
|
||||
|
||||
uint32_t descendant_index = last_entry->descendant_index;
|
||||
if (ts_tree_cursor_is_entry_visible(self, self->stack.size - 1)) {
|
||||
descendant_index += 1;
|
||||
}
|
||||
|
||||
return (CursorChildIterator) {
|
||||
.tree = self->tree,
|
||||
.parent = *last_entry->subtree,
|
||||
.position = last_entry->position,
|
||||
.child_index = 0,
|
||||
.structural_child_index = 0,
|
||||
.descendant_index = descendant_index,
|
||||
.alias_sequence = alias_sequence,
|
||||
};
|
||||
}
|
||||
|
||||
static inline bool ts_tree_cursor_child_iterator_next(
|
||||
CursorChildIterator *self,
|
||||
TreeCursorEntry *result,
|
||||
bool *visible
|
||||
) {
|
||||
if (!self->parent.ptr || self->child_index == self->parent.ptr->child_count) return false;
|
||||
const Subtree *child = &ts_subtree_children(self->parent)[self->child_index];
|
||||
*result = (TreeCursorEntry) {
|
||||
.subtree = child,
|
||||
.position = self->position,
|
||||
.child_index = self->child_index,
|
||||
.structural_child_index = self->structural_child_index,
|
||||
.descendant_index = self->descendant_index,
|
||||
};
|
||||
*visible = ts_subtree_visible(*child);
|
||||
bool extra = ts_subtree_extra(*child);
|
||||
if (!extra) {
|
||||
if (self->alias_sequence) {
|
||||
*visible |= self->alias_sequence[self->structural_child_index];
|
||||
}
|
||||
self->structural_child_index++;
|
||||
}
|
||||
|
||||
self->descendant_index += ts_subtree_visible_descendant_count(*child);
|
||||
if (*visible) {
|
||||
self->descendant_index += 1;
|
||||
}
|
||||
|
||||
self->position = length_add(self->position, ts_subtree_size(*child));
|
||||
self->child_index++;
|
||||
|
||||
if (self->child_index < self->parent.ptr->child_count) {
|
||||
Subtree next_child = ts_subtree_children(self->parent)[self->child_index];
|
||||
self->position = length_add(self->position, ts_subtree_padding(next_child));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Return a position that, when `b` is added to it, yields `a`. This
|
||||
// can only be computed if `b` has zero rows. Otherwise, this function
|
||||
// returns `LENGTH_UNDEFINED`, and the caller needs to recompute
|
||||
// the position some other way.
|
||||
static inline Length length_backtrack(Length a, Length b) {
|
||||
if (length_is_undefined(a) || b.extent.row != 0) {
|
||||
return LENGTH_UNDEFINED;
|
||||
}
|
||||
|
||||
Length result;
|
||||
result.bytes = a.bytes - b.bytes;
|
||||
result.extent.row = a.extent.row;
|
||||
result.extent.column = a.extent.column - b.extent.column;
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline bool ts_tree_cursor_child_iterator_previous(
|
||||
CursorChildIterator *self,
|
||||
TreeCursorEntry *result,
|
||||
bool *visible
|
||||
) {
|
||||
// this is mostly a reverse `ts_tree_cursor_child_iterator_next` taking into
|
||||
// account unsigned underflow
|
||||
if (!self->parent.ptr || (int8_t)self->child_index == -1) return false;
|
||||
const Subtree *child = &ts_subtree_children(self->parent)[self->child_index];
|
||||
*result = (TreeCursorEntry) {
|
||||
.subtree = child,
|
||||
.position = self->position,
|
||||
.child_index = self->child_index,
|
||||
.structural_child_index = self->structural_child_index,
|
||||
};
|
||||
*visible = ts_subtree_visible(*child);
|
||||
bool extra = ts_subtree_extra(*child);
|
||||
if (!extra && self->alias_sequence) {
|
||||
*visible |= self->alias_sequence[self->structural_child_index];
|
||||
self->structural_child_index--;
|
||||
}
|
||||
|
||||
self->position = length_backtrack(self->position, ts_subtree_padding(*child));
|
||||
self->child_index--;
|
||||
|
||||
// unsigned can underflow so compare it to child_count
|
||||
if (self->child_index < self->parent.ptr->child_count) {
|
||||
Subtree previous_child = ts_subtree_children(self->parent)[self->child_index];
|
||||
Length size = ts_subtree_size(previous_child);
|
||||
self->position = length_backtrack(self->position, size);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// TSTreeCursor - lifecycle
|
||||
|
||||
TSTreeCursor ts_tree_cursor_new(TSNode node) {
|
||||
TSTreeCursor self = {NULL, NULL, {0, 0, 0}};
|
||||
ts_tree_cursor_init((TreeCursor *)&self, node);
|
||||
return self;
|
||||
}
|
||||
|
||||
void ts_tree_cursor_reset(TSTreeCursor *_self, TSNode node) {
|
||||
ts_tree_cursor_init((TreeCursor *)_self, node);
|
||||
}
|
||||
|
||||
void ts_tree_cursor_init(TreeCursor *self, TSNode node) {
|
||||
self->tree = node.tree;
|
||||
self->root_alias_symbol = node.context[3];
|
||||
array_clear(&self->stack);
|
||||
array_push(&self->stack, ((TreeCursorEntry) {
|
||||
.subtree = (const Subtree *)node.id,
|
||||
.position = {
|
||||
ts_node_start_byte(node),
|
||||
ts_node_start_point(node)
|
||||
},
|
||||
.child_index = 0,
|
||||
.structural_child_index = 0,
|
||||
.descendant_index = 0,
|
||||
}));
|
||||
}
|
||||
|
||||
void ts_tree_cursor_delete(TSTreeCursor *_self) {
|
||||
TreeCursor *self = (TreeCursor *)_self;
|
||||
array_delete(&self->stack);
|
||||
}
|
||||
|
||||
// TSTreeCursor - walking the tree
|
||||
|
||||
TreeCursorStep ts_tree_cursor_goto_first_child_internal(TSTreeCursor *_self) {
|
||||
TreeCursor *self = (TreeCursor *)_self;
|
||||
bool visible;
|
||||
TreeCursorEntry entry;
|
||||
CursorChildIterator iterator = ts_tree_cursor_iterate_children(self);
|
||||
while (ts_tree_cursor_child_iterator_next(&iterator, &entry, &visible)) {
|
||||
if (visible) {
|
||||
array_push(&self->stack, entry);
|
||||
return TreeCursorStepVisible;
|
||||
}
|
||||
if (ts_subtree_visible_child_count(*entry.subtree) > 0) {
|
||||
array_push(&self->stack, entry);
|
||||
return TreeCursorStepHidden;
|
||||
}
|
||||
}
|
||||
return TreeCursorStepNone;
|
||||
}
|
||||
|
||||
bool ts_tree_cursor_goto_first_child(TSTreeCursor *self) {
|
||||
for (;;) {
|
||||
switch (ts_tree_cursor_goto_first_child_internal(self)) {
|
||||
case TreeCursorStepHidden:
|
||||
continue;
|
||||
case TreeCursorStepVisible:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
TreeCursorStep ts_tree_cursor_goto_last_child_internal(TSTreeCursor *_self) {
|
||||
TreeCursor *self = (TreeCursor *)_self;
|
||||
bool visible;
|
||||
TreeCursorEntry entry;
|
||||
CursorChildIterator iterator = ts_tree_cursor_iterate_children(self);
|
||||
if (!iterator.parent.ptr || iterator.parent.ptr->child_count == 0) return TreeCursorStepNone;
|
||||
|
||||
TreeCursorEntry last_entry = {0};
|
||||
TreeCursorStep last_step = TreeCursorStepNone;
|
||||
while (ts_tree_cursor_child_iterator_next(&iterator, &entry, &visible)) {
|
||||
if (visible) {
|
||||
last_entry = entry;
|
||||
last_step = TreeCursorStepVisible;
|
||||
}
|
||||
else if (ts_subtree_visible_child_count(*entry.subtree) > 0) {
|
||||
last_entry = entry;
|
||||
last_step = TreeCursorStepHidden;
|
||||
}
|
||||
}
|
||||
if (last_entry.subtree) {
|
||||
array_push(&self->stack, last_entry);
|
||||
return last_step;
|
||||
}
|
||||
|
||||
return TreeCursorStepNone;
|
||||
}
|
||||
|
||||
bool ts_tree_cursor_goto_last_child(TSTreeCursor *self) {
|
||||
for (;;) {
|
||||
switch (ts_tree_cursor_goto_last_child_internal(self)) {
|
||||
case TreeCursorStepHidden:
|
||||
continue;
|
||||
case TreeCursorStepVisible:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static inline int64_t ts_tree_cursor_goto_first_child_for_byte_and_point(
|
||||
TSTreeCursor *_self,
|
||||
uint32_t goal_byte,
|
||||
TSPoint goal_point
|
||||
) {
|
||||
TreeCursor *self = (TreeCursor *)_self;
|
||||
uint32_t initial_size = self->stack.size;
|
||||
uint32_t visible_child_index = 0;
|
||||
|
||||
bool did_descend;
|
||||
do {
|
||||
did_descend = false;
|
||||
|
||||
bool visible;
|
||||
TreeCursorEntry entry;
|
||||
CursorChildIterator iterator = ts_tree_cursor_iterate_children(self);
|
||||
while (ts_tree_cursor_child_iterator_next(&iterator, &entry, &visible)) {
|
||||
Length entry_end = length_add(entry.position, ts_subtree_size(*entry.subtree));
|
||||
bool at_goal = entry_end.bytes >= goal_byte && point_gte(entry_end.extent, goal_point);
|
||||
uint32_t visible_child_count = ts_subtree_visible_child_count(*entry.subtree);
|
||||
if (at_goal) {
|
||||
if (visible) {
|
||||
array_push(&self->stack, entry);
|
||||
return visible_child_index;
|
||||
}
|
||||
if (visible_child_count > 0) {
|
||||
array_push(&self->stack, entry);
|
||||
did_descend = true;
|
||||
break;
|
||||
}
|
||||
} else if (visible) {
|
||||
visible_child_index++;
|
||||
} else {
|
||||
visible_child_index += visible_child_count;
|
||||
}
|
||||
}
|
||||
} while (did_descend);
|
||||
|
||||
self->stack.size = initial_size;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int64_t ts_tree_cursor_goto_first_child_for_byte(TSTreeCursor *self, uint32_t goal_byte) {
|
||||
return ts_tree_cursor_goto_first_child_for_byte_and_point(self, goal_byte, POINT_ZERO);
|
||||
}
|
||||
|
||||
int64_t ts_tree_cursor_goto_first_child_for_point(TSTreeCursor *self, TSPoint goal_point) {
|
||||
return ts_tree_cursor_goto_first_child_for_byte_and_point(self, 0, goal_point);
|
||||
}
|
||||
|
||||
TreeCursorStep ts_tree_cursor_goto_sibling_internal(
|
||||
TSTreeCursor *_self,
|
||||
bool (*advance)(CursorChildIterator *, TreeCursorEntry *, bool *)) {
|
||||
TreeCursor *self = (TreeCursor *)_self;
|
||||
uint32_t initial_size = self->stack.size;
|
||||
|
||||
while (self->stack.size > 1) {
|
||||
TreeCursorEntry entry = array_pop(&self->stack);
|
||||
CursorChildIterator iterator = ts_tree_cursor_iterate_children(self);
|
||||
iterator.child_index = entry.child_index;
|
||||
iterator.structural_child_index = entry.structural_child_index;
|
||||
iterator.position = entry.position;
|
||||
iterator.descendant_index = entry.descendant_index;
|
||||
|
||||
bool visible = false;
|
||||
advance(&iterator, &entry, &visible);
|
||||
if (visible && self->stack.size + 1 < initial_size) break;
|
||||
|
||||
while (advance(&iterator, &entry, &visible)) {
|
||||
if (visible) {
|
||||
array_push(&self->stack, entry);
|
||||
return TreeCursorStepVisible;
|
||||
}
|
||||
|
||||
if (ts_subtree_visible_child_count(*entry.subtree)) {
|
||||
array_push(&self->stack, entry);
|
||||
return TreeCursorStepHidden;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self->stack.size = initial_size;
|
||||
return TreeCursorStepNone;
|
||||
}
|
||||
|
||||
TreeCursorStep ts_tree_cursor_goto_next_sibling_internal(TSTreeCursor *_self) {
|
||||
return ts_tree_cursor_goto_sibling_internal(_self, ts_tree_cursor_child_iterator_next);
|
||||
}
|
||||
|
||||
bool ts_tree_cursor_goto_next_sibling(TSTreeCursor *self) {
|
||||
switch (ts_tree_cursor_goto_next_sibling_internal(self)) {
|
||||
case TreeCursorStepHidden:
|
||||
ts_tree_cursor_goto_first_child(self);
|
||||
return true;
|
||||
case TreeCursorStepVisible:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
TreeCursorStep ts_tree_cursor_goto_previous_sibling_internal(TSTreeCursor *_self) {
|
||||
// since subtracting across row loses column information, we may have to
|
||||
// restore it
|
||||
TreeCursor *self = (TreeCursor *)_self;
|
||||
|
||||
// for that, save current position before traversing
|
||||
TreeCursorStep step = ts_tree_cursor_goto_sibling_internal(
|
||||
_self, ts_tree_cursor_child_iterator_previous);
|
||||
if (step == TreeCursorStepNone)
|
||||
return step;
|
||||
|
||||
// if length is already valid, there's no need to recompute it
|
||||
if (!length_is_undefined(array_back(&self->stack)->position))
|
||||
return step;
|
||||
|
||||
// restore position from the parent node
|
||||
const TreeCursorEntry *parent = &self->stack.contents[self->stack.size - 2];
|
||||
Length position = parent->position;
|
||||
uint32_t child_index = array_back(&self->stack)->child_index;
|
||||
const Subtree *children = ts_subtree_children((*(parent->subtree)));
|
||||
|
||||
if (child_index > 0) {
|
||||
// skip first child padding since its position should match the position of the parent
|
||||
position = length_add(position, ts_subtree_size(children[0]));
|
||||
for (uint32_t i = 1; i < child_index; ++i) {
|
||||
position = length_add(position, ts_subtree_total_size(children[i]));
|
||||
}
|
||||
position = length_add(position, ts_subtree_padding(children[child_index]));
|
||||
}
|
||||
|
||||
array_back(&self->stack)->position = position;
|
||||
|
||||
return step;
|
||||
}
|
||||
|
||||
bool ts_tree_cursor_goto_previous_sibling(TSTreeCursor *self) {
|
||||
switch (ts_tree_cursor_goto_previous_sibling_internal(self)) {
|
||||
case TreeCursorStepHidden:
|
||||
ts_tree_cursor_goto_last_child(self);
|
||||
return true;
|
||||
case TreeCursorStepVisible:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool ts_tree_cursor_goto_parent(TSTreeCursor *_self) {
|
||||
TreeCursor *self = (TreeCursor *)_self;
|
||||
for (unsigned i = self->stack.size - 2; i + 1 > 0; i--) {
|
||||
if (ts_tree_cursor_is_entry_visible(self, i)) {
|
||||
self->stack.size = i + 1;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void ts_tree_cursor_goto_descendant(
|
||||
TSTreeCursor *_self,
|
||||
uint32_t goal_descendant_index
|
||||
) {
|
||||
TreeCursor *self = (TreeCursor *)_self;
|
||||
|
||||
// Ascend to the lowest ancestor that contains the goal node.
|
||||
for (;;) {
|
||||
uint32_t i = self->stack.size - 1;
|
||||
TreeCursorEntry *entry = &self->stack.contents[i];
|
||||
uint32_t next_descendant_index =
|
||||
entry->descendant_index +
|
||||
(ts_tree_cursor_is_entry_visible(self, i) ? 1 : 0) +
|
||||
ts_subtree_visible_descendant_count(*entry->subtree);
|
||||
if (
|
||||
(entry->descendant_index <= goal_descendant_index) &&
|
||||
(next_descendant_index > goal_descendant_index)
|
||||
) {
|
||||
break;
|
||||
} else if (self->stack.size <= 1) {
|
||||
return;
|
||||
} else {
|
||||
self->stack.size--;
|
||||
}
|
||||
}
|
||||
|
||||
// Descend to the goal node.
|
||||
bool did_descend = true;
|
||||
do {
|
||||
did_descend = false;
|
||||
bool visible;
|
||||
TreeCursorEntry entry;
|
||||
CursorChildIterator iterator = ts_tree_cursor_iterate_children(self);
|
||||
if (iterator.descendant_index > goal_descendant_index) {
|
||||
return;
|
||||
}
|
||||
|
||||
while (ts_tree_cursor_child_iterator_next(&iterator, &entry, &visible)) {
|
||||
if (iterator.descendant_index > goal_descendant_index) {
|
||||
array_push(&self->stack, entry);
|
||||
if (visible && entry.descendant_index == goal_descendant_index) {
|
||||
return;
|
||||
} else {
|
||||
did_descend = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} while (did_descend);
|
||||
}
|
||||
|
||||
uint32_t ts_tree_cursor_current_descendant_index(const TSTreeCursor *_self) {
|
||||
const TreeCursor *self = (const TreeCursor *)_self;
|
||||
TreeCursorEntry *last_entry = array_back(&self->stack);
|
||||
return last_entry->descendant_index;
|
||||
}
|
||||
|
||||
TSNode ts_tree_cursor_current_node(const TSTreeCursor *_self) {
|
||||
const TreeCursor *self = (const TreeCursor *)_self;
|
||||
TreeCursorEntry *last_entry = array_back(&self->stack);
|
||||
TSSymbol alias_symbol = self->root_alias_symbol;
|
||||
if (self->stack.size > 1 && !ts_subtree_extra(*last_entry->subtree)) {
|
||||
TreeCursorEntry *parent_entry = &self->stack.contents[self->stack.size - 2];
|
||||
alias_symbol = ts_language_alias_at(
|
||||
self->tree->language,
|
||||
parent_entry->subtree->ptr->production_id,
|
||||
last_entry->structural_child_index
|
||||
);
|
||||
}
|
||||
return ts_node_new(
|
||||
self->tree,
|
||||
last_entry->subtree,
|
||||
last_entry->position,
|
||||
alias_symbol
|
||||
);
|
||||
}
|
||||
|
||||
// Private - Get various facts about the current node that are needed
|
||||
// when executing tree queries.
|
||||
void ts_tree_cursor_current_status(
|
||||
const TSTreeCursor *_self,
|
||||
TSFieldId *field_id,
|
||||
bool *has_later_siblings,
|
||||
bool *has_later_named_siblings,
|
||||
bool *can_have_later_siblings_with_this_field,
|
||||
TSSymbol *supertypes,
|
||||
unsigned *supertype_count
|
||||
) {
|
||||
const TreeCursor *self = (const TreeCursor *)_self;
|
||||
unsigned max_supertypes = *supertype_count;
|
||||
*field_id = 0;
|
||||
*supertype_count = 0;
|
||||
*has_later_siblings = false;
|
||||
*has_later_named_siblings = false;
|
||||
*can_have_later_siblings_with_this_field = false;
|
||||
|
||||
// Walk up the tree, visiting the current node and its invisible ancestors,
|
||||
// because fields can refer to nodes through invisible *wrapper* nodes,
|
||||
for (unsigned i = self->stack.size - 1; i > 0; i--) {
|
||||
TreeCursorEntry *entry = &self->stack.contents[i];
|
||||
TreeCursorEntry *parent_entry = &self->stack.contents[i - 1];
|
||||
|
||||
const TSSymbol *alias_sequence = ts_language_alias_sequence(
|
||||
self->tree->language,
|
||||
parent_entry->subtree->ptr->production_id
|
||||
);
|
||||
|
||||
#define subtree_symbol(subtree, structural_child_index) \
|
||||
(( \
|
||||
!ts_subtree_extra(subtree) && \
|
||||
alias_sequence && \
|
||||
alias_sequence[structural_child_index] \
|
||||
) ? \
|
||||
alias_sequence[structural_child_index] : \
|
||||
ts_subtree_symbol(subtree))
|
||||
|
||||
// Stop walking up when a visible ancestor is found.
|
||||
TSSymbol entry_symbol = subtree_symbol(
|
||||
*entry->subtree,
|
||||
entry->structural_child_index
|
||||
);
|
||||
TSSymbolMetadata entry_metadata = ts_language_symbol_metadata(
|
||||
self->tree->language,
|
||||
entry_symbol
|
||||
);
|
||||
if (i != self->stack.size - 1 && entry_metadata.visible) break;
|
||||
|
||||
// Record any supertypes
|
||||
if (entry_metadata.supertype && *supertype_count < max_supertypes) {
|
||||
supertypes[*supertype_count] = entry_symbol;
|
||||
(*supertype_count)++;
|
||||
}
|
||||
|
||||
// Determine if the current node has later siblings.
|
||||
if (!*has_later_siblings) {
|
||||
unsigned sibling_count = parent_entry->subtree->ptr->child_count;
|
||||
unsigned structural_child_index = entry->structural_child_index;
|
||||
if (!ts_subtree_extra(*entry->subtree)) structural_child_index++;
|
||||
for (unsigned j = entry->child_index + 1; j < sibling_count; j++) {
|
||||
Subtree sibling = ts_subtree_children(*parent_entry->subtree)[j];
|
||||
TSSymbolMetadata sibling_metadata = ts_language_symbol_metadata(
|
||||
self->tree->language,
|
||||
subtree_symbol(sibling, structural_child_index)
|
||||
);
|
||||
if (sibling_metadata.visible) {
|
||||
*has_later_siblings = true;
|
||||
if (*has_later_named_siblings) break;
|
||||
if (sibling_metadata.named) {
|
||||
*has_later_named_siblings = true;
|
||||
break;
|
||||
}
|
||||
} else if (ts_subtree_visible_child_count(sibling) > 0) {
|
||||
*has_later_siblings = true;
|
||||
if (*has_later_named_siblings) break;
|
||||
if (sibling.ptr->named_child_count > 0) {
|
||||
*has_later_named_siblings = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!ts_subtree_extra(sibling)) structural_child_index++;
|
||||
}
|
||||
}
|
||||
|
||||
#undef subtree_symbol
|
||||
|
||||
if (!ts_subtree_extra(*entry->subtree)) {
|
||||
const TSFieldMapEntry *field_map, *field_map_end;
|
||||
ts_language_field_map(
|
||||
self->tree->language,
|
||||
parent_entry->subtree->ptr->production_id,
|
||||
&field_map, &field_map_end
|
||||
);
|
||||
|
||||
// Look for a field name associated with the current node.
|
||||
if (!*field_id) {
|
||||
for (const TSFieldMapEntry *map = field_map; map < field_map_end; map++) {
|
||||
if (!map->inherited && map->child_index == entry->structural_child_index) {
|
||||
*field_id = map->field_id;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Determine if the current node can have later siblings with the same field name.
|
||||
if (*field_id) {
|
||||
for (const TSFieldMapEntry *map = field_map; map < field_map_end; map++) {
|
||||
if (
|
||||
map->field_id == *field_id &&
|
||||
map->child_index > entry->structural_child_index
|
||||
) {
|
||||
*can_have_later_siblings_with_this_field = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t ts_tree_cursor_current_depth(const TSTreeCursor *_self) {
|
||||
const TreeCursor *self = (const TreeCursor *)_self;
|
||||
uint32_t depth = 0;
|
||||
for (unsigned i = 1; i < self->stack.size; i++) {
|
||||
if (ts_tree_cursor_is_entry_visible(self, i)) {
|
||||
depth++;
|
||||
}
|
||||
}
|
||||
return depth;
|
||||
}
|
||||
|
||||
TSNode ts_tree_cursor_parent_node(const TSTreeCursor *_self) {
|
||||
const TreeCursor *self = (const TreeCursor *)_self;
|
||||
for (int i = (int)self->stack.size - 2; i >= 0; i--) {
|
||||
TreeCursorEntry *entry = &self->stack.contents[i];
|
||||
bool is_visible = true;
|
||||
TSSymbol alias_symbol = 0;
|
||||
if (i > 0) {
|
||||
TreeCursorEntry *parent_entry = &self->stack.contents[i - 1];
|
||||
alias_symbol = ts_language_alias_at(
|
||||
self->tree->language,
|
||||
parent_entry->subtree->ptr->production_id,
|
||||
entry->structural_child_index
|
||||
);
|
||||
is_visible = (alias_symbol != 0) || ts_subtree_visible(*entry->subtree);
|
||||
}
|
||||
if (is_visible) {
|
||||
return ts_node_new(
|
||||
self->tree,
|
||||
entry->subtree,
|
||||
entry->position,
|
||||
alias_symbol
|
||||
);
|
||||
}
|
||||
}
|
||||
return ts_node_new(NULL, NULL, length_zero(), 0);
|
||||
}
|
||||
|
||||
TSFieldId ts_tree_cursor_current_field_id(const TSTreeCursor *_self) {
|
||||
const TreeCursor *self = (const TreeCursor *)_self;
|
||||
|
||||
// Walk up the tree, visiting the current node and its invisible ancestors.
|
||||
for (unsigned i = self->stack.size - 1; i > 0; i--) {
|
||||
TreeCursorEntry *entry = &self->stack.contents[i];
|
||||
TreeCursorEntry *parent_entry = &self->stack.contents[i - 1];
|
||||
|
||||
// Stop walking up when another visible node is found.
|
||||
if (
|
||||
i != self->stack.size - 1 &&
|
||||
ts_tree_cursor_is_entry_visible(self, i)
|
||||
) break;
|
||||
|
||||
if (ts_subtree_extra(*entry->subtree)) break;
|
||||
|
||||
const TSFieldMapEntry *field_map, *field_map_end;
|
||||
ts_language_field_map(
|
||||
self->tree->language,
|
||||
parent_entry->subtree->ptr->production_id,
|
||||
&field_map, &field_map_end
|
||||
);
|
||||
for (const TSFieldMapEntry *map = field_map; map < field_map_end; map++) {
|
||||
if (!map->inherited && map->child_index == entry->structural_child_index) {
|
||||
return map->field_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char *ts_tree_cursor_current_field_name(const TSTreeCursor *_self) {
|
||||
TSFieldId id = ts_tree_cursor_current_field_id(_self);
|
||||
if (id) {
|
||||
const TreeCursor *self = (const TreeCursor *)_self;
|
||||
return self->tree->language->field_names[id];
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
TSTreeCursor ts_tree_cursor_copy(const TSTreeCursor *_cursor) {
|
||||
const TreeCursor *cursor = (const TreeCursor *)_cursor;
|
||||
TSTreeCursor res = {NULL, NULL, {0, 0}};
|
||||
TreeCursor *copy = (TreeCursor *)&res;
|
||||
copy->tree = cursor->tree;
|
||||
copy->root_alias_symbol = cursor->root_alias_symbol;
|
||||
array_init(©->stack);
|
||||
array_push_all(©->stack, &cursor->stack);
|
||||
return res;
|
||||
}
|
||||
|
||||
void ts_tree_cursor_reset_to(TSTreeCursor *_dst, const TSTreeCursor *_src) {
|
||||
const TreeCursor *cursor = (const TreeCursor *)_src;
|
||||
TreeCursor *copy = (TreeCursor *)_dst;
|
||||
copy->tree = cursor->tree;
|
||||
copy->root_alias_symbol = cursor->root_alias_symbol;
|
||||
array_clear(©->stack);
|
||||
array_push_all(©->stack, &cursor->stack);
|
||||
}
|
||||
|
|
@ -1,48 +0,0 @@
|
|||
#ifndef TREE_SITTER_TREE_CURSOR_H_
|
||||
#define TREE_SITTER_TREE_CURSOR_H_
|
||||
|
||||
#include "./subtree.h"
|
||||
|
||||
typedef struct {
|
||||
const Subtree *subtree;
|
||||
Length position;
|
||||
uint32_t child_index;
|
||||
uint32_t structural_child_index;
|
||||
uint32_t descendant_index;
|
||||
} TreeCursorEntry;
|
||||
|
||||
typedef struct {
|
||||
const TSTree *tree;
|
||||
Array(TreeCursorEntry) stack;
|
||||
TSSymbol root_alias_symbol;
|
||||
} TreeCursor;
|
||||
|
||||
typedef enum {
|
||||
TreeCursorStepNone,
|
||||
TreeCursorStepHidden,
|
||||
TreeCursorStepVisible,
|
||||
} TreeCursorStep;
|
||||
|
||||
void ts_tree_cursor_init(TreeCursor *, TSNode);
|
||||
void ts_tree_cursor_current_status(
|
||||
const TSTreeCursor *,
|
||||
TSFieldId *,
|
||||
bool *,
|
||||
bool *,
|
||||
bool *,
|
||||
TSSymbol *,
|
||||
unsigned *
|
||||
);
|
||||
|
||||
TreeCursorStep ts_tree_cursor_goto_first_child_internal(TSTreeCursor *);
|
||||
TreeCursorStep ts_tree_cursor_goto_next_sibling_internal(TSTreeCursor *);
|
||||
|
||||
static inline Subtree ts_tree_cursor_current_subtree(const TSTreeCursor *_self) {
|
||||
const TreeCursor *self = (const TreeCursor *)_self;
|
||||
TreeCursorEntry *last_entry = array_back(&self->stack);
|
||||
return *last_entry->subtree;
|
||||
}
|
||||
|
||||
TSNode ts_tree_cursor_parent_node(const TSTreeCursor *);
|
||||
|
||||
#endif // TREE_SITTER_TREE_CURSOR_H_
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* alias_sequences.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/14 19:17:54 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/04/14 19:18:20 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef ALIAS_SEQUENCES_H
|
||||
# define ALIAS_SEQUENCES_H
|
||||
|
||||
# include "../types/type_alias_sequences.h"
|
||||
# include "../headers/symbols.h"
|
||||
# include "../headers/external_scanner_symbol_identifiers.h"
|
||||
# include "../headers/field_identifiers.h"
|
||||
|
||||
# include "../headers/constants.h"
|
||||
|
||||
void alias_sequences_0(t_alias_sequences_array *v);
|
||||
void alias_sequences_1(t_alias_sequences_array *v);
|
||||
void alias_sequences_2(t_alias_sequences_array *v);
|
||||
|
||||
#endif // ALIAS_SEQUENCES_H
|
||||
|
|
@ -1,75 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* alias_sequences_0.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/14 19:17:54 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/04/14 19:18:20 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "./alias_sequences.h"
|
||||
|
||||
void alias_sequences_0(t_alias_sequences_array *v)
|
||||
{
|
||||
v->a[1][0] = sym_word;
|
||||
v->a[9][1] = sym_word;
|
||||
v->a[10][1] = sym_word;
|
||||
v->a[11][1] = anon_sym_AT2;
|
||||
v->a[13][0] = anon_sym_AT2;
|
||||
v->a[16][0] = sym_word;
|
||||
v->a[22][2] = sym_word;
|
||||
v->a[23][2] = sym_word;
|
||||
v->a[25][2] = sym_word;
|
||||
v->a[32][0] = anon_sym_AT2;
|
||||
v->a[33][1] = anon_sym_AT2;
|
||||
v->a[36][1] = sym_word;
|
||||
v->a[40][2] = sym_word;
|
||||
v->a[45][1] = sym_word;
|
||||
v->a[48][0] = sym_regex;
|
||||
v->a[53][1] = anon_sym_AT2;
|
||||
v->a[55][0] = sym_variable_name;
|
||||
v->a[59][0] = sym_word;
|
||||
v->a[62][2] = sym_word;
|
||||
v->a[77][0] = sym_word;
|
||||
alias_sequences_1(v);
|
||||
}
|
||||
|
||||
void alias_sequences_1(t_alias_sequences_array *v)
|
||||
{
|
||||
v->a[78][0] = sym_word;
|
||||
v->a[79][0] = sym_word;
|
||||
v->a[85][3] = sym_word;
|
||||
v->a[86][2] = sym_word;
|
||||
v->a[88][3] = sym_word;
|
||||
v->a[103][0] = sym_word;
|
||||
v->a[104][0] = sym_word;
|
||||
v->a[105][0] = sym_word;
|
||||
v->a[106][0] = sym_word;
|
||||
v->a[107][1] = sym_word;
|
||||
v->a[108][1] = sym_word;
|
||||
v->a[109][1] = sym_word;
|
||||
v->a[117][3] = sym_word;
|
||||
v->a[119][4] = sym_word;
|
||||
v->a[120][3] = sym_word;
|
||||
v->a[121][4] = sym_word;
|
||||
v->a[134][0] = sym_word;
|
||||
v->a[135][0] = sym_word;
|
||||
v->a[136][1] = sym_word;
|
||||
v->a[137][1] = sym_word;
|
||||
alias_sequences_2(v);
|
||||
}
|
||||
|
||||
void alias_sequences_2(t_alias_sequences_array *v)
|
||||
{
|
||||
v->a[138][1] = sym_word;
|
||||
v->a[139][1] = sym_word;
|
||||
v->a[146][4] = sym_word;
|
||||
v->a[147][4] = sym_word;
|
||||
v->a[153][1] = sym_word;
|
||||
v->a[154][1] = sym_word;
|
||||
}
|
||||
|
||||
/* EOF alias_sequences_0.c */
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* charset_inline.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/14 19:17:54 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/04/14 19:18:20 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef CHARSET_INLINE_H
|
||||
# define CHARSET_INLINE_H
|
||||
# include "../../parse_types.h"
|
||||
# include <stdint.h>
|
||||
|
||||
static inline t_char_range *sym__comment_word_character_set_1(void)
|
||||
{
|
||||
static t_char_range val[12] = {{0, 0x08}, {0x0e, 0x1f}, \
|
||||
{'!', '!'}, {'#', '#'}, {'%', '%'}, {'*', ':'}, {'=', \
|
||||
'='}, {'?', 'Z'}, {'\\', '\\'}, {'^', '_'}, {'a', 'z'}, \
|
||||
{'~', 0x10ffff}};
|
||||
|
||||
return (val);
|
||||
}
|
||||
|
||||
static inline t_char_range *sym_word_character_set_1(void)
|
||||
{
|
||||
static t_char_range val[11] = {{0, 0x08}, {0x0e, 0x1f}, \
|
||||
{'!', '!'}, {'%', '%'}, {'*', ':'}, {'=', '='}, {'?', \
|
||||
'Z'}, {'\\', '\\'}, {'^', '_'}, {'a', 'z'}, {'~', \
|
||||
0x10ffff}};
|
||||
|
||||
return (val);
|
||||
}
|
||||
|
||||
#endif // CHARSET_INLINE_H
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* create_alias_sequences.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/14 19:17:54 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/04/28 18:14:24 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../types/type_alias_sequences.h"
|
||||
#include "../alias_sequences/alias_sequences.h"
|
||||
|
||||
t_alias_sequences_array *create_alias_sequences(void)
|
||||
{
|
||||
static t_alias_sequences_array table = {};
|
||||
static bool init = false;
|
||||
|
||||
if (!init)
|
||||
{
|
||||
alias_sequences_0(&table);
|
||||
init = true;
|
||||
}
|
||||
return (&table);
|
||||
}
|
||||
|
||||
/* create_alias_sequences.c */
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* create_external_scanner_states.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/14 19:17:54 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/04/28 18:14:41 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../types/type_external_scanner_states.h"
|
||||
#include "../external_scanner_states/external_scanner_states.h"
|
||||
|
||||
t_external_scanner_states_array *create_external_scanner_states(void)
|
||||
{
|
||||
static t_external_scanner_states_array table = {};
|
||||
static bool init = false;
|
||||
|
||||
if (!init)
|
||||
{
|
||||
external_scanner_states_0(&table);
|
||||
init = true;
|
||||
}
|
||||
return (&table);
|
||||
}
|
||||
|
||||
/* create_external_scanner_states.c */
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* create_external_scanner_symbol_map.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/14 19:17:54 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/04/28 18:15:37 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../types/type_external_scanner_symbol_map.h"
|
||||
#include "../external_scanner_symbol_map/external_scanner_symbol_map.h"
|
||||
|
||||
t_external_scanner_symbol_map_array *create_external_scanner_symbol_map(void)
|
||||
{
|
||||
static t_external_scanner_symbol_map_array table = {};
|
||||
static bool init = false;
|
||||
|
||||
if (!init)
|
||||
{
|
||||
external_scanner_symbol_map_0(&table);
|
||||
init = true;
|
||||
}
|
||||
return (&table);
|
||||
}
|
||||
|
||||
/* create_external_scanner_symbol_map.c */
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* create_field_map_entries.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/14 19:17:54 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/04/28 18:14:55 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../types/type_field_map_entries.h"
|
||||
#include "../field_map_entries/field_map_entries.h"
|
||||
|
||||
t_field_map_entries_array *create_field_map_entries(void)
|
||||
{
|
||||
static t_field_map_entries_array table = {};
|
||||
static bool init = false;
|
||||
|
||||
if (!init)
|
||||
{
|
||||
field_map_entries_0(&table);
|
||||
init = true;
|
||||
}
|
||||
return (&table);
|
||||
}
|
||||
|
||||
/* create_field_map_entries.c */
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* create_field_map_slices.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/14 19:17:54 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/04/28 18:20:21 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../types/type_field_map_slices.h"
|
||||
#include "../field_map_slices/field_map_slices.h"
|
||||
|
||||
t_field_map_slices_array *create_field_map_slices(void)
|
||||
{
|
||||
static t_field_map_slices_array table = {};
|
||||
static bool init = false;
|
||||
|
||||
if (!init)
|
||||
{
|
||||
field_map_slices_0(&table);
|
||||
init = true;
|
||||
}
|
||||
return (&table);
|
||||
}
|
||||
|
||||
/* create_field_map_slices.c */
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* create_field_names.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/14 19:17:54 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/04/28 18:15:08 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../types/type_field_names.h"
|
||||
#include "../field_names/field_names.h"
|
||||
|
||||
t_field_names_array *create_field_names(void)
|
||||
{
|
||||
static t_field_names_array table = {};
|
||||
static bool init = false;
|
||||
|
||||
if (!init)
|
||||
{
|
||||
field_names_0(&table);
|
||||
init = true;
|
||||
}
|
||||
return (&table);
|
||||
}
|
||||
|
||||
/* create_field_names.c */
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* create_lex_keywords.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/14 19:17:54 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/04/28 18:15:20 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../types/type_lex_keywords.h"
|
||||
#include "../lex_funcs/lex_keywords/create_table/lex_keywords_array.h"
|
||||
|
||||
t_lex_keywords_array *create_lex_keywords(void)
|
||||
{
|
||||
static t_lex_keywords_array table = {};
|
||||
static bool init = false;
|
||||
|
||||
if (!init)
|
||||
{
|
||||
lex_keywords_array_0(&table);
|
||||
init = true;
|
||||
}
|
||||
return (&table);
|
||||
}
|
||||
|
||||
/* create_lex_keywords.c */
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* create_lex_modes.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/14 19:17:54 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/04/28 18:16:46 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../types/type_lex_modes.h"
|
||||
#include "../lex_modes/lex_modes.h"
|
||||
|
||||
t_lex_modes_array *create_lex_modes(void)
|
||||
{
|
||||
static t_lex_modes_array table = {};
|
||||
static bool init = false;
|
||||
|
||||
if (!init)
|
||||
{
|
||||
lex_modes_0(&table);
|
||||
init = true;
|
||||
}
|
||||
return (&table);
|
||||
}
|
||||
|
||||
/* create_lex_modes.c */
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* create_lex_normal.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/14 19:17:54 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/04/28 18:17:22 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../types/type_lex_normal.h"
|
||||
#include "../lex_funcs/lex_normal/create_table/lex_normal_array.h"
|
||||
|
||||
t_lex_normal_array *create_lex_normal(void)
|
||||
{
|
||||
static t_lex_normal_array table = {};
|
||||
static bool init = false;
|
||||
|
||||
if (!init)
|
||||
{
|
||||
lex_normal_array_0(&table);
|
||||
init = true;
|
||||
}
|
||||
return (&table);
|
||||
}
|
||||
|
||||
/* create_lex_normal.c */
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* create_non_terminal_alias_map.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/14 19:17:54 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/04/28 18:17:43 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../types/type_non_terminal_alias_map.h"
|
||||
#include "../non_terminal_alias_map/non_terminal_alias_map.h"
|
||||
|
||||
t_non_terminal_alias_map_array *create_non_terminal_alias_map(void)
|
||||
{
|
||||
static t_non_terminal_alias_map_array table = {};
|
||||
static bool init = false;
|
||||
|
||||
if (!init)
|
||||
{
|
||||
non_terminal_alias_map_0(&table);
|
||||
init = true;
|
||||
}
|
||||
return (&table);
|
||||
}
|
||||
|
||||
/* create_non_terminal_alias_map.c */
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* create_parse_actions_entries.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/14 19:17:54 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/04/28 18:18:15 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../types/type_parse_actions_entries.h"
|
||||
#include "../types/type_parse_actions_entries.h"
|
||||
#include "../parse_actions_entries/parse_actions_entries.h"
|
||||
|
||||
t_parse_actions_entries_array *create_parse_actions_entries(void)
|
||||
{
|
||||
static t_parse_actions_entries_array table = {};
|
||||
static bool init = false;
|
||||
|
||||
if (!init)
|
||||
{
|
||||
parse_actions_entries_0(&table);
|
||||
init = true;
|
||||
}
|
||||
return (&table);
|
||||
}
|
||||
|
||||
/* create_parse_actions_entries.c */
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* create_parse_table.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/14 19:17:54 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/04/28 18:17:06 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../types/type_parse_table.h"
|
||||
#include "../parse_table/parse_table.h"
|
||||
|
||||
t_parse_table_array *create_parse_table(void)
|
||||
{
|
||||
static t_parse_table_array table = {};
|
||||
static bool init = false;
|
||||
|
||||
if (!init)
|
||||
{
|
||||
parse_table_0(&table);
|
||||
init = true;
|
||||
}
|
||||
return (&table);
|
||||
}
|
||||
|
||||
/* create_parse_table.c */
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* create_primary_state_ids.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/14 19:17:54 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/04/28 18:18:30 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../types/type_primary_state_ids.h"
|
||||
#include "../primary_state_ids/primary_state_ids.h"
|
||||
|
||||
t_primary_state_ids_array *create_primary_state_ids(void)
|
||||
{
|
||||
static t_primary_state_ids_array table = {};
|
||||
static bool init = false;
|
||||
|
||||
if (!init)
|
||||
{
|
||||
primary_state_ids_0(&table);
|
||||
init = true;
|
||||
}
|
||||
return (&table);
|
||||
}
|
||||
|
||||
/* create_primary_state_ids.c */
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* create_small_parse_table.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/14 19:17:54 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/04/28 18:18:48 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../types/type_small_parse_table.h"
|
||||
#include "../small_parse_table/small_parse_table.h"
|
||||
|
||||
t_small_parse_table_array *create_small_parse_table(void)
|
||||
{
|
||||
static t_small_parse_table_array table = {};
|
||||
static bool init = false;
|
||||
|
||||
if (!init)
|
||||
{
|
||||
small_parse_table_0(&table);
|
||||
init = true;
|
||||
}
|
||||
return (&table);
|
||||
}
|
||||
|
||||
/* create_small_parse_table.c */
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* create_small_parse_table_map.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/14 19:17:54 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/04/28 18:19:01 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../types/type_small_parse_table_map.h"
|
||||
#include "../small_parse_table_map/small_parse_table_map.h"
|
||||
|
||||
t_small_parse_table_map_array *create_small_parse_table_map(void)
|
||||
{
|
||||
static t_small_parse_table_map_array table = {};
|
||||
static bool init = false;
|
||||
|
||||
if (!init)
|
||||
{
|
||||
small_parse_table_map_0(&table);
|
||||
init = true;
|
||||
}
|
||||
return (&table);
|
||||
}
|
||||
|
||||
/* create_small_parse_table_map.c */
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* create_symbols_metadata.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/14 19:17:54 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/04/28 18:19:14 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../types/type_symbols_metadata.h"
|
||||
#include "../symbols_metadata/symbols_metadata.h"
|
||||
|
||||
t_symbols_metadata_array *create_symbols_metadata(void)
|
||||
{
|
||||
static t_symbols_metadata_array table = {};
|
||||
static bool init = false;
|
||||
|
||||
if (!init)
|
||||
{
|
||||
symbols_metadata_0(&table);
|
||||
init = true;
|
||||
}
|
||||
return (&table);
|
||||
}
|
||||
|
||||
/* create_symbols_metadata.c */
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* create_symbols_names.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/14 19:17:54 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/04/28 18:19:25 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../types/type_symbols_names.h"
|
||||
#include "../symbols_names/symbols_names.h"
|
||||
|
||||
t_symbols_names_array *create_symbols_names(void)
|
||||
{
|
||||
static t_symbols_names_array table = {};
|
||||
static bool init = false;
|
||||
|
||||
if (!init)
|
||||
{
|
||||
symbols_names_0(&table);
|
||||
init = true;
|
||||
}
|
||||
return (&table);
|
||||
}
|
||||
|
||||
/* create_symbols_names.c */
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* create_unique_symbols_map.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/14 19:17:54 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/04/14 19:18:20 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../types/type_unique_symbols_map.h"
|
||||
#include "../unique_symbols_map/unique_symbols_map.h"
|
||||
|
||||
t_unique_symbols_map_array *create_unique_symbols_map(void)
|
||||
{
|
||||
static t_unique_symbols_map_array table = {};
|
||||
static bool init = false;
|
||||
|
||||
if (!init)
|
||||
{
|
||||
unique_symbols_map_0(&table);
|
||||
init = true;
|
||||
}
|
||||
return (&table);
|
||||
}
|
||||
|
||||
/* create_unique_symbols_map.c */
|
||||
|
|
@ -1,56 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* external_scanner_states.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/14 19:17:54 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/04/14 19:18:20 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef EXTERNAL_SCANNER_STATES_H
|
||||
# define EXTERNAL_SCANNER_STATES_H
|
||||
|
||||
# include "../types/type_external_scanner_states.h"
|
||||
# include "../headers/symbols.h"
|
||||
# include "../headers/external_scanner_symbol_identifiers.h"
|
||||
# include "../headers/field_identifiers.h"
|
||||
|
||||
# include "../headers/constants.h"
|
||||
|
||||
void external_scanner_states_0(t_external_scanner_states_array *v);
|
||||
void external_scanner_states_1(t_external_scanner_states_array *v);
|
||||
void external_scanner_states_2(t_external_scanner_states_array *v);
|
||||
void external_scanner_states_3(t_external_scanner_states_array *v);
|
||||
void external_scanner_states_4(t_external_scanner_states_array *v);
|
||||
void external_scanner_states_5(t_external_scanner_states_array *v);
|
||||
void external_scanner_states_6(t_external_scanner_states_array *v);
|
||||
void external_scanner_states_7(t_external_scanner_states_array *v);
|
||||
void external_scanner_states_8(t_external_scanner_states_array *v);
|
||||
void external_scanner_states_9(t_external_scanner_states_array *v);
|
||||
void external_scanner_states_10(t_external_scanner_states_array *v);
|
||||
void external_scanner_states_11(t_external_scanner_states_array *v);
|
||||
void external_scanner_states_12(t_external_scanner_states_array *v);
|
||||
void external_scanner_states_13(t_external_scanner_states_array *v);
|
||||
void external_scanner_states_14(t_external_scanner_states_array *v);
|
||||
void external_scanner_states_15(t_external_scanner_states_array *v);
|
||||
void external_scanner_states_16(t_external_scanner_states_array *v);
|
||||
void external_scanner_states_17(t_external_scanner_states_array *v);
|
||||
void external_scanner_states_18(t_external_scanner_states_array *v);
|
||||
void external_scanner_states_19(t_external_scanner_states_array *v);
|
||||
void external_scanner_states_20(t_external_scanner_states_array *v);
|
||||
void external_scanner_states_21(t_external_scanner_states_array *v);
|
||||
void external_scanner_states_22(t_external_scanner_states_array *v);
|
||||
void external_scanner_states_23(t_external_scanner_states_array *v);
|
||||
void external_scanner_states_24(t_external_scanner_states_array *v);
|
||||
void external_scanner_states_25(t_external_scanner_states_array *v);
|
||||
void external_scanner_states_26(t_external_scanner_states_array *v);
|
||||
void external_scanner_states_27(t_external_scanner_states_array *v);
|
||||
void external_scanner_states_28(t_external_scanner_states_array *v);
|
||||
void external_scanner_states_29(t_external_scanner_states_array *v);
|
||||
void external_scanner_states_30(t_external_scanner_states_array *v);
|
||||
void external_scanner_states_31(t_external_scanner_states_array *v);
|
||||
|
||||
#endif // EXTERNAL_SCANNER_STATES_H
|
||||
|
|
@ -1,140 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* external_scanner_states_0.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/14 19:17:54 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/04/14 19:18:20 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "./external_scanner_states.h"
|
||||
|
||||
void external_scanner_states_0(t_external_scanner_states_array *v)
|
||||
{
|
||||
v->a[1][ts_external_token_heredoc_start] = true;
|
||||
v->a[1][ts_external_token_simple_heredoc_body] = true;
|
||||
v->a[1][ts_external_token__heredoc_body_beginning] = true;
|
||||
v->a[1][ts_external_token_heredoc_content] = true;
|
||||
v->a[1][ts_external_token_heredoc_end] = true;
|
||||
v->a[1][ts_external_token_file_descriptor] = true;
|
||||
v->a[1][ts_external_token__empty_value] = true;
|
||||
v->a[1][ts_external_token__concat] = true;
|
||||
v->a[1][ts_external_token_variable_name] = true;
|
||||
v->a[1][ts_external_token_test_operator] = true;
|
||||
v->a[1][ts_external_token_regex] = true;
|
||||
v->a[1][ts_external_token__regex_no_slash] = true;
|
||||
v->a[1][ts_external_token__regex_no_space] = true;
|
||||
v->a[1][ts_external_token__expansion_word] = true;
|
||||
v->a[1][ts_external_token_extglob_pattern] = true;
|
||||
v->a[1][ts_external_token__bare_dollar] = true;
|
||||
v->a[1][ts_external_token__brace_start] = true;
|
||||
v->a[1][ts_external_token__immediate_double_hash] = true;
|
||||
v->a[1][ts_external_token__external_expansion_sym_hash] = true;
|
||||
v->a[1][ts_external_token__external_expansion_sym_bang] = true;
|
||||
external_scanner_states_1(v);
|
||||
}
|
||||
|
||||
void external_scanner_states_1(t_external_scanner_states_array *v)
|
||||
{
|
||||
v->a[1][ts_external_token__external_expansion_sym_equal] = true;
|
||||
v->a[1][ts_external_token_RBRACE] = true;
|
||||
v->a[1][ts_external_token_RBRACK] = true;
|
||||
v->a[1][ts_external_token_LT_LT] = true;
|
||||
v->a[1][ts_external_token_LT_LT_DASH] = true;
|
||||
v->a[1][ts_external_token_LPAREN] = true;
|
||||
v->a[1][ts_external_token_esac] = true;
|
||||
v->a[1][ts_external_token___error_recovery] = true;
|
||||
v->a[2][ts_external_token_file_descriptor] = true;
|
||||
v->a[2][ts_external_token_variable_name] = true;
|
||||
v->a[2][ts_external_token_test_operator] = true;
|
||||
v->a[2][ts_external_token__brace_start] = true;
|
||||
v->a[2][ts_external_token_LPAREN] = true;
|
||||
v->a[3][ts_external_token_file_descriptor] = true;
|
||||
v->a[3][ts_external_token_variable_name] = true;
|
||||
v->a[3][ts_external_token_test_operator] = true;
|
||||
v->a[3][ts_external_token__brace_start] = true;
|
||||
v->a[3][ts_external_token_RBRACK] = true;
|
||||
v->a[3][ts_external_token_LPAREN] = true;
|
||||
v->a[4][ts_external_token_file_descriptor] = true;
|
||||
external_scanner_states_2(v);
|
||||
}
|
||||
|
||||
void external_scanner_states_2(t_external_scanner_states_array *v)
|
||||
{
|
||||
v->a[4][ts_external_token__concat] = true;
|
||||
v->a[4][ts_external_token_test_operator] = true;
|
||||
v->a[4][ts_external_token__bare_dollar] = true;
|
||||
v->a[4][ts_external_token__brace_start] = true;
|
||||
v->a[4][ts_external_token_LT_LT] = true;
|
||||
v->a[4][ts_external_token_LT_LT_DASH] = true;
|
||||
v->a[4][ts_external_token_heredoc_redirect_token1] = true;
|
||||
v->a[4][ts_external_token_LPAREN] = true;
|
||||
v->a[5][ts_external_token_file_descriptor] = true;
|
||||
v->a[5][ts_external_token__concat] = true;
|
||||
v->a[5][ts_external_token_test_operator] = true;
|
||||
v->a[5][ts_external_token__bare_dollar] = true;
|
||||
v->a[5][ts_external_token__brace_start] = true;
|
||||
v->a[5][ts_external_token_RBRACK] = true;
|
||||
v->a[5][ts_external_token_LT_LT] = true;
|
||||
v->a[5][ts_external_token_LT_LT_DASH] = true;
|
||||
v->a[5][ts_external_token_LPAREN] = true;
|
||||
v->a[6][ts_external_token_file_descriptor] = true;
|
||||
v->a[6][ts_external_token_variable_name] = true;
|
||||
v->a[6][ts_external_token_test_operator] = true;
|
||||
external_scanner_states_3(v);
|
||||
}
|
||||
|
||||
void external_scanner_states_3(t_external_scanner_states_array *v)
|
||||
{
|
||||
v->a[6][ts_external_token__brace_start] = true;
|
||||
v->a[6][ts_external_token_LPAREN] = true;
|
||||
v->a[6][ts_external_token_esac] = true;
|
||||
v->a[7][ts_external_token__concat] = true;
|
||||
v->a[7][ts_external_token_test_operator] = true;
|
||||
v->a[7][ts_external_token__brace_start] = true;
|
||||
v->a[7][ts_external_token_LT_LT] = true;
|
||||
v->a[7][ts_external_token_LPAREN] = true;
|
||||
v->a[8][ts_external_token__concat] = true;
|
||||
v->a[8][ts_external_token_test_operator] = true;
|
||||
v->a[8][ts_external_token__brace_start] = true;
|
||||
v->a[8][ts_external_token_RBRACK] = true;
|
||||
v->a[8][ts_external_token_LT_LT] = true;
|
||||
v->a[8][ts_external_token_LPAREN] = true;
|
||||
v->a[9][ts_external_token_file_descriptor] = true;
|
||||
v->a[9][ts_external_token_variable_name] = true;
|
||||
v->a[9][ts_external_token_test_operator] = true;
|
||||
v->a[9][ts_external_token__bare_dollar] = true;
|
||||
v->a[9][ts_external_token__brace_start] = true;
|
||||
v->a[9][ts_external_token_LT_LT] = true;
|
||||
external_scanner_states_4(v);
|
||||
}
|
||||
|
||||
void external_scanner_states_4(t_external_scanner_states_array *v)
|
||||
{
|
||||
v->a[9][ts_external_token_LT_LT_DASH] = true;
|
||||
v->a[9][ts_external_token_heredoc_redirect_token1] = true;
|
||||
v->a[9][ts_external_token_LPAREN] = true;
|
||||
v->a[10][ts_external_token_file_descriptor] = true;
|
||||
v->a[10][ts_external_token_variable_name] = true;
|
||||
v->a[10][ts_external_token_test_operator] = true;
|
||||
v->a[10][ts_external_token__bare_dollar] = true;
|
||||
v->a[10][ts_external_token__brace_start] = true;
|
||||
v->a[10][ts_external_token_RBRACK] = true;
|
||||
v->a[10][ts_external_token_LT_LT] = true;
|
||||
v->a[10][ts_external_token_LT_LT_DASH] = true;
|
||||
v->a[10][ts_external_token_LPAREN] = true;
|
||||
v->a[11][ts_external_token_file_descriptor] = true;
|
||||
v->a[11][ts_external_token_test_operator] = true;
|
||||
v->a[11][ts_external_token__bare_dollar] = true;
|
||||
v->a[11][ts_external_token__brace_start] = true;
|
||||
v->a[11][ts_external_token_LT_LT] = true;
|
||||
v->a[11][ts_external_token_LT_LT_DASH] = true;
|
||||
v->a[11][ts_external_token_heredoc_redirect_token1] = true;
|
||||
v->a[11][ts_external_token_LPAREN] = true;
|
||||
external_scanner_states_5(v);
|
||||
}
|
||||
|
||||
/* EOF external_scanner_states_0.c */
|
||||
|
|
@ -1,140 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* external_scanner_states_1.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/14 19:17:54 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/04/14 19:18:20 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "./external_scanner_states.h"
|
||||
|
||||
void external_scanner_states_5(t_external_scanner_states_array *v)
|
||||
{
|
||||
v->a[12][ts_external_token_file_descriptor] = true;
|
||||
v->a[12][ts_external_token_test_operator] = true;
|
||||
v->a[12][ts_external_token__bare_dollar] = true;
|
||||
v->a[12][ts_external_token__brace_start] = true;
|
||||
v->a[12][ts_external_token_RBRACK] = true;
|
||||
v->a[12][ts_external_token_LT_LT] = true;
|
||||
v->a[12][ts_external_token_LT_LT_DASH] = true;
|
||||
v->a[12][ts_external_token_LPAREN] = true;
|
||||
v->a[13][ts_external_token_file_descriptor] = true;
|
||||
v->a[13][ts_external_token_test_operator] = true;
|
||||
v->a[13][ts_external_token__bare_dollar] = true;
|
||||
v->a[13][ts_external_token__brace_start] = true;
|
||||
v->a[13][ts_external_token_LT_LT] = true;
|
||||
v->a[13][ts_external_token_LT_LT_DASH] = true;
|
||||
v->a[13][ts_external_token_heredoc_redirect_token1] = true;
|
||||
v->a[13][ts_external_token_LPAREN] = true;
|
||||
v->a[13][ts_external_token_esac] = true;
|
||||
v->a[14][ts_external_token_file_descriptor] = true;
|
||||
v->a[14][ts_external_token_test_operator] = true;
|
||||
v->a[14][ts_external_token__bare_dollar] = true;
|
||||
external_scanner_states_6(v);
|
||||
}
|
||||
|
||||
void external_scanner_states_6(t_external_scanner_states_array *v)
|
||||
{
|
||||
v->a[14][ts_external_token__brace_start] = true;
|
||||
v->a[14][ts_external_token_LT_LT] = true;
|
||||
v->a[14][ts_external_token_LT_LT_DASH] = true;
|
||||
v->a[14][ts_external_token_heredoc_redirect_token1] = true;
|
||||
v->a[14][ts_external_token_esac] = true;
|
||||
v->a[15][ts_external_token_file_descriptor] = true;
|
||||
v->a[15][ts_external_token_variable_name] = true;
|
||||
v->a[15][ts_external_token_test_operator] = true;
|
||||
v->a[15][ts_external_token__bare_dollar] = true;
|
||||
v->a[15][ts_external_token__brace_start] = true;
|
||||
v->a[15][ts_external_token_LT_LT] = true;
|
||||
v->a[15][ts_external_token_LT_LT_DASH] = true;
|
||||
v->a[15][ts_external_token_heredoc_redirect_token1] = true;
|
||||
v->a[15][ts_external_token_LPAREN] = true;
|
||||
v->a[15][ts_external_token_esac] = true;
|
||||
v->a[16][ts_external_token_file_descriptor] = true;
|
||||
v->a[16][ts_external_token_test_operator] = true;
|
||||
v->a[16][ts_external_token__bare_dollar] = true;
|
||||
v->a[16][ts_external_token__brace_start] = true;
|
||||
v->a[16][ts_external_token_LT_LT] = true;
|
||||
external_scanner_states_7(v);
|
||||
}
|
||||
|
||||
void external_scanner_states_7(t_external_scanner_states_array *v)
|
||||
{
|
||||
v->a[16][ts_external_token_LT_LT_DASH] = true;
|
||||
v->a[16][ts_external_token_heredoc_redirect_token1] = true;
|
||||
v->a[17][ts_external_token_file_descriptor] = true;
|
||||
v->a[17][ts_external_token_variable_name] = true;
|
||||
v->a[17][ts_external_token_test_operator] = true;
|
||||
v->a[17][ts_external_token__brace_start] = true;
|
||||
v->a[17][ts_external_token_LT_LT] = true;
|
||||
v->a[17][ts_external_token_LT_LT_DASH] = true;
|
||||
v->a[17][ts_external_token_heredoc_redirect_token1] = true;
|
||||
v->a[17][ts_external_token_esac] = true;
|
||||
v->a[18][ts_external_token_file_descriptor] = true;
|
||||
v->a[18][ts_external_token_variable_name] = true;
|
||||
v->a[18][ts_external_token_test_operator] = true;
|
||||
v->a[18][ts_external_token__bare_dollar] = true;
|
||||
v->a[18][ts_external_token__brace_start] = true;
|
||||
v->a[18][ts_external_token_LT_LT] = true;
|
||||
v->a[18][ts_external_token_LT_LT_DASH] = true;
|
||||
v->a[18][ts_external_token_heredoc_redirect_token1] = true;
|
||||
v->a[18][ts_external_token_esac] = true;
|
||||
v->a[19][ts_external_token_file_descriptor] = true;
|
||||
external_scanner_states_8(v);
|
||||
}
|
||||
|
||||
void external_scanner_states_8(t_external_scanner_states_array *v)
|
||||
{
|
||||
v->a[19][ts_external_token_variable_name] = true;
|
||||
v->a[19][ts_external_token_test_operator] = true;
|
||||
v->a[19][ts_external_token__brace_start] = true;
|
||||
v->a[19][ts_external_token_LT_LT] = true;
|
||||
v->a[19][ts_external_token_LT_LT_DASH] = true;
|
||||
v->a[19][ts_external_token_heredoc_redirect_token1] = true;
|
||||
v->a[20][ts_external_token_file_descriptor] = true;
|
||||
v->a[20][ts_external_token_variable_name] = true;
|
||||
v->a[20][ts_external_token_test_operator] = true;
|
||||
v->a[20][ts_external_token__bare_dollar] = true;
|
||||
v->a[20][ts_external_token__brace_start] = true;
|
||||
v->a[20][ts_external_token_LT_LT] = true;
|
||||
v->a[20][ts_external_token_LT_LT_DASH] = true;
|
||||
v->a[20][ts_external_token_heredoc_redirect_token1] = true;
|
||||
v->a[21][ts_external_token_file_descriptor] = true;
|
||||
v->a[21][ts_external_token_test_operator] = true;
|
||||
v->a[21][ts_external_token__brace_start] = true;
|
||||
v->a[21][ts_external_token_LT_LT] = true;
|
||||
v->a[21][ts_external_token_LT_LT_DASH] = true;
|
||||
v->a[21][ts_external_token_heredoc_redirect_token1] = true;
|
||||
external_scanner_states_9(v);
|
||||
}
|
||||
|
||||
void external_scanner_states_9(t_external_scanner_states_array *v)
|
||||
{
|
||||
v->a[21][ts_external_token_esac] = true;
|
||||
v->a[22][ts_external_token_file_descriptor] = true;
|
||||
v->a[22][ts_external_token_test_operator] = true;
|
||||
v->a[22][ts_external_token__brace_start] = true;
|
||||
v->a[22][ts_external_token_LT_LT] = true;
|
||||
v->a[22][ts_external_token_LT_LT_DASH] = true;
|
||||
v->a[22][ts_external_token_heredoc_redirect_token1] = true;
|
||||
v->a[23][ts_external_token_file_descriptor] = true;
|
||||
v->a[23][ts_external_token_test_operator] = true;
|
||||
v->a[23][ts_external_token__bare_dollar] = true;
|
||||
v->a[23][ts_external_token__brace_start] = true;
|
||||
v->a[23][ts_external_token_LT_LT] = true;
|
||||
v->a[23][ts_external_token_LT_LT_DASH] = true;
|
||||
v->a[23][ts_external_token_LPAREN] = true;
|
||||
v->a[24][ts_external_token_variable_name] = true;
|
||||
v->a[24][ts_external_token_test_operator] = true;
|
||||
v->a[24][ts_external_token__brace_start] = true;
|
||||
v->a[24][ts_external_token_LPAREN] = true;
|
||||
v->a[25][ts_external_token_file_descriptor] = true;
|
||||
v->a[25][ts_external_token_test_operator] = true;
|
||||
external_scanner_states_10(v);
|
||||
}
|
||||
|
||||
/* EOF external_scanner_states_1.c */
|
||||
|
|
@ -1,140 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* external_scanner_states_2.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/14 19:17:54 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/04/14 19:18:20 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "./external_scanner_states.h"
|
||||
|
||||
void external_scanner_states_10(t_external_scanner_states_array *v)
|
||||
{
|
||||
v->a[25][ts_external_token__bare_dollar] = true;
|
||||
v->a[25][ts_external_token__brace_start] = true;
|
||||
v->a[25][ts_external_token_LT_LT] = true;
|
||||
v->a[25][ts_external_token_LT_LT_DASH] = true;
|
||||
v->a[26][ts_external_token_file_descriptor] = true;
|
||||
v->a[26][ts_external_token_test_operator] = true;
|
||||
v->a[26][ts_external_token__brace_start] = true;
|
||||
v->a[26][ts_external_token_heredoc_redirect_token1] = true;
|
||||
v->a[27][ts_external_token_file_descriptor] = true;
|
||||
v->a[27][ts_external_token_variable_name] = true;
|
||||
v->a[27][ts_external_token_test_operator] = true;
|
||||
v->a[27][ts_external_token__bare_dollar] = true;
|
||||
v->a[27][ts_external_token__brace_start] = true;
|
||||
v->a[27][ts_external_token_LT_LT] = true;
|
||||
v->a[27][ts_external_token_LT_LT_DASH] = true;
|
||||
v->a[27][ts_external_token_LPAREN] = true;
|
||||
v->a[28][ts_external_token_file_descriptor] = true;
|
||||
v->a[28][ts_external_token_variable_name] = true;
|
||||
v->a[28][ts_external_token_test_operator] = true;
|
||||
v->a[28][ts_external_token__bare_dollar] = true;
|
||||
external_scanner_states_11(v);
|
||||
}
|
||||
|
||||
void external_scanner_states_11(t_external_scanner_states_array *v)
|
||||
{
|
||||
v->a[28][ts_external_token__brace_start] = true;
|
||||
v->a[28][ts_external_token_LT_LT] = true;
|
||||
v->a[28][ts_external_token_LT_LT_DASH] = true;
|
||||
v->a[29][ts_external_token_file_descriptor] = true;
|
||||
v->a[29][ts_external_token_variable_name] = true;
|
||||
v->a[29][ts_external_token_test_operator] = true;
|
||||
v->a[29][ts_external_token__brace_start] = true;
|
||||
v->a[29][ts_external_token_LT_LT] = true;
|
||||
v->a[29][ts_external_token_LT_LT_DASH] = true;
|
||||
v->a[30][ts_external_token_file_descriptor] = true;
|
||||
v->a[30][ts_external_token__concat] = true;
|
||||
v->a[30][ts_external_token_test_operator] = true;
|
||||
v->a[30][ts_external_token__bare_dollar] = true;
|
||||
v->a[30][ts_external_token__brace_start] = true;
|
||||
v->a[30][ts_external_token_LT_LT] = true;
|
||||
v->a[30][ts_external_token_LT_LT_DASH] = true;
|
||||
v->a[30][ts_external_token_heredoc_redirect_token1] = true;
|
||||
v->a[30][ts_external_token_LPAREN] = true;
|
||||
v->a[30][ts_external_token_esac] = true;
|
||||
v->a[31][ts_external_token_file_descriptor] = true;
|
||||
external_scanner_states_12(v);
|
||||
}
|
||||
|
||||
void external_scanner_states_12(t_external_scanner_states_array *v)
|
||||
{
|
||||
v->a[31][ts_external_token_variable_name] = true;
|
||||
v->a[31][ts_external_token_test_operator] = true;
|
||||
v->a[31][ts_external_token__brace_start] = true;
|
||||
v->a[31][ts_external_token_RBRACK] = true;
|
||||
v->a[31][ts_external_token_LT_LT] = true;
|
||||
v->a[31][ts_external_token_LT_LT_DASH] = true;
|
||||
v->a[32][ts_external_token_file_descriptor] = true;
|
||||
v->a[32][ts_external_token__concat] = true;
|
||||
v->a[32][ts_external_token_test_operator] = true;
|
||||
v->a[32][ts_external_token__bare_dollar] = true;
|
||||
v->a[32][ts_external_token__brace_start] = true;
|
||||
v->a[32][ts_external_token_LT_LT] = true;
|
||||
v->a[32][ts_external_token_LT_LT_DASH] = true;
|
||||
v->a[32][ts_external_token_heredoc_redirect_token1] = true;
|
||||
v->a[32][ts_external_token_esac] = true;
|
||||
v->a[33][ts_external_token_file_descriptor] = true;
|
||||
v->a[33][ts_external_token_test_operator] = true;
|
||||
v->a[33][ts_external_token__brace_start] = true;
|
||||
v->a[33][ts_external_token_RBRACK] = true;
|
||||
v->a[33][ts_external_token_LT_LT] = true;
|
||||
external_scanner_states_13(v);
|
||||
}
|
||||
|
||||
void external_scanner_states_13(t_external_scanner_states_array *v)
|
||||
{
|
||||
v->a[33][ts_external_token_LT_LT_DASH] = true;
|
||||
v->a[34][ts_external_token_file_descriptor] = true;
|
||||
v->a[34][ts_external_token_test_operator] = true;
|
||||
v->a[34][ts_external_token__brace_start] = true;
|
||||
v->a[34][ts_external_token_LT_LT] = true;
|
||||
v->a[34][ts_external_token_LT_LT_DASH] = true;
|
||||
v->a[35][ts_external_token__concat] = true;
|
||||
v->a[35][ts_external_token_variable_name] = true;
|
||||
v->a[35][ts_external_token_test_operator] = true;
|
||||
v->a[35][ts_external_token_RBRACK] = true;
|
||||
v->a[35][ts_external_token_LT_LT] = true;
|
||||
v->a[36][ts_external_token_file_descriptor] = true;
|
||||
v->a[36][ts_external_token_variable_name] = true;
|
||||
v->a[36][ts_external_token_test_operator] = true;
|
||||
v->a[36][ts_external_token__brace_start] = true;
|
||||
v->a[37][ts_external_token_file_descriptor] = true;
|
||||
v->a[37][ts_external_token__concat] = true;
|
||||
v->a[37][ts_external_token_test_operator] = true;
|
||||
v->a[37][ts_external_token__bare_dollar] = true;
|
||||
v->a[37][ts_external_token__brace_start] = true;
|
||||
external_scanner_states_14(v);
|
||||
}
|
||||
|
||||
void external_scanner_states_14(t_external_scanner_states_array *v)
|
||||
{
|
||||
v->a[37][ts_external_token_LT_LT] = true;
|
||||
v->a[37][ts_external_token_LT_LT_DASH] = true;
|
||||
v->a[37][ts_external_token_heredoc_redirect_token1] = true;
|
||||
v->a[38][ts_external_token_file_descriptor] = true;
|
||||
v->a[38][ts_external_token__concat] = true;
|
||||
v->a[38][ts_external_token_variable_name] = true;
|
||||
v->a[38][ts_external_token_test_operator] = true;
|
||||
v->a[38][ts_external_token__brace_start] = true;
|
||||
v->a[38][ts_external_token_LT_LT] = true;
|
||||
v->a[38][ts_external_token_LT_LT_DASH] = true;
|
||||
v->a[38][ts_external_token_heredoc_redirect_token1] = true;
|
||||
v->a[38][ts_external_token_esac] = true;
|
||||
v->a[39][ts_external_token_variable_name] = true;
|
||||
v->a[39][ts_external_token_test_operator] = true;
|
||||
v->a[39][ts_external_token_LT_LT] = true;
|
||||
v->a[40][ts_external_token_variable_name] = true;
|
||||
v->a[40][ts_external_token_test_operator] = true;
|
||||
v->a[40][ts_external_token_RBRACK] = true;
|
||||
v->a[40][ts_external_token_LT_LT] = true;
|
||||
v->a[41][ts_external_token_file_descriptor] = true;
|
||||
external_scanner_states_15(v);
|
||||
}
|
||||
|
||||
/* EOF external_scanner_states_2.c */
|
||||
|
|
@ -1,140 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* external_scanner_states_3.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/14 19:17:54 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/04/14 19:18:20 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "./external_scanner_states.h"
|
||||
|
||||
void external_scanner_states_15(t_external_scanner_states_array *v)
|
||||
{
|
||||
v->a[41][ts_external_token__concat] = true;
|
||||
v->a[41][ts_external_token_variable_name] = true;
|
||||
v->a[41][ts_external_token_test_operator] = true;
|
||||
v->a[41][ts_external_token__brace_start] = true;
|
||||
v->a[41][ts_external_token_LT_LT] = true;
|
||||
v->a[41][ts_external_token_LT_LT_DASH] = true;
|
||||
v->a[41][ts_external_token_heredoc_redirect_token1] = true;
|
||||
v->a[42][ts_external_token_test_operator] = true;
|
||||
v->a[42][ts_external_token_LT_LT] = true;
|
||||
v->a[43][ts_external_token_file_descriptor] = true;
|
||||
v->a[43][ts_external_token__concat] = true;
|
||||
v->a[43][ts_external_token_test_operator] = true;
|
||||
v->a[43][ts_external_token__brace_start] = true;
|
||||
v->a[43][ts_external_token_LT_LT] = true;
|
||||
v->a[43][ts_external_token_LT_LT_DASH] = true;
|
||||
v->a[43][ts_external_token_heredoc_redirect_token1] = true;
|
||||
v->a[43][ts_external_token_esac] = true;
|
||||
v->a[44][ts_external_token_file_descriptor] = true;
|
||||
v->a[44][ts_external_token__concat] = true;
|
||||
v->a[44][ts_external_token_test_operator] = true;
|
||||
external_scanner_states_16(v);
|
||||
}
|
||||
|
||||
void external_scanner_states_16(t_external_scanner_states_array *v)
|
||||
{
|
||||
v->a[44][ts_external_token__brace_start] = true;
|
||||
v->a[44][ts_external_token_LT_LT] = true;
|
||||
v->a[44][ts_external_token_LT_LT_DASH] = true;
|
||||
v->a[44][ts_external_token_heredoc_redirect_token1] = true;
|
||||
v->a[45][ts_external_token__concat] = true;
|
||||
v->a[45][ts_external_token_test_operator] = true;
|
||||
v->a[45][ts_external_token_RBRACK] = true;
|
||||
v->a[45][ts_external_token_LT_LT] = true;
|
||||
v->a[46][ts_external_token_file_descriptor] = true;
|
||||
v->a[46][ts_external_token_variable_name] = true;
|
||||
v->a[46][ts_external_token_test_operator] = true;
|
||||
v->a[46][ts_external_token__brace_start] = true;
|
||||
v->a[46][ts_external_token_heredoc_redirect_token1] = true;
|
||||
v->a[47][ts_external_token_test_operator] = true;
|
||||
v->a[47][ts_external_token_extglob_pattern] = true;
|
||||
v->a[47][ts_external_token__brace_start] = true;
|
||||
v->a[47][ts_external_token_LPAREN] = true;
|
||||
v->a[48][ts_external_token_test_operator] = true;
|
||||
v->a[48][ts_external_token_RBRACK] = true;
|
||||
v->a[48][ts_external_token_LT_LT] = true;
|
||||
external_scanner_states_17(v);
|
||||
}
|
||||
|
||||
void external_scanner_states_17(t_external_scanner_states_array *v)
|
||||
{
|
||||
v->a[49][ts_external_token_test_operator] = true;
|
||||
v->a[49][ts_external_token__brace_start] = true;
|
||||
v->a[49][ts_external_token_LPAREN] = true;
|
||||
v->a[50][ts_external_token_test_operator] = true;
|
||||
v->a[50][ts_external_token__regex_no_space] = true;
|
||||
v->a[50][ts_external_token__brace_start] = true;
|
||||
v->a[50][ts_external_token_LPAREN] = true;
|
||||
v->a[51][ts_external_token_file_descriptor] = true;
|
||||
v->a[51][ts_external_token__concat] = true;
|
||||
v->a[51][ts_external_token_test_operator] = true;
|
||||
v->a[51][ts_external_token__bare_dollar] = true;
|
||||
v->a[51][ts_external_token__brace_start] = true;
|
||||
v->a[51][ts_external_token_LT_LT] = true;
|
||||
v->a[51][ts_external_token_LT_LT_DASH] = true;
|
||||
v->a[51][ts_external_token_LPAREN] = true;
|
||||
v->a[52][ts_external_token_file_descriptor] = true;
|
||||
v->a[52][ts_external_token__concat] = true;
|
||||
v->a[52][ts_external_token_test_operator] = true;
|
||||
v->a[52][ts_external_token__bare_dollar] = true;
|
||||
v->a[52][ts_external_token__brace_start] = true;
|
||||
external_scanner_states_18(v);
|
||||
}
|
||||
|
||||
void external_scanner_states_18(t_external_scanner_states_array *v)
|
||||
{
|
||||
v->a[52][ts_external_token_LT_LT] = true;
|
||||
v->a[52][ts_external_token_LT_LT_DASH] = true;
|
||||
v->a[53][ts_external_token_file_descriptor] = true;
|
||||
v->a[53][ts_external_token__concat] = true;
|
||||
v->a[53][ts_external_token_variable_name] = true;
|
||||
v->a[53][ts_external_token_test_operator] = true;
|
||||
v->a[53][ts_external_token__brace_start] = true;
|
||||
v->a[53][ts_external_token_RBRACK] = true;
|
||||
v->a[53][ts_external_token_LT_LT] = true;
|
||||
v->a[53][ts_external_token_LT_LT_DASH] = true;
|
||||
v->a[54][ts_external_token__concat] = true;
|
||||
v->a[54][ts_external_token_test_operator] = true;
|
||||
v->a[54][ts_external_token_LT_LT] = true;
|
||||
v->a[55][ts_external_token_test_operator] = true;
|
||||
v->a[55][ts_external_token_extglob_pattern] = true;
|
||||
v->a[55][ts_external_token__brace_start] = true;
|
||||
v->a[55][ts_external_token_heredoc_redirect_token1] = true;
|
||||
v->a[55][ts_external_token_LPAREN] = true;
|
||||
v->a[55][ts_external_token_esac] = true;
|
||||
v->a[56][ts_external_token_file_descriptor] = true;
|
||||
external_scanner_states_19(v);
|
||||
}
|
||||
|
||||
void external_scanner_states_19(t_external_scanner_states_array *v)
|
||||
{
|
||||
v->a[56][ts_external_token__concat] = true;
|
||||
v->a[56][ts_external_token_variable_name] = true;
|
||||
v->a[56][ts_external_token_test_operator] = true;
|
||||
v->a[56][ts_external_token__brace_start] = true;
|
||||
v->a[56][ts_external_token_LT_LT] = true;
|
||||
v->a[56][ts_external_token_LT_LT_DASH] = true;
|
||||
v->a[57][ts_external_token_file_descriptor] = true;
|
||||
v->a[57][ts_external_token__concat] = true;
|
||||
v->a[57][ts_external_token_test_operator] = true;
|
||||
v->a[57][ts_external_token__brace_start] = true;
|
||||
v->a[57][ts_external_token_RBRACK] = true;
|
||||
v->a[57][ts_external_token_LT_LT] = true;
|
||||
v->a[57][ts_external_token_LT_LT_DASH] = true;
|
||||
v->a[58][ts_external_token_test_operator] = true;
|
||||
v->a[58][ts_external_token_extglob_pattern] = true;
|
||||
v->a[58][ts_external_token_LT_LT] = true;
|
||||
v->a[59][ts_external_token_file_descriptor] = true;
|
||||
v->a[59][ts_external_token__concat] = true;
|
||||
v->a[59][ts_external_token_test_operator] = true;
|
||||
v->a[59][ts_external_token__brace_start] = true;
|
||||
external_scanner_states_20(v);
|
||||
}
|
||||
|
||||
/* EOF external_scanner_states_3.c */
|
||||
|
|
@ -1,140 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* external_scanner_states_4.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/14 19:17:54 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/04/14 19:18:20 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "./external_scanner_states.h"
|
||||
|
||||
void external_scanner_states_20(t_external_scanner_states_array *v)
|
||||
{
|
||||
v->a[59][ts_external_token_LT_LT] = true;
|
||||
v->a[59][ts_external_token_LT_LT_DASH] = true;
|
||||
v->a[60][ts_external_token_LT_LT] = true;
|
||||
v->a[61][ts_external_token__concat] = true;
|
||||
v->a[61][ts_external_token_test_operator] = true;
|
||||
v->a[61][ts_external_token_extglob_pattern] = true;
|
||||
v->a[61][ts_external_token_RBRACK] = true;
|
||||
v->a[61][ts_external_token_LT_LT] = true;
|
||||
v->a[62][ts_external_token__concat] = true;
|
||||
v->a[62][ts_external_token_LT_LT] = true;
|
||||
v->a[63][ts_external_token_file_descriptor] = true;
|
||||
v->a[63][ts_external_token_variable_name] = true;
|
||||
v->a[63][ts_external_token_LT_LT] = true;
|
||||
v->a[63][ts_external_token_LT_LT_DASH] = true;
|
||||
v->a[63][ts_external_token_heredoc_redirect_token1] = true;
|
||||
v->a[63][ts_external_token_esac] = true;
|
||||
v->a[64][ts_external_token_LT_LT] = true;
|
||||
v->a[64][ts_external_token_heredoc_redirect_token1] = true;
|
||||
v->a[65][ts_external_token_test_operator] = true;
|
||||
v->a[65][ts_external_token_extglob_pattern] = true;
|
||||
external_scanner_states_21(v);
|
||||
}
|
||||
|
||||
void external_scanner_states_21(t_external_scanner_states_array *v)
|
||||
{
|
||||
v->a[65][ts_external_token_RBRACK] = true;
|
||||
v->a[65][ts_external_token_LT_LT] = true;
|
||||
v->a[66][ts_external_token_file_descriptor] = true;
|
||||
v->a[66][ts_external_token_variable_name] = true;
|
||||
v->a[66][ts_external_token_LT_LT] = true;
|
||||
v->a[66][ts_external_token_LT_LT_DASH] = true;
|
||||
v->a[66][ts_external_token_heredoc_redirect_token1] = true;
|
||||
v->a[67][ts_external_token_test_operator] = true;
|
||||
v->a[67][ts_external_token_extglob_pattern] = true;
|
||||
v->a[67][ts_external_token__brace_start] = true;
|
||||
v->a[67][ts_external_token_LPAREN] = true;
|
||||
v->a[67][ts_external_token_esac] = true;
|
||||
v->a[68][ts_external_token__concat] = true;
|
||||
v->a[68][ts_external_token_RBRACK] = true;
|
||||
v->a[68][ts_external_token_LT_LT] = true;
|
||||
v->a[69][ts_external_token_RBRACK] = true;
|
||||
v->a[69][ts_external_token_LT_LT] = true;
|
||||
v->a[70][ts_external_token_file_descriptor] = true;
|
||||
v->a[70][ts_external_token__concat] = true;
|
||||
v->a[70][ts_external_token_test_operator] = true;
|
||||
external_scanner_states_22(v);
|
||||
}
|
||||
|
||||
void external_scanner_states_22(t_external_scanner_states_array *v)
|
||||
{
|
||||
v->a[70][ts_external_token__brace_start] = true;
|
||||
v->a[70][ts_external_token_heredoc_redirect_token1] = true;
|
||||
v->a[71][ts_external_token_file_descriptor] = true;
|
||||
v->a[71][ts_external_token__concat] = true;
|
||||
v->a[71][ts_external_token_variable_name] = true;
|
||||
v->a[71][ts_external_token_test_operator] = true;
|
||||
v->a[71][ts_external_token__brace_start] = true;
|
||||
v->a[72][ts_external_token_variable_name] = true;
|
||||
v->a[72][ts_external_token_test_operator] = true;
|
||||
v->a[72][ts_external_token__brace_start] = true;
|
||||
v->a[72][ts_external_token_heredoc_redirect_token1] = true;
|
||||
v->a[73][ts_external_token_test_operator] = true;
|
||||
v->a[73][ts_external_token__brace_start] = true;
|
||||
v->a[73][ts_external_token_heredoc_redirect_token1] = true;
|
||||
v->a[74][ts_external_token_variable_name] = true;
|
||||
v->a[74][ts_external_token_test_operator] = true;
|
||||
v->a[74][ts_external_token__expansion_word] = true;
|
||||
v->a[74][ts_external_token__brace_start] = true;
|
||||
v->a[74][ts_external_token_RBRACE] = true;
|
||||
v->a[74][ts_external_token_LPAREN] = true;
|
||||
external_scanner_states_23(v);
|
||||
}
|
||||
|
||||
void external_scanner_states_23(t_external_scanner_states_array *v)
|
||||
{
|
||||
v->a[75][ts_external_token__empty_value] = true;
|
||||
v->a[75][ts_external_token_test_operator] = true;
|
||||
v->a[75][ts_external_token__brace_start] = true;
|
||||
v->a[75][ts_external_token_LPAREN] = true;
|
||||
v->a[76][ts_external_token__immediate_double_hash] = true;
|
||||
v->a[76][ts_external_token__external_expansion_sym_hash] = true;
|
||||
v->a[76][ts_external_token__external_expansion_sym_bang] = true;
|
||||
v->a[76][ts_external_token__external_expansion_sym_equal] = true;
|
||||
v->a[76][ts_external_token_RBRACE] = true;
|
||||
v->a[77][ts_external_token_file_descriptor] = true;
|
||||
v->a[77][ts_external_token_variable_name] = true;
|
||||
v->a[77][ts_external_token_RBRACK] = true;
|
||||
v->a[77][ts_external_token_LT_LT] = true;
|
||||
v->a[77][ts_external_token_LT_LT_DASH] = true;
|
||||
v->a[78][ts_external_token_test_operator] = true;
|
||||
v->a[78][ts_external_token__brace_start] = true;
|
||||
v->a[79][ts_external_token_test_operator] = true;
|
||||
v->a[79][ts_external_token_extglob_pattern] = true;
|
||||
v->a[79][ts_external_token__brace_start] = true;
|
||||
v->a[80][ts_external_token_variable_name] = true;
|
||||
external_scanner_states_24(v);
|
||||
}
|
||||
|
||||
void external_scanner_states_24(t_external_scanner_states_array *v)
|
||||
{
|
||||
v->a[80][ts_external_token_test_operator] = true;
|
||||
v->a[80][ts_external_token__brace_start] = true;
|
||||
v->a[81][ts_external_token_file_descriptor] = true;
|
||||
v->a[81][ts_external_token_variable_name] = true;
|
||||
v->a[81][ts_external_token_LT_LT] = true;
|
||||
v->a[81][ts_external_token_LT_LT_DASH] = true;
|
||||
v->a[82][ts_external_token_test_operator] = true;
|
||||
v->a[82][ts_external_token__bare_dollar] = true;
|
||||
v->a[82][ts_external_token__brace_start] = true;
|
||||
v->a[82][ts_external_token_RBRACK] = true;
|
||||
v->a[83][ts_external_token_test_operator] = true;
|
||||
v->a[83][ts_external_token_regex] = true;
|
||||
v->a[83][ts_external_token__brace_start] = true;
|
||||
v->a[84][ts_external_token__immediate_double_hash] = true;
|
||||
v->a[84][ts_external_token_RBRACE] = true;
|
||||
v->a[85][ts_external_token_test_operator] = true;
|
||||
v->a[85][ts_external_token__bare_dollar] = true;
|
||||
v->a[85][ts_external_token__brace_start] = true;
|
||||
v->a[86][ts_external_token_variable_name] = true;
|
||||
v->a[86][ts_external_token_LPAREN] = true;
|
||||
external_scanner_states_25(v);
|
||||
}
|
||||
|
||||
/* EOF external_scanner_states_4.c */
|
||||
|
|
@ -1,140 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* external_scanner_states_5.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/14 19:17:54 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/04/14 19:18:20 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "./external_scanner_states.h"
|
||||
|
||||
void external_scanner_states_25(t_external_scanner_states_array *v)
|
||||
{
|
||||
v->a[87][ts_external_token_file_descriptor] = true;
|
||||
v->a[87][ts_external_token_variable_name] = true;
|
||||
v->a[87][ts_external_token_heredoc_redirect_token1] = true;
|
||||
v->a[88][ts_external_token_heredoc_redirect_token1] = true;
|
||||
v->a[88][ts_external_token_LPAREN] = true;
|
||||
v->a[89][ts_external_token_file_descriptor] = true;
|
||||
v->a[89][ts_external_token__concat] = true;
|
||||
v->a[89][ts_external_token_LT_LT] = true;
|
||||
v->a[89][ts_external_token_LT_LT_DASH] = true;
|
||||
v->a[89][ts_external_token_heredoc_redirect_token1] = true;
|
||||
v->a[89][ts_external_token_esac] = true;
|
||||
v->a[90][ts_external_token__immediate_double_hash] = true;
|
||||
v->a[91][ts_external_token_file_descriptor] = true;
|
||||
v->a[91][ts_external_token__concat] = true;
|
||||
v->a[91][ts_external_token_variable_name] = true;
|
||||
v->a[91][ts_external_token_LT_LT] = true;
|
||||
v->a[91][ts_external_token_LT_LT_DASH] = true;
|
||||
v->a[91][ts_external_token_heredoc_redirect_token1] = true;
|
||||
v->a[91][ts_external_token_esac] = true;
|
||||
v->a[92][ts_external_token_file_descriptor] = true;
|
||||
external_scanner_states_26(v);
|
||||
}
|
||||
|
||||
void external_scanner_states_26(t_external_scanner_states_array *v)
|
||||
{
|
||||
v->a[92][ts_external_token_LT_LT] = true;
|
||||
v->a[92][ts_external_token_LT_LT_DASH] = true;
|
||||
v->a[92][ts_external_token_heredoc_redirect_token1] = true;
|
||||
v->a[92][ts_external_token_esac] = true;
|
||||
v->a[93][ts_external_token_file_descriptor] = true;
|
||||
v->a[93][ts_external_token__concat] = true;
|
||||
v->a[93][ts_external_token_LT_LT] = true;
|
||||
v->a[93][ts_external_token_LT_LT_DASH] = true;
|
||||
v->a[93][ts_external_token_heredoc_redirect_token1] = true;
|
||||
v->a[94][ts_external_token_file_descriptor] = true;
|
||||
v->a[94][ts_external_token_LT_LT] = true;
|
||||
v->a[94][ts_external_token_LT_LT_DASH] = true;
|
||||
v->a[94][ts_external_token_heredoc_redirect_token1] = true;
|
||||
v->a[95][ts_external_token_file_descriptor] = true;
|
||||
v->a[95][ts_external_token__concat] = true;
|
||||
v->a[95][ts_external_token_variable_name] = true;
|
||||
v->a[95][ts_external_token_LT_LT] = true;
|
||||
v->a[95][ts_external_token_LT_LT_DASH] = true;
|
||||
v->a[95][ts_external_token_heredoc_redirect_token1] = true;
|
||||
v->a[96][ts_external_token__concat] = true;
|
||||
external_scanner_states_27(v);
|
||||
}
|
||||
|
||||
void external_scanner_states_27(t_external_scanner_states_array *v)
|
||||
{
|
||||
v->a[96][ts_external_token__immediate_double_hash] = true;
|
||||
v->a[96][ts_external_token__external_expansion_sym_hash] = true;
|
||||
v->a[96][ts_external_token__external_expansion_sym_bang] = true;
|
||||
v->a[96][ts_external_token__external_expansion_sym_equal] = true;
|
||||
v->a[96][ts_external_token_RBRACE] = true;
|
||||
v->a[97][ts_external_token__concat] = true;
|
||||
v->a[97][ts_external_token_test_operator] = true;
|
||||
v->a[97][ts_external_token__brace_start] = true;
|
||||
v->a[97][ts_external_token_heredoc_redirect_token1] = true;
|
||||
v->a[98][ts_external_token_variable_name] = true;
|
||||
v->a[98][ts_external_token__external_expansion_sym_hash] = true;
|
||||
v->a[98][ts_external_token__external_expansion_sym_bang] = true;
|
||||
v->a[98][ts_external_token__external_expansion_sym_equal] = true;
|
||||
v->a[98][ts_external_token_RBRACE] = true;
|
||||
v->a[99][ts_external_token_LPAREN] = true;
|
||||
v->a[100][ts_external_token__concat] = true;
|
||||
v->a[100][ts_external_token_test_operator] = true;
|
||||
v->a[100][ts_external_token__brace_start] = true;
|
||||
v->a[101][ts_external_token_file_descriptor] = true;
|
||||
v->a[101][ts_external_token__concat] = true;
|
||||
external_scanner_states_28(v);
|
||||
}
|
||||
|
||||
void external_scanner_states_28(t_external_scanner_states_array *v)
|
||||
{
|
||||
v->a[101][ts_external_token_RBRACK] = true;
|
||||
v->a[101][ts_external_token_LT_LT] = true;
|
||||
v->a[101][ts_external_token_LT_LT_DASH] = true;
|
||||
v->a[102][ts_external_token_file_descriptor] = true;
|
||||
v->a[102][ts_external_token_RBRACK] = true;
|
||||
v->a[102][ts_external_token_LT_LT] = true;
|
||||
v->a[102][ts_external_token_LT_LT_DASH] = true;
|
||||
v->a[103][ts_external_token_file_descriptor] = true;
|
||||
v->a[103][ts_external_token_LT_LT] = true;
|
||||
v->a[103][ts_external_token_LT_LT_DASH] = true;
|
||||
v->a[104][ts_external_token_RBRACE] = true;
|
||||
v->a[104][ts_external_token_heredoc_redirect_token1] = true;
|
||||
v->a[104][ts_external_token_LPAREN] = true;
|
||||
v->a[105][ts_external_token_file_descriptor] = true;
|
||||
v->a[105][ts_external_token__concat] = true;
|
||||
v->a[105][ts_external_token_variable_name] = true;
|
||||
v->a[105][ts_external_token_LT_LT] = true;
|
||||
v->a[105][ts_external_token_LT_LT_DASH] = true;
|
||||
v->a[106][ts_external_token_file_descriptor] = true;
|
||||
v->a[106][ts_external_token__concat] = true;
|
||||
external_scanner_states_29(v);
|
||||
}
|
||||
|
||||
void external_scanner_states_29(t_external_scanner_states_array *v)
|
||||
{
|
||||
v->a[106][ts_external_token_LT_LT] = true;
|
||||
v->a[106][ts_external_token_LT_LT_DASH] = true;
|
||||
v->a[107][ts_external_token_variable_name] = true;
|
||||
v->a[107][ts_external_token__expansion_word] = true;
|
||||
v->a[107][ts_external_token_RBRACE] = true;
|
||||
v->a[107][ts_external_token_LPAREN] = true;
|
||||
v->a[108][ts_external_token_variable_name] = true;
|
||||
v->a[108][ts_external_token__expansion_word] = true;
|
||||
v->a[108][ts_external_token_LPAREN] = true;
|
||||
v->a[109][ts_external_token_variable_name] = true;
|
||||
v->a[109][ts_external_token_heredoc_redirect_token1] = true;
|
||||
v->a[110][ts_external_token_file_descriptor] = true;
|
||||
v->a[110][ts_external_token_heredoc_redirect_token1] = true;
|
||||
v->a[111][ts_external_token_file_descriptor] = true;
|
||||
v->a[111][ts_external_token__concat] = true;
|
||||
v->a[111][ts_external_token_heredoc_redirect_token1] = true;
|
||||
v->a[112][ts_external_token_variable_name] = true;
|
||||
v->a[113][ts_external_token_LT_LT] = true;
|
||||
v->a[113][ts_external_token_LT_LT_DASH] = true;
|
||||
v->a[114][ts_external_token_RBRACE] = true;
|
||||
external_scanner_states_30(v);
|
||||
}
|
||||
|
||||
/* EOF external_scanner_states_5.c */
|
||||
|
|
@ -1,55 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* external_scanner_states_6.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/14 19:17:54 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/04/14 19:18:20 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "./external_scanner_states.h"
|
||||
|
||||
void external_scanner_states_30(t_external_scanner_states_array *v)
|
||||
{
|
||||
v->a[115][ts_external_token__concat] = true;
|
||||
v->a[116][ts_external_token_heredoc_content] = true;
|
||||
v->a[116][ts_external_token_heredoc_end] = true;
|
||||
v->a[117][ts_external_token__regex_no_slash] = true;
|
||||
v->a[117][ts_external_token_RBRACE] = true;
|
||||
v->a[118][ts_external_token__concat] = true;
|
||||
v->a[118][ts_external_token_heredoc_redirect_token1] = true;
|
||||
v->a[119][ts_external_token_regex] = true;
|
||||
v->a[119][ts_external_token_RBRACE] = true;
|
||||
v->a[120][ts_external_token_heredoc_redirect_token1] = true;
|
||||
v->a[121][ts_external_token__concat] = true;
|
||||
v->a[121][ts_external_token__expansion_word] = true;
|
||||
v->a[121][ts_external_token_RBRACE] = true;
|
||||
v->a[122][ts_external_token_simple_heredoc_body] = true;
|
||||
v->a[122][ts_external_token__heredoc_body_beginning] = true;
|
||||
v->a[123][ts_external_token__concat] = true;
|
||||
v->a[123][ts_external_token__external_expansion_sym_hash] = true;
|
||||
v->a[123][ts_external_token__external_expansion_sym_bang] = true;
|
||||
v->a[123][ts_external_token__external_expansion_sym_equal] = true;
|
||||
v->a[123][ts_external_token_RBRACE] = true;
|
||||
external_scanner_states_31(v);
|
||||
}
|
||||
|
||||
void external_scanner_states_31(t_external_scanner_states_array *v)
|
||||
{
|
||||
v->a[124][ts_external_token__concat] = true;
|
||||
v->a[124][ts_external_token_RBRACE] = true;
|
||||
v->a[125][ts_external_token__external_expansion_sym_hash] = true;
|
||||
v->a[125][ts_external_token__external_expansion_sym_bang] = true;
|
||||
v->a[125][ts_external_token__external_expansion_sym_equal] = true;
|
||||
v->a[125][ts_external_token_RBRACE] = true;
|
||||
v->a[126][ts_external_token_esac] = true;
|
||||
v->a[127][ts_external_token_extglob_pattern] = true;
|
||||
v->a[128][ts_external_token_heredoc_end] = true;
|
||||
v->a[129][ts_external_token_RBRACK] = true;
|
||||
v->a[130][ts_external_token_heredoc_start] = true;
|
||||
}
|
||||
|
||||
/* EOF external_scanner_states_6.c */
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* external_scanner_symbol_map.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/14 19:17:54 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/04/14 19:18:20 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef EXTERNAL_SCANNER_SYMBOL_MAP_H
|
||||
# define EXTERNAL_SCANNER_SYMBOL_MAP_H
|
||||
|
||||
# include "../types/type_external_scanner_symbol_map.h"
|
||||
# include "../headers/symbols.h"
|
||||
# include "../headers/external_scanner_symbol_identifiers.h"
|
||||
# include "../headers/field_identifiers.h"
|
||||
|
||||
# include "../headers/constants.h"
|
||||
|
||||
void external_scanner_symbol_map_0(t_external_scanner_symbol_map_array *v);
|
||||
void external_scanner_symbol_map_1(t_external_scanner_symbol_map_array *v);
|
||||
|
||||
#endif // EXTERNAL_SCANNER_SYMBOL_MAP_H
|
||||
|
|
@ -1,59 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* external_scanner_symbol_map_0.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/14 19:17:54 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/04/14 19:18:20 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "./external_scanner_symbol_map.h"
|
||||
|
||||
void external_scanner_symbol_map_0(t_external_scanner_symbol_map_array *v)
|
||||
{
|
||||
v->a[ts_external_token_heredoc_start] = sym_heredoc_start;
|
||||
v->a[ts_external_token_simple_heredoc_body] = sym_simple_heredoc_body;
|
||||
v->a[ts_external_token__heredoc_body_beginning] \
|
||||
= sym__heredoc_body_beginning;
|
||||
v->a[ts_external_token_heredoc_content] = sym_heredoc_content;
|
||||
v->a[ts_external_token_heredoc_end] = sym_heredoc_end;
|
||||
v->a[ts_external_token_file_descriptor] = sym_file_descriptor;
|
||||
v->a[ts_external_token__empty_value] = sym__empty_value;
|
||||
v->a[ts_external_token__concat] = sym__concat;
|
||||
v->a[ts_external_token_variable_name] = sym_variable_name;
|
||||
v->a[ts_external_token_test_operator] = sym_test_operator;
|
||||
v->a[ts_external_token_regex] = sym_regex;
|
||||
v->a[ts_external_token__regex_no_slash] = sym__regex_no_slash;
|
||||
v->a[ts_external_token__regex_no_space] = sym__regex_no_space;
|
||||
v->a[ts_external_token__expansion_word] = sym__expansion_word;
|
||||
v->a[ts_external_token_extglob_pattern] = sym_extglob_pattern;
|
||||
v->a[ts_external_token__bare_dollar] = sym__bare_dollar;
|
||||
v->a[ts_external_token__brace_start] = sym__brace_start;
|
||||
v->a[ts_external_token__immediate_double_hash] \
|
||||
= sym__immediate_double_hash;
|
||||
v->a[ts_external_token__external_expansion_sym_hash] \
|
||||
= sym__external_expansion_sym_hash;
|
||||
v->a[ts_external_token__external_expansion_sym_bang] \
|
||||
= sym__external_expansion_sym_bang;
|
||||
external_scanner_symbol_map_1(v);
|
||||
}
|
||||
|
||||
void external_scanner_symbol_map_1(t_external_scanner_symbol_map_array *v)
|
||||
{
|
||||
v->a[ts_external_token__external_expansion_sym_equal] \
|
||||
= sym__external_expansion_sym_equal;
|
||||
v->a[ts_external_token_RBRACE] = anon_sym_RBRACE3;
|
||||
v->a[ts_external_token_RBRACK] = anon_sym_RBRACK;
|
||||
v->a[ts_external_token_LT_LT] = anon_sym_LT_LT;
|
||||
v->a[ts_external_token_LT_LT_DASH] = anon_sym_LT_LT_DASH;
|
||||
v->a[ts_external_token_heredoc_redirect_token1] \
|
||||
= aux_sym_heredoc_redirect_token1;
|
||||
v->a[ts_external_token_LPAREN] = anon_sym_LPAREN;
|
||||
v->a[ts_external_token_esac] = anon_sym_esac;
|
||||
v->a[ts_external_token___error_recovery] = sym___error_recovery;
|
||||
}
|
||||
|
||||
/* EOF external_scanner_symbol_map_0.c */
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* field_map_entries.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/14 19:17:54 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/04/14 19:18:20 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef FIELD_MAP_ENTRIES_H
|
||||
# define FIELD_MAP_ENTRIES_H
|
||||
|
||||
# include "../types/type_field_map_entries.h"
|
||||
# include "../headers/symbols.h"
|
||||
# include "../headers/external_scanner_symbol_identifiers.h"
|
||||
# include "../headers/field_identifiers.h"
|
||||
|
||||
# include "../headers/constants.h"
|
||||
|
||||
void field_map_entries_0(t_field_map_entries_array *v);
|
||||
void field_map_entries_1(t_field_map_entries_array *v);
|
||||
void field_map_entries_2(t_field_map_entries_array *v);
|
||||
void field_map_entries_3(t_field_map_entries_array *v);
|
||||
void field_map_entries_4(t_field_map_entries_array *v);
|
||||
void field_map_entries_5(t_field_map_entries_array *v);
|
||||
void field_map_entries_6(t_field_map_entries_array *v);
|
||||
void field_map_entries_7(t_field_map_entries_array *v);
|
||||
void field_map_entries_8(t_field_map_entries_array *v);
|
||||
void field_map_entries_9(t_field_map_entries_array *v);
|
||||
void field_map_entries_10(t_field_map_entries_array *v);
|
||||
void field_map_entries_11(t_field_map_entries_array *v);
|
||||
void field_map_entries_12(t_field_map_entries_array *v);
|
||||
void field_map_entries_13(t_field_map_entries_array *v);
|
||||
void field_map_entries_14(t_field_map_entries_array *v);
|
||||
|
||||
#endif // FIELD_MAP_ENTRIES_H
|
||||
|
|
@ -1,140 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* field_map_entries_0.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/14 19:17:54 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/04/14 19:18:20 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "./field_map_entries.h"
|
||||
|
||||
void field_map_entries_0(t_field_map_entries_array *v)
|
||||
{
|
||||
v->a[0] = fmap_entry(field_name, 0, false);
|
||||
v->a[1] = fmap_entry(field_redirect, 0, false);
|
||||
v->a[2] = fmap_entry(field_descriptor, 0, false);
|
||||
v->a[3] = fmap_entry(field_left, 0, true);
|
||||
v->a[4] = fmap_entry(field_operator, 0, true);
|
||||
v->a[5] = fmap_entry(field_right, 0, true);
|
||||
v->a[6] = fmap_entry(field_alternative, 0, true);
|
||||
v->a[7] = fmap_entry(field_condition, 0, true);
|
||||
v->a[8] = fmap_entry(field_consequence, 0, true);
|
||||
v->a[9] = fmap_entry(field_operator, 0, true);
|
||||
v->a[10] = fmap_entry(field_destination, 1, false);
|
||||
v->a[11] = fmap_entry(field_operator, 0, false);
|
||||
v->a[12] = fmap_entry(field_body, 0, false);
|
||||
v->a[13] = fmap_entry(field_redirect, 1, false);
|
||||
v->a[14] = fmap_entry(field_body, 0, false);
|
||||
v->a[15] = fmap_entry(field_argument, 0, false);
|
||||
v->a[16] = fmap_entry(field_argument, 1, true);
|
||||
v->a[17] = fmap_entry(field_name, 0, false);
|
||||
v->a[18] = fmap_entry(field_redirect, 1, true);
|
||||
v->a[19] = fmap_entry(field_name, 1, false);
|
||||
field_map_entries_1(v);
|
||||
}
|
||||
|
||||
void field_map_entries_1(t_field_map_entries_array *v)
|
||||
{
|
||||
v->a[20] = fmap_entry(field_redirect, 0, true);
|
||||
v->a[21] = fmap_entry(field_redirect, 0, true);
|
||||
v->a[22] = fmap_entry(field_redirect, 1, true);
|
||||
v->a[23] = fmap_entry(field_descriptor, 0, false);
|
||||
v->a[24] = fmap_entry(field_destination, 2, false);
|
||||
v->a[25] = fmap_entry(field_name, 0, false);
|
||||
v->a[26] = fmap_entry(field_value, 2, false);
|
||||
v->a[27] = fmap_entry(field_name, 0, true);
|
||||
v->a[28] = fmap_entry(field_value, 0, true);
|
||||
v->a[29] = fmap_entry(field_operator, 1, false);
|
||||
v->a[30] = fmap_entry(field_body, 2, false);
|
||||
v->a[31] = fmap_entry(field_condition, 1, false);
|
||||
v->a[32] = fmap_entry(field_body, 2, false);
|
||||
v->a[33] = fmap_entry(field_name, 1, false);
|
||||
v->a[34] = fmap_entry(field_left, 1, true);
|
||||
v->a[35] = fmap_entry(field_operator, 1, true);
|
||||
v->a[36] = fmap_entry(field_right, 1, true);
|
||||
v->a[37] = fmap_entry(field_operator, 1, true);
|
||||
v->a[38] = fmap_entry(field_operator, 0, true);
|
||||
v->a[39] = fmap_entry(field_operator, 1, true);
|
||||
field_map_entries_2(v);
|
||||
}
|
||||
|
||||
void field_map_entries_2(t_field_map_entries_array *v)
|
||||
{
|
||||
v->a[40] = fmap_entry(field_redirect, 1, false);
|
||||
v->a[41] = fmap_entry(field_argument, 0, false);
|
||||
v->a[42] = fmap_entry(field_argument, 1, false);
|
||||
v->a[43] = fmap_entry(field_argument, 0, true);
|
||||
v->a[44] = fmap_entry(field_argument, 1, true);
|
||||
v->a[45] = fmap_entry(field_redirect, 0, true);
|
||||
v->a[46] = fmap_entry(field_redirect, 1, true);
|
||||
v->a[47] = fmap_entry(field_argument, 2, true);
|
||||
v->a[48] = fmap_entry(field_name, 1, false);
|
||||
v->a[49] = fmap_entry(field_redirect, 0, true);
|
||||
v->a[50] = fmap_entry(field_redirect, 2, true);
|
||||
v->a[51] = fmap_entry(field_index, 2, false);
|
||||
v->a[52] = fmap_entry(field_name, 0, false);
|
||||
v->a[53] = fmap_entry(field_body, 3, false);
|
||||
v->a[54] = fmap_entry(field_variable, 1, false);
|
||||
v->a[55] = fmap_entry(field_left, 0, false);
|
||||
v->a[56] = fmap_entry(field_operator, 1, false);
|
||||
v->a[57] = fmap_entry(field_right, 2, false);
|
||||
v->a[58] = fmap_entry(field_condition, 1, false);
|
||||
v->a[59] = fmap_entry(field_value, 1, false);
|
||||
field_map_entries_3(v);
|
||||
}
|
||||
|
||||
void field_map_entries_3(t_field_map_entries_array *v)
|
||||
{
|
||||
v->a[60] = fmap_entry(field_body, 2, false);
|
||||
v->a[61] = fmap_entry(field_name, 1, false);
|
||||
v->a[62] = fmap_entry(field_redirect, 3, false);
|
||||
v->a[63] = fmap_entry(field_operator, 0, false);
|
||||
v->a[64] = fmap_entry(field_operator, 1, false);
|
||||
v->a[65] = fmap_entry(field_operator, 0, false);
|
||||
v->a[66] = fmap_entry(field_operator, 1, true);
|
||||
v->a[67] = fmap_entry(field_operator, 0, false);
|
||||
v->a[68] = fmap_entry(field_operator, 2, false);
|
||||
v->a[69] = fmap_entry(field_operator, 0, false);
|
||||
v->a[70] = fmap_entry(field_operator, 2, true);
|
||||
v->a[71] = fmap_entry(field_body, 3, false);
|
||||
v->a[72] = fmap_entry(field_name, 0, false);
|
||||
v->a[73] = fmap_entry(field_body, 4, false);
|
||||
v->a[74] = fmap_entry(field_condition, 2, true);
|
||||
v->a[75] = fmap_entry(field_initializer, 2, true);
|
||||
v->a[76] = fmap_entry(field_update, 2, true);
|
||||
v->a[77] = fmap_entry(field_initializer, 0, false);
|
||||
v->a[78] = fmap_entry(field_update, 2, false);
|
||||
v->a[79] = fmap_entry(field_value, 0, false);
|
||||
field_map_entries_4(v);
|
||||
}
|
||||
|
||||
void field_map_entries_4(t_field_map_entries_array *v)
|
||||
{
|
||||
v->a[80] = fmap_entry(field_body, 4, false);
|
||||
v->a[81] = fmap_entry(field_name, 1, false);
|
||||
v->a[82] = fmap_entry(field_operator, 0, false);
|
||||
v->a[83] = fmap_entry(field_operator, 1, false);
|
||||
v->a[84] = fmap_entry(field_operator, 2, true);
|
||||
v->a[85] = fmap_entry(field_operator, 0, false);
|
||||
v->a[86] = fmap_entry(field_operator, 1, true);
|
||||
v->a[87] = fmap_entry(field_operator, 2, false);
|
||||
v->a[88] = fmap_entry(field_body, 3, false);
|
||||
v->a[89] = fmap_entry(field_name, 0, false);
|
||||
v->a[90] = fmap_entry(field_redirect, 4, false);
|
||||
v->a[91] = fmap_entry(field_operator, 0, false);
|
||||
v->a[92] = fmap_entry(field_right, 1, false);
|
||||
v->a[93] = fmap_entry(field_argument, 0, true);
|
||||
v->a[94] = fmap_entry(field_argument, 1, true);
|
||||
v->a[95] = fmap_entry(field_body, 5, false);
|
||||
v->a[96] = fmap_entry(field_condition, 2, true);
|
||||
v->a[97] = fmap_entry(field_initializer, 2, true);
|
||||
v->a[98] = fmap_entry(field_update, 2, true);
|
||||
v->a[99] = fmap_entry(field_condition, 2, false);
|
||||
field_map_entries_5(v);
|
||||
}
|
||||
|
||||
/* EOF field_map_entries_0.c */
|
||||
|
|
@ -1,140 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* field_map_entries_1.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/14 19:17:54 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/04/14 19:18:20 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "./field_map_entries.h"
|
||||
|
||||
void field_map_entries_5(t_field_map_entries_array *v)
|
||||
{
|
||||
v->a[100] = fmap_entry(field_initializer, 0, false);
|
||||
v->a[101] = fmap_entry(field_initializer, 0, false);
|
||||
v->a[102] = fmap_entry(field_update, 3, false);
|
||||
v->a[103] = fmap_entry(field_initializer, 0, false);
|
||||
v->a[104] = fmap_entry(field_initializer, 1, false);
|
||||
v->a[105] = fmap_entry(field_condition, 1, false);
|
||||
v->a[106] = fmap_entry(field_update, 3, false);
|
||||
v->a[107] = fmap_entry(field_condition, 1, false);
|
||||
v->a[108] = fmap_entry(field_condition, 2, false);
|
||||
v->a[109] = fmap_entry(field_update, 2, false);
|
||||
v->a[110] = fmap_entry(field_update, 3, false);
|
||||
v->a[111] = fmap_entry(field_body, 5, false);
|
||||
v->a[112] = fmap_entry(field_value, 3, false);
|
||||
v->a[113] = fmap_entry(field_variable, 1, false);
|
||||
v->a[114] = fmap_entry(field_alternative, 4, false);
|
||||
v->a[115] = fmap_entry(field_condition, 0, false);
|
||||
v->a[116] = fmap_entry(field_consequence, 2, false);
|
||||
v->a[117] = fmap_entry(field_termination, 2, false);
|
||||
v->a[118] = fmap_entry(field_value, 0, false);
|
||||
v->a[119] = fmap_entry(field_fallthrough, 2, false);
|
||||
field_map_entries_6(v);
|
||||
}
|
||||
|
||||
void field_map_entries_6(t_field_map_entries_array *v)
|
||||
{
|
||||
v->a[120] = fmap_entry(field_value, 0, false);
|
||||
v->a[121] = fmap_entry(field_value, 0, false);
|
||||
v->a[122] = fmap_entry(field_value, 1, true);
|
||||
v->a[123] = fmap_entry(field_value, 0, true);
|
||||
v->a[124] = fmap_entry(field_value, 1, true);
|
||||
v->a[125] = fmap_entry(field_body, 4, false);
|
||||
v->a[126] = fmap_entry(field_name, 1, false);
|
||||
v->a[127] = fmap_entry(field_redirect, 5, false);
|
||||
v->a[128] = fmap_entry(field_operator, 0, false);
|
||||
v->a[129] = fmap_entry(field_operator, 1, false);
|
||||
v->a[130] = fmap_entry(field_operator, 3, false);
|
||||
v->a[131] = fmap_entry(field_operator, 0, false);
|
||||
v->a[132] = fmap_entry(field_operator, 3, false);
|
||||
v->a[133] = fmap_entry(field_operator, 0, false);
|
||||
v->a[134] = fmap_entry(field_operator, 2, false);
|
||||
v->a[135] = fmap_entry(field_operator, 3, true);
|
||||
v->a[136] = fmap_entry(field_operator, 0, false);
|
||||
v->a[137] = fmap_entry(field_operator, 1, false);
|
||||
v->a[138] = fmap_entry(field_operator, 3, true);
|
||||
v->a[139] = fmap_entry(field_operator, 0, false);
|
||||
field_map_entries_7(v);
|
||||
}
|
||||
|
||||
void field_map_entries_7(t_field_map_entries_array *v)
|
||||
{
|
||||
v->a[140] = fmap_entry(field_operator, 1, true);
|
||||
v->a[141] = fmap_entry(field_operator, 2, false);
|
||||
v->a[142] = fmap_entry(field_operator, 3, true);
|
||||
v->a[143] = fmap_entry(field_operator, 2, true);
|
||||
v->a[144] = fmap_entry(field_right, 2, true);
|
||||
v->a[145] = fmap_entry(field_argument, 2, true);
|
||||
v->a[146] = fmap_entry(field_redirect, 2, false);
|
||||
v->a[147] = fmap_entry(field_condition, 2, false);
|
||||
v->a[148] = fmap_entry(field_initializer, 0, false);
|
||||
v->a[149] = fmap_entry(field_update, 4, false);
|
||||
v->a[150] = fmap_entry(field_condition, 2, false);
|
||||
v->a[151] = fmap_entry(field_condition, 3, false);
|
||||
v->a[152] = fmap_entry(field_initializer, 0, false);
|
||||
v->a[153] = fmap_entry(field_initializer, 0, false);
|
||||
v->a[154] = fmap_entry(field_update, 3, false);
|
||||
v->a[155] = fmap_entry(field_update, 4, false);
|
||||
v->a[156] = fmap_entry(field_condition, 3, false);
|
||||
v->a[157] = fmap_entry(field_initializer, 0, false);
|
||||
v->a[158] = fmap_entry(field_initializer, 1, false);
|
||||
v->a[159] = fmap_entry(field_initializer, 0, false);
|
||||
field_map_entries_8(v);
|
||||
}
|
||||
|
||||
void field_map_entries_8(t_field_map_entries_array *v)
|
||||
{
|
||||
v->a[160] = fmap_entry(field_initializer, 1, false);
|
||||
v->a[161] = fmap_entry(field_update, 4, false);
|
||||
v->a[162] = fmap_entry(field_condition, 1, false);
|
||||
v->a[163] = fmap_entry(field_update, 3, false);
|
||||
v->a[164] = fmap_entry(field_update, 4, false);
|
||||
v->a[165] = fmap_entry(field_condition, 1, false);
|
||||
v->a[166] = fmap_entry(field_condition, 2, false);
|
||||
v->a[167] = fmap_entry(field_update, 4, false);
|
||||
v->a[168] = fmap_entry(field_termination, 3, false);
|
||||
v->a[169] = fmap_entry(field_value, 0, false);
|
||||
v->a[170] = fmap_entry(field_fallthrough, 3, false);
|
||||
v->a[171] = fmap_entry(field_value, 0, false);
|
||||
v->a[172] = fmap_entry(field_termination, 3, false);
|
||||
v->a[173] = fmap_entry(field_value, 0, false);
|
||||
v->a[174] = fmap_entry(field_value, 1, true);
|
||||
v->a[175] = fmap_entry(field_fallthrough, 3, false);
|
||||
v->a[176] = fmap_entry(field_value, 0, false);
|
||||
v->a[177] = fmap_entry(field_value, 1, true);
|
||||
v->a[178] = fmap_entry(field_termination, 3, false);
|
||||
v->a[179] = fmap_entry(field_value, 1, false);
|
||||
field_map_entries_9(v);
|
||||
}
|
||||
|
||||
void field_map_entries_9(t_field_map_entries_array *v)
|
||||
{
|
||||
v->a[180] = fmap_entry(field_fallthrough, 3, false);
|
||||
v->a[181] = fmap_entry(field_value, 1, false);
|
||||
v->a[182] = fmap_entry(field_value, 1, false);
|
||||
v->a[183] = fmap_entry(field_value, 2, true);
|
||||
v->a[184] = fmap_entry(field_operator, 0, false);
|
||||
v->a[185] = fmap_entry(field_operator, 2, false);
|
||||
v->a[186] = fmap_entry(field_operator, 4, false);
|
||||
v->a[187] = fmap_entry(field_operator, 0, false);
|
||||
v->a[188] = fmap_entry(field_operator, 1, false);
|
||||
v->a[189] = fmap_entry(field_operator, 4, false);
|
||||
v->a[190] = fmap_entry(field_operator, 0, false);
|
||||
v->a[191] = fmap_entry(field_operator, 2, false);
|
||||
v->a[192] = fmap_entry(field_operator, 4, true);
|
||||
v->a[193] = fmap_entry(field_operator, 0, false);
|
||||
v->a[194] = fmap_entry(field_operator, 1, true);
|
||||
v->a[195] = fmap_entry(field_operator, 2, false);
|
||||
v->a[196] = fmap_entry(field_operator, 4, true);
|
||||
v->a[197] = fmap_entry(field_descriptor, 0, false);
|
||||
v->a[198] = fmap_entry(field_operator, 3, true);
|
||||
v->a[199] = fmap_entry(field_right, 3, true);
|
||||
field_map_entries_10(v);
|
||||
}
|
||||
|
||||
/* EOF field_map_entries_1.c */
|
||||
|
|
@ -1,126 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* field_map_entries_2.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/14 19:17:54 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/04/14 19:18:20 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "./field_map_entries.h"
|
||||
|
||||
void field_map_entries_10(t_field_map_entries_array *v)
|
||||
{
|
||||
v->a[200] = fmap_entry(field_argument, 3, true);
|
||||
v->a[201] = fmap_entry(field_descriptor, 0, false);
|
||||
v->a[202] = fmap_entry(field_descriptor, 0, false);
|
||||
v->a[203] = fmap_entry(field_redirect, 3, false);
|
||||
v->a[204] = fmap_entry(field_operator, 3, true);
|
||||
v->a[205] = fmap_entry(field_redirect, 2, false);
|
||||
v->a[206] = fmap_entry(field_right, 3, true);
|
||||
v->a[207] = fmap_entry(field_condition, 2, false);
|
||||
v->a[208] = fmap_entry(field_initializer, 0, false);
|
||||
v->a[209] = fmap_entry(field_update, 4, false);
|
||||
v->a[210] = fmap_entry(field_update, 5, false);
|
||||
v->a[211] = fmap_entry(field_condition, 2, false);
|
||||
v->a[212] = fmap_entry(field_condition, 3, false);
|
||||
v->a[213] = fmap_entry(field_initializer, 0, false);
|
||||
v->a[214] = fmap_entry(field_update, 5, false);
|
||||
v->a[215] = fmap_entry(field_condition, 3, false);
|
||||
v->a[216] = fmap_entry(field_initializer, 0, false);
|
||||
v->a[217] = fmap_entry(field_initializer, 1, false);
|
||||
v->a[218] = fmap_entry(field_update, 5, false);
|
||||
v->a[219] = fmap_entry(field_condition, 3, false);
|
||||
field_map_entries_11(v);
|
||||
}
|
||||
|
||||
void field_map_entries_11(t_field_map_entries_array *v)
|
||||
{
|
||||
v->a[220] = fmap_entry(field_condition, 4, false);
|
||||
v->a[221] = fmap_entry(field_initializer, 0, false);
|
||||
v->a[222] = fmap_entry(field_initializer, 1, false);
|
||||
v->a[223] = fmap_entry(field_initializer, 0, false);
|
||||
v->a[224] = fmap_entry(field_initializer, 1, false);
|
||||
v->a[225] = fmap_entry(field_update, 4, false);
|
||||
v->a[226] = fmap_entry(field_update, 5, false);
|
||||
v->a[227] = fmap_entry(field_condition, 1, false);
|
||||
v->a[228] = fmap_entry(field_condition, 2, false);
|
||||
v->a[229] = fmap_entry(field_update, 4, false);
|
||||
v->a[230] = fmap_entry(field_update, 5, false);
|
||||
v->a[231] = fmap_entry(field_termination, 4, false);
|
||||
v->a[232] = fmap_entry(field_value, 0, false);
|
||||
v->a[233] = fmap_entry(field_value, 1, true);
|
||||
v->a[234] = fmap_entry(field_fallthrough, 4, false);
|
||||
v->a[235] = fmap_entry(field_value, 0, false);
|
||||
v->a[236] = fmap_entry(field_value, 1, true);
|
||||
v->a[237] = fmap_entry(field_termination, 4, false);
|
||||
v->a[238] = fmap_entry(field_value, 1, false);
|
||||
v->a[239] = fmap_entry(field_fallthrough, 4, false);
|
||||
field_map_entries_12(v);
|
||||
}
|
||||
|
||||
void field_map_entries_12(t_field_map_entries_array *v)
|
||||
{
|
||||
v->a[240] = fmap_entry(field_value, 1, false);
|
||||
v->a[241] = fmap_entry(field_termination, 4, false);
|
||||
v->a[242] = fmap_entry(field_value, 1, false);
|
||||
v->a[243] = fmap_entry(field_value, 2, true);
|
||||
v->a[244] = fmap_entry(field_fallthrough, 4, false);
|
||||
v->a[245] = fmap_entry(field_value, 1, false);
|
||||
v->a[246] = fmap_entry(field_value, 2, true);
|
||||
v->a[247] = fmap_entry(field_operator, 0, false);
|
||||
v->a[248] = fmap_entry(field_operator, 2, false);
|
||||
v->a[249] = fmap_entry(field_operator, 5, false);
|
||||
v->a[250] = fmap_entry(field_operator, 0, false);
|
||||
v->a[251] = fmap_entry(field_operator, 3, false);
|
||||
v->a[252] = fmap_entry(field_operator, 5, false);
|
||||
v->a[253] = fmap_entry(field_descriptor, 0, false);
|
||||
v->a[254] = fmap_entry(field_operator, 4, true);
|
||||
v->a[255] = fmap_entry(field_redirect, 3, false);
|
||||
v->a[256] = fmap_entry(field_right, 4, true);
|
||||
v->a[257] = fmap_entry(field_condition, 2, false);
|
||||
v->a[258] = fmap_entry(field_condition, 3, false);
|
||||
v->a[259] = fmap_entry(field_initializer, 0, false);
|
||||
field_map_entries_13(v);
|
||||
}
|
||||
|
||||
void field_map_entries_13(t_field_map_entries_array *v)
|
||||
{
|
||||
v->a[260] = fmap_entry(field_update, 5, false);
|
||||
v->a[261] = fmap_entry(field_update, 6, false);
|
||||
v->a[262] = fmap_entry(field_condition, 3, false);
|
||||
v->a[263] = fmap_entry(field_initializer, 0, false);
|
||||
v->a[264] = fmap_entry(field_initializer, 1, false);
|
||||
v->a[265] = fmap_entry(field_update, 5, false);
|
||||
v->a[266] = fmap_entry(field_update, 6, false);
|
||||
v->a[267] = fmap_entry(field_condition, 3, false);
|
||||
v->a[268] = fmap_entry(field_condition, 4, false);
|
||||
v->a[269] = fmap_entry(field_initializer, 0, false);
|
||||
v->a[270] = fmap_entry(field_initializer, 1, false);
|
||||
v->a[271] = fmap_entry(field_update, 6, false);
|
||||
v->a[272] = fmap_entry(field_termination, 5, false);
|
||||
v->a[273] = fmap_entry(field_value, 1, false);
|
||||
v->a[274] = fmap_entry(field_value, 2, true);
|
||||
v->a[275] = fmap_entry(field_fallthrough, 5, false);
|
||||
v->a[276] = fmap_entry(field_value, 1, false);
|
||||
v->a[277] = fmap_entry(field_value, 2, true);
|
||||
v->a[278] = fmap_entry(field_operator, 0, false);
|
||||
v->a[279] = fmap_entry(field_operator, 3, false);
|
||||
field_map_entries_14(v);
|
||||
}
|
||||
|
||||
void field_map_entries_14(t_field_map_entries_array *v)
|
||||
{
|
||||
v->a[280] = fmap_entry(field_operator, 6, false);
|
||||
v->a[281] = fmap_entry(field_condition, 3, false);
|
||||
v->a[282] = fmap_entry(field_condition, 4, false);
|
||||
v->a[283] = fmap_entry(field_initializer, 0, false);
|
||||
v->a[284] = fmap_entry(field_initializer, 1, false);
|
||||
v->a[285] = fmap_entry(field_update, 6, false);
|
||||
v->a[286] = fmap_entry(field_update, 7, false);
|
||||
}
|
||||
|
||||
/* EOF field_map_entries_2.c */
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* field_map_slices.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/14 19:17:54 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/04/14 19:18:20 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef FIELD_MAP_SLICES_H
|
||||
# define FIELD_MAP_SLICES_H
|
||||
|
||||
# include "../types/type_field_map_slices.h"
|
||||
# include "../headers/symbols.h"
|
||||
# include "../headers/external_scanner_symbol_identifiers.h"
|
||||
# include "../headers/field_identifiers.h"
|
||||
|
||||
# include "../headers/constants.h"
|
||||
|
||||
void field_map_slices_0(t_field_map_slices_array *v);
|
||||
void field_map_slices_1(t_field_map_slices_array *v);
|
||||
void field_map_slices_2(t_field_map_slices_array *v);
|
||||
void field_map_slices_3(t_field_map_slices_array *v);
|
||||
void field_map_slices_4(t_field_map_slices_array *v);
|
||||
void field_map_slices_5(t_field_map_slices_array *v);
|
||||
void field_map_slices_6(t_field_map_slices_array *v);
|
||||
void field_map_slices_7(t_field_map_slices_array *v);
|
||||
|
||||
#endif // FIELD_MAP_SLICES_H
|
||||
|
|
@ -1,140 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* field_map_slices_0.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/14 19:17:54 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/04/14 19:18:20 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "./field_map_slices.h"
|
||||
|
||||
void field_map_slices_0(t_field_map_slices_array *v)
|
||||
{
|
||||
v->a[2] = fmap_slice(0, 1);
|
||||
v->a[3] = fmap_slice(1, 1);
|
||||
v->a[4] = fmap_slice(2, 1);
|
||||
v->a[5] = fmap_slice(3, 3);
|
||||
v->a[6] = fmap_slice(6, 3);
|
||||
v->a[7] = fmap_slice(9, 1);
|
||||
v->a[8] = fmap_slice(10, 1);
|
||||
v->a[9] = fmap_slice(10, 1);
|
||||
v->a[12] = fmap_slice(11, 1);
|
||||
v->a[14] = fmap_slice(12, 2);
|
||||
v->a[15] = fmap_slice(14, 1);
|
||||
v->a[16] = fmap_slice(15, 1);
|
||||
v->a[17] = fmap_slice(15, 1);
|
||||
v->a[18] = fmap_slice(16, 3);
|
||||
v->a[19] = fmap_slice(19, 2);
|
||||
v->a[20] = fmap_slice(21, 2);
|
||||
v->a[21] = fmap_slice(23, 2);
|
||||
v->a[22] = fmap_slice(23, 2);
|
||||
v->a[23] = fmap_slice(2, 1);
|
||||
v->a[24] = fmap_slice(25, 2);
|
||||
field_map_slices_1(v);
|
||||
}
|
||||
|
||||
void field_map_slices_1(t_field_map_slices_array *v)
|
||||
{
|
||||
v->a[25] = fmap_slice(25, 2);
|
||||
v->a[26] = fmap_slice(27, 2);
|
||||
v->a[27] = fmap_slice(29, 1);
|
||||
v->a[28] = fmap_slice(30, 2);
|
||||
v->a[29] = fmap_slice(32, 2);
|
||||
v->a[30] = fmap_slice(34, 3);
|
||||
v->a[31] = fmap_slice(37, 1);
|
||||
v->a[32] = fmap_slice(37, 1);
|
||||
v->a[33] = fmap_slice(11, 1);
|
||||
v->a[34] = fmap_slice(38, 2);
|
||||
v->a[35] = fmap_slice(40, 1);
|
||||
v->a[36] = fmap_slice(41, 2);
|
||||
v->a[37] = fmap_slice(41, 2);
|
||||
v->a[38] = fmap_slice(43, 4);
|
||||
v->a[39] = fmap_slice(47, 4);
|
||||
v->a[40] = fmap_slice(51, 2);
|
||||
v->a[41] = fmap_slice(51, 2);
|
||||
v->a[42] = fmap_slice(53, 2);
|
||||
v->a[43] = fmap_slice(55, 3);
|
||||
v->a[44] = fmap_slice(58, 1);
|
||||
field_map_slices_2(v);
|
||||
}
|
||||
|
||||
void field_map_slices_2(t_field_map_slices_array *v)
|
||||
{
|
||||
v->a[45] = fmap_slice(59, 1);
|
||||
v->a[46] = fmap_slice(59, 1);
|
||||
v->a[47] = fmap_slice(60, 3);
|
||||
v->a[49] = fmap_slice(63, 2);
|
||||
v->a[50] = fmap_slice(65, 2);
|
||||
v->a[51] = fmap_slice(67, 2);
|
||||
v->a[52] = fmap_slice(69, 2);
|
||||
v->a[53] = fmap_slice(69, 2);
|
||||
v->a[54] = fmap_slice(71, 2);
|
||||
v->a[55] = fmap_slice(25, 2);
|
||||
v->a[56] = fmap_slice(73, 4);
|
||||
v->a[57] = fmap_slice(77, 1);
|
||||
v->a[58] = fmap_slice(78, 1);
|
||||
v->a[59] = fmap_slice(79, 1);
|
||||
v->a[60] = fmap_slice(79, 1);
|
||||
v->a[61] = fmap_slice(80, 2);
|
||||
v->a[62] = fmap_slice(63, 2);
|
||||
v->a[63] = fmap_slice(82, 3);
|
||||
v->a[64] = fmap_slice(85, 3);
|
||||
v->a[65] = fmap_slice(88, 3);
|
||||
field_map_slices_3(v);
|
||||
}
|
||||
|
||||
void field_map_slices_3(t_field_map_slices_array *v)
|
||||
{
|
||||
v->a[66] = fmap_slice(91, 2);
|
||||
v->a[67] = fmap_slice(93, 2);
|
||||
v->a[68] = fmap_slice(95, 4);
|
||||
v->a[69] = fmap_slice(99, 2);
|
||||
v->a[70] = fmap_slice(101, 2);
|
||||
v->a[71] = fmap_slice(103, 2);
|
||||
v->a[72] = fmap_slice(105, 2);
|
||||
v->a[73] = fmap_slice(107, 2);
|
||||
v->a[74] = fmap_slice(109, 2);
|
||||
v->a[75] = fmap_slice(111, 3);
|
||||
v->a[76] = fmap_slice(114, 3);
|
||||
v->a[77] = fmap_slice(117, 2);
|
||||
v->a[78] = fmap_slice(119, 2);
|
||||
v->a[79] = fmap_slice(121, 2);
|
||||
v->a[80] = fmap_slice(123, 2);
|
||||
v->a[81] = fmap_slice(117, 2);
|
||||
v->a[82] = fmap_slice(119, 2);
|
||||
v->a[83] = fmap_slice(121, 2);
|
||||
v->a[84] = fmap_slice(125, 3);
|
||||
v->a[85] = fmap_slice(67, 2);
|
||||
field_map_slices_4(v);
|
||||
}
|
||||
|
||||
void field_map_slices_4(t_field_map_slices_array *v)
|
||||
{
|
||||
v->a[86] = fmap_slice(128, 3);
|
||||
v->a[87] = fmap_slice(128, 3);
|
||||
v->a[88] = fmap_slice(63, 2);
|
||||
v->a[89] = fmap_slice(131, 2);
|
||||
v->a[90] = fmap_slice(133, 3);
|
||||
v->a[91] = fmap_slice(136, 3);
|
||||
v->a[92] = fmap_slice(139, 4);
|
||||
v->a[93] = fmap_slice(143, 2);
|
||||
v->a[94] = fmap_slice(145, 1);
|
||||
v->a[95] = fmap_slice(146, 1);
|
||||
v->a[96] = fmap_slice(147, 3);
|
||||
v->a[97] = fmap_slice(150, 3);
|
||||
v->a[98] = fmap_slice(153, 3);
|
||||
v->a[99] = fmap_slice(156, 3);
|
||||
v->a[100] = fmap_slice(159, 3);
|
||||
v->a[101] = fmap_slice(162, 3);
|
||||
v->a[102] = fmap_slice(165, 3);
|
||||
v->a[103] = fmap_slice(168, 2);
|
||||
v->a[104] = fmap_slice(170, 2);
|
||||
v->a[105] = fmap_slice(172, 3);
|
||||
field_map_slices_5(v);
|
||||
}
|
||||
|
||||
/* EOF field_map_slices_0.c */
|
||||
|
|
@ -1,82 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* field_map_slices_1.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/14 19:17:54 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/04/14 19:18:20 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "./field_map_slices.h"
|
||||
|
||||
void field_map_slices_5(t_field_map_slices_array *v)
|
||||
{
|
||||
v->a[106] = fmap_slice(175, 3);
|
||||
v->a[107] = fmap_slice(178, 2);
|
||||
v->a[108] = fmap_slice(180, 2);
|
||||
v->a[109] = fmap_slice(182, 2);
|
||||
v->a[110] = fmap_slice(178, 2);
|
||||
v->a[111] = fmap_slice(180, 2);
|
||||
v->a[112] = fmap_slice(182, 2);
|
||||
v->a[113] = fmap_slice(168, 2);
|
||||
v->a[114] = fmap_slice(170, 2);
|
||||
v->a[115] = fmap_slice(172, 3);
|
||||
v->a[116] = fmap_slice(175, 3);
|
||||
v->a[117] = fmap_slice(184, 3);
|
||||
v->a[118] = fmap_slice(184, 3);
|
||||
v->a[119] = fmap_slice(67, 2);
|
||||
v->a[120] = fmap_slice(187, 3);
|
||||
v->a[121] = fmap_slice(131, 2);
|
||||
v->a[122] = fmap_slice(190, 3);
|
||||
v->a[123] = fmap_slice(193, 4);
|
||||
v->a[124] = fmap_slice(197, 3);
|
||||
v->a[125] = fmap_slice(200, 2);
|
||||
field_map_slices_6(v);
|
||||
}
|
||||
|
||||
void field_map_slices_6(t_field_map_slices_array *v)
|
||||
{
|
||||
v->a[126] = fmap_slice(202, 2);
|
||||
v->a[127] = fmap_slice(204, 3);
|
||||
v->a[128] = fmap_slice(207, 4);
|
||||
v->a[129] = fmap_slice(211, 4);
|
||||
v->a[130] = fmap_slice(215, 4);
|
||||
v->a[131] = fmap_slice(219, 4);
|
||||
v->a[132] = fmap_slice(223, 4);
|
||||
v->a[133] = fmap_slice(227, 4);
|
||||
v->a[134] = fmap_slice(231, 3);
|
||||
v->a[135] = fmap_slice(234, 3);
|
||||
v->a[136] = fmap_slice(237, 2);
|
||||
v->a[137] = fmap_slice(239, 2);
|
||||
v->a[138] = fmap_slice(241, 3);
|
||||
v->a[139] = fmap_slice(244, 3);
|
||||
v->a[140] = fmap_slice(237, 2);
|
||||
v->a[141] = fmap_slice(239, 2);
|
||||
v->a[142] = fmap_slice(241, 3);
|
||||
v->a[143] = fmap_slice(244, 3);
|
||||
v->a[144] = fmap_slice(231, 3);
|
||||
v->a[145] = fmap_slice(234, 3);
|
||||
field_map_slices_7(v);
|
||||
}
|
||||
|
||||
void field_map_slices_7(t_field_map_slices_array *v)
|
||||
{
|
||||
v->a[146] = fmap_slice(247, 3);
|
||||
v->a[147] = fmap_slice(250, 3);
|
||||
v->a[148] = fmap_slice(250, 3);
|
||||
v->a[149] = fmap_slice(253, 4);
|
||||
v->a[150] = fmap_slice(257, 5);
|
||||
v->a[151] = fmap_slice(262, 5);
|
||||
v->a[152] = fmap_slice(267, 5);
|
||||
v->a[153] = fmap_slice(272, 3);
|
||||
v->a[154] = fmap_slice(275, 3);
|
||||
v->a[155] = fmap_slice(272, 3);
|
||||
v->a[156] = fmap_slice(275, 3);
|
||||
v->a[157] = fmap_slice(278, 3);
|
||||
v->a[158] = fmap_slice(281, 6);
|
||||
}
|
||||
|
||||
/* EOF field_map_slices_1.c */
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* field_names.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/14 19:17:54 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/04/14 19:18:20 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef FIELD_NAMES_H
|
||||
# define FIELD_NAMES_H
|
||||
|
||||
# include "../types/type_field_names.h"
|
||||
# include "../headers/symbols.h"
|
||||
# include "../headers/external_scanner_symbol_identifiers.h"
|
||||
# include "../headers/field_identifiers.h"
|
||||
|
||||
# include "../headers/constants.h"
|
||||
|
||||
void field_names_0(t_field_names_array *v);
|
||||
|
||||
#endif // FIELD_NAMES_H
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* field_names_0.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/14 19:17:54 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/04/14 19:18:20 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "./field_names.h"
|
||||
|
||||
void field_names_0(t_field_names_array *v)
|
||||
{
|
||||
v->a[field_alternative] = "alternative";
|
||||
v->a[field_argument] = "argument";
|
||||
v->a[field_body] = "body";
|
||||
v->a[field_condition] = "condition";
|
||||
v->a[field_consequence] = "consequence";
|
||||
v->a[field_descriptor] = "descriptor";
|
||||
v->a[field_destination] = "destination";
|
||||
v->a[field_fallthrough] = "fallthrough";
|
||||
v->a[field_index] = "index";
|
||||
v->a[field_initializer] = "initializer";
|
||||
v->a[field_left] = "left";
|
||||
v->a[field_name] = "name";
|
||||
v->a[field_operator] = "operator";
|
||||
v->a[field_redirect] = "redirect";
|
||||
v->a[field_right] = "right";
|
||||
v->a[field_termination] = "termination";
|
||||
v->a[field_update] = "update";
|
||||
v->a[field_value] = "value";
|
||||
v->a[field_variable] = "variable";
|
||||
}
|
||||
|
||||
/* EOF field_names_0.c */
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* constants.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/14 19:17:54 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/04/14 19:18:20 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef CONSTANTS_H
|
||||
# define CONSTANTS_H
|
||||
|
||||
# define LANGUAGE_VERSION 14
|
||||
# define STATE_COUNT 7671
|
||||
# define LARGE_STATE_COUNT 528
|
||||
# define SYMBOL_COUNT 280
|
||||
# define ALIAS_COUNT 0
|
||||
# define TOKEN_COUNT 175
|
||||
# define EXTERNAL_TOKEN_COUNT 29
|
||||
# define FIELD_COUNT 19
|
||||
# define MAX_ALIAS_SEQUENCE_LENGTH 8
|
||||
# define PRODUCTION_ID_COUNT 159
|
||||
|
||||
#endif // CONSTANTS_H
|
||||
|
|
@ -1,48 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* external_scanner_symbol_identifiers.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/14 19:17:54 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/04/14 19:18:20 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef EXTERNAL_SCANNER_SYMBOL_IDENTIFIERS_H
|
||||
# define EXTERNAL_SCANNER_SYMBOL_IDENTIFIERS_H
|
||||
|
||||
enum e_external_scanner_symbol_identifiers {
|
||||
ts_external_token_heredoc_start = 0,
|
||||
ts_external_token_simple_heredoc_body = 1,
|
||||
ts_external_token__heredoc_body_beginning = 2,
|
||||
ts_external_token_heredoc_content = 3,
|
||||
ts_external_token_heredoc_end = 4,
|
||||
ts_external_token_file_descriptor = 5,
|
||||
ts_external_token__empty_value = 6,
|
||||
ts_external_token__concat = 7,
|
||||
ts_external_token_variable_name = 8,
|
||||
ts_external_token_test_operator = 9,
|
||||
ts_external_token_regex = 10,
|
||||
ts_external_token__regex_no_slash = 11,
|
||||
ts_external_token__regex_no_space = 12,
|
||||
ts_external_token__expansion_word = 13,
|
||||
ts_external_token_extglob_pattern = 14,
|
||||
ts_external_token__bare_dollar = 15,
|
||||
ts_external_token__brace_start = 16,
|
||||
ts_external_token__immediate_double_hash = 17,
|
||||
ts_external_token__external_expansion_sym_hash = 18,
|
||||
ts_external_token__external_expansion_sym_bang = 19,
|
||||
ts_external_token__external_expansion_sym_equal = 20,
|
||||
ts_external_token_RBRACE = 21,
|
||||
ts_external_token_RBRACK = 22,
|
||||
ts_external_token_LT_LT = 23,
|
||||
ts_external_token_LT_LT_DASH = 24,
|
||||
ts_external_token_heredoc_redirect_token1 = 25,
|
||||
ts_external_token_LPAREN = 26,
|
||||
ts_external_token_esac = 27,
|
||||
ts_external_token___error_recovery = 28,
|
||||
};
|
||||
|
||||
#endif // EXTERNAL_SCANNER_SYMBOL_IDENTIFIERS_H
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* field_identifiers.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/14 19:17:54 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/04/14 19:18:20 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef FIELD_IDENTIFIERS_H
|
||||
# define FIELD_IDENTIFIERS_H
|
||||
|
||||
enum e_field_identifiers {
|
||||
field_alternative = 1,
|
||||
field_argument = 2,
|
||||
field_body = 3,
|
||||
field_condition = 4,
|
||||
field_consequence = 5,
|
||||
field_descriptor = 6,
|
||||
field_destination = 7,
|
||||
field_fallthrough = 8,
|
||||
field_index = 9,
|
||||
field_initializer = 10,
|
||||
field_left = 11,
|
||||
field_name = 12,
|
||||
field_operator = 13,
|
||||
field_redirect = 14,
|
||||
field_right = 15,
|
||||
field_termination = 16,
|
||||
field_update = 17,
|
||||
field_value = 18,
|
||||
field_variable = 19,
|
||||
};
|
||||
|
||||
#endif // FIELD_IDENTIFIERS_H
|
||||
|
|
@ -1,298 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* symbols.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/14 19:17:54 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/04/14 19:18:20 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef SYMBOLS_H
|
||||
# define SYMBOLS_H
|
||||
|
||||
enum e_symbols {
|
||||
sym_word = 1,
|
||||
anon_sym_for = 2,
|
||||
anon_sym_select = 3,
|
||||
anon_sym_in = 4,
|
||||
anon_sym_LPAREN_LPAREN = 5,
|
||||
anon_sym_RPAREN_RPAREN = 6,
|
||||
anon_sym_SEMI = 7,
|
||||
anon_sym_COMMA = 8,
|
||||
anon_sym_EQ = 9,
|
||||
anon_sym_PLUS_PLUS = 10,
|
||||
anon_sym_DASH_DASH = 11,
|
||||
anon_sym_PLUS_EQ = 12,
|
||||
anon_sym_DASH_EQ = 13,
|
||||
anon_sym_STAR_EQ = 14,
|
||||
anon_sym_SLASH_EQ = 15,
|
||||
anon_sym_PERCENT_EQ = 16,
|
||||
anon_sym_STAR_STAR_EQ = 17,
|
||||
anon_sym_LT_LT_EQ = 18,
|
||||
anon_sym_GT_GT_EQ = 19,
|
||||
anon_sym_AMP_EQ = 20,
|
||||
anon_sym_CARET_EQ = 21,
|
||||
anon_sym_PIPE_EQ = 22,
|
||||
anon_sym_PIPE_PIPE = 23,
|
||||
anon_sym_DASHo = 24,
|
||||
anon_sym_AMP_AMP = 25,
|
||||
anon_sym_DASHa = 26,
|
||||
anon_sym_PIPE = 27,
|
||||
anon_sym_CARET = 28,
|
||||
anon_sym_AMP = 29,
|
||||
anon_sym_EQ_EQ = 30,
|
||||
anon_sym_BANG_EQ = 31,
|
||||
anon_sym_LT = 32,
|
||||
anon_sym_GT = 33,
|
||||
anon_sym_LT_EQ = 34,
|
||||
anon_sym_GT_EQ = 35,
|
||||
anon_sym_LT_LT = 36,
|
||||
anon_sym_GT_GT = 37,
|
||||
anon_sym_PLUS = 38,
|
||||
anon_sym_DASH = 39,
|
||||
anon_sym_STAR = 40,
|
||||
anon_sym_SLASH = 41,
|
||||
anon_sym_PERCENT = 42,
|
||||
anon_sym_STAR_STAR = 43,
|
||||
anon_sym_LPAREN = 44,
|
||||
anon_sym_RPAREN = 45,
|
||||
aux_sym__c_word_token1 = 46,
|
||||
anon_sym_while = 47,
|
||||
anon_sym_until = 48,
|
||||
anon_sym_do = 49,
|
||||
anon_sym_done = 50,
|
||||
anon_sym_if = 51,
|
||||
anon_sym_then = 52,
|
||||
anon_sym_fi = 53,
|
||||
anon_sym_elif = 54,
|
||||
anon_sym_else = 55,
|
||||
anon_sym_case = 56,
|
||||
anon_sym_esac = 57,
|
||||
anon_sym_SEMI_SEMI = 58,
|
||||
anon_sym_SEMI_AMP = 59,
|
||||
anon_sym_SEMI_SEMI_AMP = 60,
|
||||
anon_sym_function = 61,
|
||||
anon_sym_LBRACE = 62,
|
||||
anon_sym_RBRACE = 63,
|
||||
anon_sym_PIPE_AMP = 64,
|
||||
anon_sym_BANG = 65,
|
||||
anon_sym_LBRACK = 66,
|
||||
anon_sym_RBRACK = 67,
|
||||
anon_sym_LBRACK_LBRACK = 68,
|
||||
anon_sym_RBRACK_RBRACK = 69,
|
||||
anon_sym_declare = 70,
|
||||
anon_sym_typeset = 71,
|
||||
anon_sym_export = 72,
|
||||
anon_sym_readonly = 73,
|
||||
anon_sym_local = 74,
|
||||
anon_sym_unset = 75,
|
||||
anon_sym_unsetenv = 76,
|
||||
anon_sym_EQ_TILDE = 77,
|
||||
anon_sym_AMP_GT = 78,
|
||||
anon_sym_AMP_GT_GT = 79,
|
||||
anon_sym_LT_AMP = 80,
|
||||
anon_sym_GT_AMP = 81,
|
||||
anon_sym_GT_PIPE = 82,
|
||||
anon_sym_LT_AMP_DASH = 83,
|
||||
anon_sym_GT_AMP_DASH = 84,
|
||||
anon_sym_LT_LT_DASH = 85,
|
||||
aux_sym_heredoc_redirect_token1 = 86,
|
||||
anon_sym_LT_LT_LT = 87,
|
||||
anon_sym_QMARK = 88,
|
||||
anon_sym_COLON = 89,
|
||||
anon_sym_PLUS_PLUS2 = 90,
|
||||
anon_sym_DASH_DASH2 = 91,
|
||||
anon_sym_DASH2 = 92,
|
||||
anon_sym_PLUS2 = 93,
|
||||
anon_sym_TILDE = 94,
|
||||
anon_sym_DOLLAR_LPAREN_LPAREN = 95,
|
||||
anon_sym_DOLLAR_LBRACK = 96,
|
||||
aux_sym_brace_expression_token1 = 97,
|
||||
anon_sym_DOT_DOT = 98,
|
||||
anon_sym_RBRACE2 = 99,
|
||||
aux_sym_concatenation_token1 = 100,
|
||||
anon_sym_DOLLAR = 101,
|
||||
sym__special_character = 102,
|
||||
anon_sym_DQUOTE = 103,
|
||||
sym_string_content = 104,
|
||||
sym_raw_string = 105,
|
||||
sym_ansi_c_string = 106,
|
||||
aux_sym_number_token1 = 107,
|
||||
aux_sym_number_token2 = 108,
|
||||
anon_sym_POUND = 109,
|
||||
anon_sym_DOLLAR_LBRACE = 110,
|
||||
anon_sym_RBRACE3 = 111,
|
||||
anon_sym_BANG2 = 112,
|
||||
anon_sym_AT = 113,
|
||||
anon_sym_STAR2 = 114,
|
||||
anon_sym_POUND2 = 115,
|
||||
anon_sym_EQ2 = 116,
|
||||
anon_sym_COLON_EQ = 117,
|
||||
anon_sym_DASH3 = 118,
|
||||
anon_sym_COLON_DASH = 119,
|
||||
anon_sym_PLUS3 = 120,
|
||||
anon_sym_COLON_PLUS = 121,
|
||||
anon_sym_QMARK2 = 122,
|
||||
anon_sym_COLON_QMARK = 123,
|
||||
anon_sym_PERCENT_PERCENT = 124,
|
||||
aux_sym__expansion_regex_token1 = 125,
|
||||
anon_sym_SLASH_SLASH = 126,
|
||||
anon_sym_SLASH_POUND = 127,
|
||||
anon_sym_SLASH_PERCENT = 128,
|
||||
anon_sym_COMMA_COMMA = 129,
|
||||
anon_sym_CARET_CARET = 130,
|
||||
anon_sym_U = 131,
|
||||
anon_sym_u = 132,
|
||||
anon_sym_L = 133,
|
||||
anon_sym_Q = 134,
|
||||
anon_sym_E = 135,
|
||||
anon_sym_P = 136,
|
||||
anon_sym_A = 137,
|
||||
anon_sym_K = 138,
|
||||
anon_sym_a = 139,
|
||||
anon_sym_k = 140,
|
||||
anon_sym_DOLLAR_LPAREN = 141,
|
||||
anon_sym_BQUOTE = 142,
|
||||
anon_sym_DOLLAR_BQUOTE = 143,
|
||||
anon_sym_LT_LPAREN = 144,
|
||||
anon_sym_GT_LPAREN = 145,
|
||||
sym_comment = 146,
|
||||
sym__comment_word = 147,
|
||||
aux_sym__simple_variable_name_token1 = 148,
|
||||
aux_sym__multiline_variable_name_token1 = 149,
|
||||
anon_sym_AT2 = 150,
|
||||
anon_sym_0 = 151,
|
||||
anon_sym__ = 152,
|
||||
sym_heredoc_start = 153,
|
||||
sym_simple_heredoc_body = 154,
|
||||
sym__heredoc_body_beginning = 155,
|
||||
sym_heredoc_content = 156,
|
||||
sym_heredoc_end = 157,
|
||||
sym_file_descriptor = 158,
|
||||
sym__empty_value = 159,
|
||||
sym__concat = 160,
|
||||
sym_variable_name = 161,
|
||||
sym_test_operator = 162,
|
||||
sym_regex = 163,
|
||||
sym__regex_no_slash = 164,
|
||||
sym__regex_no_space = 165,
|
||||
sym__expansion_word = 166,
|
||||
sym_extglob_pattern = 167,
|
||||
sym__bare_dollar = 168,
|
||||
sym__brace_start = 169,
|
||||
sym__immediate_double_hash = 170,
|
||||
sym__external_expansion_sym_hash = 171,
|
||||
sym__external_expansion_sym_bang = 172,
|
||||
sym__external_expansion_sym_equal = 173,
|
||||
sym___error_recovery = 174,
|
||||
sym_program = 175,
|
||||
sym__statements = 176,
|
||||
aux_sym__terminated_statement = 177,
|
||||
sym__statement_not_pipeline = 178,
|
||||
sym_redirected_statement = 179,
|
||||
sym_for_statement = 180,
|
||||
sym_c_style_for_statement = 181,
|
||||
sym__for_body = 182,
|
||||
sym__c_expression = 183,
|
||||
sym__c_expression_not_assignment = 184,
|
||||
sym__c_variable_assignment = 185,
|
||||
sym__c_unary_expression = 186,
|
||||
sym__c_binary_expression = 187,
|
||||
sym__c_postfix_expression = 188,
|
||||
sym__c_parenthesized_expression = 189,
|
||||
sym_while_statement = 190,
|
||||
sym_do_group = 191,
|
||||
sym_if_statement = 192,
|
||||
sym_elif_clause = 193,
|
||||
sym_else_clause = 194,
|
||||
sym_case_statement = 195,
|
||||
sym_case_item = 196,
|
||||
sym_last_case_item = 197,
|
||||
sym_function_definition = 198,
|
||||
sym_compound_statement = 199,
|
||||
sym_subshell = 200,
|
||||
sym_pipeline = 201,
|
||||
sym_list = 202,
|
||||
sym_negated_command = 203,
|
||||
sym_test_command = 204,
|
||||
sym__test_command_binary_expression = 205,
|
||||
sym_declaration_command = 206,
|
||||
sym_unset_command = 207,
|
||||
sym_command = 208,
|
||||
sym_command_name = 209,
|
||||
sym_variable_assignment = 210,
|
||||
sym_variable_assignments = 211,
|
||||
sym_subscript = 212,
|
||||
sym_file_redirect = 213,
|
||||
sym_heredoc_redirect = 214,
|
||||
sym__heredoc_pipeline = 215,
|
||||
sym__heredoc_expression = 216,
|
||||
aux_sym__heredoc_command = 217,
|
||||
sym__heredoc_body = 218,
|
||||
sym_heredoc_body = 219,
|
||||
sym__simple_heredoc_body = 220,
|
||||
sym_herestring_redirect = 221,
|
||||
sym__expression = 222,
|
||||
sym_binary_expression = 223,
|
||||
sym_ternary_expression = 224,
|
||||
sym_unary_expression = 225,
|
||||
sym_postfix_expression = 226,
|
||||
sym_parenthesized_expression = 227,
|
||||
sym_arithmetic_expansion = 228,
|
||||
sym_brace_expression = 229,
|
||||
sym__arithmetic_expression = 230,
|
||||
sym__arithmetic_literal = 231,
|
||||
sym__arithmetic_binary_expression = 232,
|
||||
sym__arithmetic_ternary_expression = 233,
|
||||
sym__arithmetic_unary_expression = 234,
|
||||
sym__arithmetic_postfix_expression = 235,
|
||||
sym__arithmetic_parenthesized_expression = 236,
|
||||
sym_concatenation = 237,
|
||||
sym_string = 238,
|
||||
sym_translated_string = 239,
|
||||
sym_array = 240,
|
||||
sym_number = 241,
|
||||
sym_simple_expansion = 242,
|
||||
sym_expansion = 243,
|
||||
sym__expansion_body = 244,
|
||||
sym__expansion_expression = 245,
|
||||
sym__expansion_regex = 246,
|
||||
sym__expansion_regex_replacement = 247,
|
||||
sym__expansion_regex_removal = 248,
|
||||
sym__expansion_max_length = 249,
|
||||
sym__expansion_max_length_expression = 250,
|
||||
sym__expansion_max_length_binary_expression = 251,
|
||||
sym__expansion_operator = 252,
|
||||
sym__concatenation_in_expansion = 253,
|
||||
sym_command_substitution = 254,
|
||||
sym_process_substitution = 255,
|
||||
sym__extglob_blob = 256,
|
||||
sym__c_terminator = 257,
|
||||
aux_sym__statements_repeat1 = 258,
|
||||
aux_sym_redirected_statement_repeat1 = 259,
|
||||
aux_sym_redirected_statement_repeat2 = 260,
|
||||
aux_sym_for_statement_repeat1 = 261,
|
||||
aux_sym__for_body_repeat1 = 262,
|
||||
aux_sym_if_statement_repeat1 = 263,
|
||||
aux_sym_case_statement_repeat1 = 264,
|
||||
aux_sym_case_item_repeat1 = 265,
|
||||
aux_sym_pipeline_repeat1 = 266,
|
||||
aux_sym_declaration_command_repeat1 = 267,
|
||||
aux_sym_unset_command_repeat1 = 268,
|
||||
aux_sym_command_repeat1 = 269,
|
||||
aux_sym_command_repeat2 = 270,
|
||||
aux_sym_variable_assignments_repeat1 = 271,
|
||||
aux_sym_heredoc_body_repeat1 = 272,
|
||||
aux_sym__literal_repeat1 = 273,
|
||||
aux_sym_arithmetic_expansion_repeat1 = 274,
|
||||
aux_sym_concatenation_repeat1 = 275,
|
||||
aux_sym_string_repeat1 = 276,
|
||||
aux_sym__expansion_body_repeat1 = 277,
|
||||
aux_sym__expansion_regex_repeat1 = 278,
|
||||
aux_sym__concatenation_in_expansion_repeat1 = 279,
|
||||
};
|
||||
|
||||
#endif // SYMBOLS_H
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* lex_keywords_array.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/14 19:17:54 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/04/14 19:18:20 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef LEX_KEYWORDS_ARRAY_H
|
||||
# define LEX_KEYWORDS_ARRAY_H
|
||||
|
||||
# include "../../../types/type_lex_keywords.h"
|
||||
# include "../../../headers/symbols.h"
|
||||
# include "../../../headers/external_scanner_symbol_identifiers.h"
|
||||
# include "../../../headers/field_identifiers.h"
|
||||
# include "../../../headers/constants.h"
|
||||
# include "../../../char_set/charset_inline.h"
|
||||
# include "../lex_keywords_funcs.h"
|
||||
|
||||
void lex_keywords_array_0(t_lex_keywords_array *v);
|
||||
void lex_keywords_array_1(t_lex_keywords_array *v);
|
||||
void lex_keywords_array_2(t_lex_keywords_array *v);
|
||||
void lex_keywords_array_3(t_lex_keywords_array *v);
|
||||
void lex_keywords_array_4(t_lex_keywords_array *v);
|
||||
|
||||
#endif // LEX_KEYWORDS_ARRAY_H
|
||||
|
|
@ -1,140 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* lex_keywords_array_0.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/14 19:17:54 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/04/14 19:18:20 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../../../headers/symbols.h"
|
||||
#include "../../../headers/external_scanner_symbol_identifiers.h"
|
||||
#include "../../../headers/field_identifiers.h"
|
||||
#include "../../../headers/constants.h"
|
||||
#include "../lex_keywords_funcs.h"
|
||||
#include "./lex_keywords_array.h"
|
||||
|
||||
void lex_keywords_array_0(t_lex_keywords_array *v)
|
||||
{
|
||||
v->a[0] = lex_keywords_s0;
|
||||
v->a[1] = lex_keywords_s1;
|
||||
v->a[2] = lex_keywords_s2;
|
||||
v->a[3] = lex_keywords_s3;
|
||||
v->a[4] = lex_keywords_s4;
|
||||
v->a[5] = lex_keywords_s5;
|
||||
v->a[6] = lex_keywords_s6;
|
||||
v->a[7] = lex_keywords_s7;
|
||||
v->a[8] = lex_keywords_s8;
|
||||
v->a[9] = lex_keywords_s9;
|
||||
v->a[10] = lex_keywords_s10;
|
||||
v->a[11] = lex_keywords_s11;
|
||||
v->a[12] = lex_keywords_s12;
|
||||
v->a[13] = lex_keywords_s13;
|
||||
v->a[14] = lex_keywords_s14;
|
||||
v->a[15] = lex_keywords_s15;
|
||||
v->a[16] = lex_keywords_s16;
|
||||
v->a[17] = lex_keywords_s17;
|
||||
v->a[18] = lex_keywords_s18;
|
||||
v->a[19] = lex_keywords_s19;
|
||||
lex_keywords_array_1(v);
|
||||
}
|
||||
|
||||
void lex_keywords_array_1(t_lex_keywords_array *v)
|
||||
{
|
||||
v->a[20] = lex_keywords_s20;
|
||||
v->a[21] = lex_keywords_s21;
|
||||
v->a[22] = lex_keywords_s22;
|
||||
v->a[23] = lex_keywords_s23;
|
||||
v->a[24] = lex_keywords_s24;
|
||||
v->a[25] = lex_keywords_s25;
|
||||
v->a[26] = lex_keywords_s26;
|
||||
v->a[27] = lex_keywords_s27;
|
||||
v->a[28] = lex_keywords_s28;
|
||||
v->a[29] = lex_keywords_s29;
|
||||
v->a[30] = lex_keywords_s30;
|
||||
v->a[31] = lex_keywords_s31;
|
||||
v->a[32] = lex_keywords_s32;
|
||||
v->a[33] = lex_keywords_s33;
|
||||
v->a[34] = lex_keywords_s34;
|
||||
v->a[35] = lex_keywords_s35;
|
||||
v->a[36] = lex_keywords_s36;
|
||||
v->a[37] = lex_keywords_s37;
|
||||
v->a[38] = lex_keywords_s38;
|
||||
v->a[39] = lex_keywords_s39;
|
||||
lex_keywords_array_2(v);
|
||||
}
|
||||
|
||||
void lex_keywords_array_2(t_lex_keywords_array *v)
|
||||
{
|
||||
v->a[40] = lex_keywords_s40;
|
||||
v->a[41] = lex_keywords_s41;
|
||||
v->a[42] = lex_keywords_s42;
|
||||
v->a[43] = lex_keywords_s43;
|
||||
v->a[44] = lex_keywords_s44;
|
||||
v->a[45] = lex_keywords_s45;
|
||||
v->a[46] = lex_keywords_s46;
|
||||
v->a[47] = lex_keywords_s47;
|
||||
v->a[48] = lex_keywords_s48;
|
||||
v->a[49] = lex_keywords_s49;
|
||||
v->a[50] = lex_keywords_s50;
|
||||
v->a[51] = lex_keywords_s51;
|
||||
v->a[52] = lex_keywords_s52;
|
||||
v->a[53] = lex_keywords_s53;
|
||||
v->a[54] = lex_keywords_s54;
|
||||
v->a[55] = lex_keywords_s55;
|
||||
v->a[56] = lex_keywords_s56;
|
||||
v->a[57] = lex_keywords_s57;
|
||||
v->a[58] = lex_keywords_s58;
|
||||
v->a[59] = lex_keywords_s59;
|
||||
lex_keywords_array_3(v);
|
||||
}
|
||||
|
||||
void lex_keywords_array_3(t_lex_keywords_array *v)
|
||||
{
|
||||
v->a[60] = lex_keywords_s60;
|
||||
v->a[61] = lex_keywords_s61;
|
||||
v->a[62] = lex_keywords_s62;
|
||||
v->a[63] = lex_keywords_s63;
|
||||
v->a[64] = lex_keywords_s64;
|
||||
v->a[65] = lex_keywords_s65;
|
||||
v->a[66] = lex_keywords_s66;
|
||||
v->a[67] = lex_keywords_s67;
|
||||
v->a[68] = lex_keywords_s68;
|
||||
v->a[69] = lex_keywords_s69;
|
||||
v->a[70] = lex_keywords_s70;
|
||||
v->a[71] = lex_keywords_s71;
|
||||
v->a[72] = lex_keywords_s72;
|
||||
v->a[73] = lex_keywords_s73;
|
||||
v->a[74] = lex_keywords_s74;
|
||||
v->a[75] = lex_keywords_s75;
|
||||
v->a[76] = lex_keywords_s76;
|
||||
v->a[77] = lex_keywords_s77;
|
||||
v->a[78] = lex_keywords_s78;
|
||||
v->a[79] = lex_keywords_s79;
|
||||
lex_keywords_array_4(v);
|
||||
}
|
||||
|
||||
void lex_keywords_array_4(t_lex_keywords_array *v)
|
||||
{
|
||||
v->a[80] = lex_keywords_s80;
|
||||
v->a[81] = lex_keywords_s81;
|
||||
v->a[82] = lex_keywords_s82;
|
||||
v->a[83] = lex_keywords_s83;
|
||||
v->a[84] = lex_keywords_s84;
|
||||
v->a[85] = lex_keywords_s85;
|
||||
v->a[86] = lex_keywords_s86;
|
||||
v->a[87] = lex_keywords_s87;
|
||||
v->a[88] = lex_keywords_s88;
|
||||
v->a[89] = lex_keywords_s89;
|
||||
v->a[90] = lex_keywords_s90;
|
||||
v->a[91] = lex_keywords_s91;
|
||||
v->a[92] = lex_keywords_s92;
|
||||
v->a[93] = lex_keywords_s93;
|
||||
v->a[94] = lex_keywords_s94;
|
||||
v->a[95] = lex_keywords_s95;
|
||||
v->a[96] = lex_keywords_s96;
|
||||
}
|
||||
/* EOF lex_keywords_array_0.c */
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* inline.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/14 19:17:54 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/04/14 19:18:20 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef INLINE_H
|
||||
# define INLINE_H
|
||||
|
||||
# include "../../headers/symbols.h"
|
||||
# include "../../headers/external_scanner_symbol_identifiers.h"
|
||||
# include "../../headers/field_identifiers.h"
|
||||
# include "../../headers/constants.h"
|
||||
# include "../../../parse_types.h"
|
||||
|
||||
#endif // INLINE_H
|
||||
|
|
@ -1,127 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* lex_keywords_funcs.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/14 19:17:54 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/04/14 19:18:20 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef LEX_KEYWORDS_FUNCS_H
|
||||
# define LEX_KEYWORDS_FUNCS_H
|
||||
|
||||
# include "../../types/type_lex_keywords.h"
|
||||
# include "../../headers/symbols.h"
|
||||
# include "../../headers/external_scanner_symbol_identifiers.h"
|
||||
# include "../../headers/field_identifiers.h"
|
||||
# include "../../headers/constants.h"
|
||||
# include "../../char_set/charset_inline.h"
|
||||
# include "./inline.h"
|
||||
# include "../../../parse_types.h"
|
||||
|
||||
bool lex_keywords_s0_bis(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s22_bis(t_lexer *lexer, t_lexer_state *s);
|
||||
|
||||
bool lex_keywords_s0(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s1(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s2(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s3(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s4(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s5(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s6(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s7(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s8(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s9(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s10(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s11(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s12(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s13(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s14(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s15(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s16(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s17(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s18(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s19(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s20(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s21(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s22(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s23(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s24(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s25(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s26(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s27(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s28(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s29(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s30(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s31(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s32(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s33(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s34(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s35(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s36(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s37(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s38(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s39(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s40(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s41(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s42(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s43(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s44(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s45(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s46(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s47(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s48(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s49(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s50(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s51(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s52(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s53(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s54(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s55(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s56(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s57(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s58(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s59(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s60(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s61(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s62(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s63(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s64(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s65(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s66(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s67(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s68(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s69(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s70(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s71(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s72(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s73(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s74(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s75(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s76(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s77(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s78(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s79(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s80(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s81(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s82(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s83(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s84(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s85(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s86(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s87(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s88(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s89(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s90(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s91(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s92(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s93(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s94(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s95(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_s96(t_lexer *lexer, t_lexer_state *s);
|
||||
bool lex_keywords_default(t_lexer *lexer, t_lexer_state *s);
|
||||
|
||||
#endif // LEX_KEYWORDS_FUNCS_H
|
||||
|
|
@ -1,49 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* main_func.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/14 19:17:54 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/04/14 19:18:20 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "./lex_keywords_funcs.h"
|
||||
|
||||
t_lex_keywords_array *create_lex_keywords(void);
|
||||
|
||||
bool lex_keywords_call(t_lexer *lexer, t_lexer_state *s)
|
||||
{
|
||||
t_lex_keywords_array *t;
|
||||
|
||||
t = create_lex_keywords();
|
||||
if (s->state < 97)
|
||||
{
|
||||
return (((bool (*)(t_lexer *, t_lexer_state \
|
||||
*))(t->a[s->state]))(lexer, s));
|
||||
}
|
||||
return (lex_keywords_default(lexer, s));
|
||||
}
|
||||
|
||||
bool lex_keywords_main(t_lexer *lexer, t_state_id state)
|
||||
{
|
||||
t_lexer_state s;
|
||||
|
||||
s = (t_lexer_state){.result = false, .skip = false, .eof = \
|
||||
false};
|
||||
s.state = state;
|
||||
s.skip = false;
|
||||
s.lookahead = lexer->lookahead;
|
||||
s.eof = lexer->eof(lexer);
|
||||
while (lex_keywords_call(lexer, &s))
|
||||
{
|
||||
lexer->advance(lexer, s.skip);
|
||||
s.skip = false;
|
||||
s.lookahead = lexer->lookahead;
|
||||
s.eof = lexer->eof(lexer);
|
||||
}
|
||||
return (s.result);
|
||||
}
|
||||
/* main_func.c */
|
||||
|
|
@ -1,63 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* state_0.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/14 19:17:54 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/04/14 19:18:20 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "./lex_keywords_funcs.h"
|
||||
|
||||
bool lex_keywords_s0(t_lexer *lexer, t_lexer_state *s)
|
||||
{
|
||||
if (lex_keywords_s0_bis(lexer, s))
|
||||
return (true);
|
||||
if (s->lookahead == 'i')
|
||||
return (lex_advance(14, lexer, s));
|
||||
if (s->lookahead == 'k')
|
||||
return (lex_advance(15, lexer, s));
|
||||
if (s->lookahead == 'l')
|
||||
return (lex_advance(16, lexer, s));
|
||||
if (s->lookahead == 'r')
|
||||
return (lex_advance(17, lexer, s));
|
||||
if (s->lookahead == 's')
|
||||
return (lex_advance(18, lexer, s));
|
||||
if (s->lookahead == 't')
|
||||
return (lex_advance(19, lexer, s));
|
||||
if (s->lookahead == 'u')
|
||||
return (lex_advance(20, lexer, s));
|
||||
if (s->lookahead == 'w')
|
||||
return (lex_advance(21, lexer, s));
|
||||
if (((s->lookahead >= '\t' && s->lookahead <= '\r') || \
|
||||
s->lookahead == ' '))
|
||||
return (lex_skip(22, lexer, s));
|
||||
return (lex_end_state(lexer, s));
|
||||
}
|
||||
|
||||
bool lex_keywords_s1(t_lexer *lexer, t_lexer_state *s)
|
||||
{
|
||||
lex_accept_token(anon_sym_A, lexer, s);
|
||||
return (lex_end_state(lexer, s));
|
||||
}
|
||||
|
||||
bool lex_keywords_s2(t_lexer *lexer, t_lexer_state *s)
|
||||
{
|
||||
lex_accept_token(anon_sym_E, lexer, s);
|
||||
return (lex_end_state(lexer, s));
|
||||
}
|
||||
|
||||
bool lex_keywords_s3(t_lexer *lexer, t_lexer_state *s)
|
||||
{
|
||||
lex_accept_token(anon_sym_K, lexer, s);
|
||||
return (lex_end_state(lexer, s));
|
||||
}
|
||||
|
||||
bool lex_keywords_s4(t_lexer *lexer, t_lexer_state *s)
|
||||
{
|
||||
lex_accept_token(anon_sym_L, lexer, s);
|
||||
return (lex_end_state(lexer, s));
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue