push
This commit is contained in:
65
srcs/srcs_asm/lexer/ft_automaton.c
Normal file
65
srcs/srcs_asm/lexer/ft_automaton.c
Normal file
@@ -0,0 +1,65 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_automaton.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: jfleury <jfleury@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/06/06 14:48:26 by jfleury #+# #+# */
|
||||
/* Updated: 2019/07/16 14:30:23 by jfleury ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "asm.h"
|
||||
|
||||
static int ft_cal_i_string(int i_matrice, char *line, int *nb_char_token)
|
||||
{
|
||||
int i_string;
|
||||
|
||||
i_string = 0;
|
||||
if (line[*nb_char_token] == 0
|
||||
|| (i_matrice == 21 && line[*nb_char_token] != '\n'))
|
||||
i_string = 16;
|
||||
else
|
||||
while (!(ft_line_strchr(g_string_automaton[i_string],
|
||||
line[*nb_char_token])) && i_string < 15)
|
||||
i_string++;
|
||||
return (i_string);
|
||||
}
|
||||
|
||||
static int ft_end_error(int *nb_char_token, char *line)
|
||||
{
|
||||
g_nb_char = g_nb_char + *nb_char_token;
|
||||
ft_printf("error: syntax %d:%d char: %c\n",
|
||||
g_nb_line, g_nb_char + 1, line[*nb_char_token]);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int ft_automaton(char *line, t_token *token, t_label *label,
|
||||
int *nb_char_token)
|
||||
{
|
||||
int i_matrice;
|
||||
int i_string;
|
||||
int type;
|
||||
|
||||
i_matrice = 0;
|
||||
while (1)
|
||||
{
|
||||
type = i_matrice;
|
||||
i_string = ft_cal_i_string(i_matrice, line, nb_char_token);
|
||||
i_matrice = g_matrice_automaton[i_matrice][i_string];
|
||||
if (i_matrice == -2 || i_matrice == -3)
|
||||
{
|
||||
if (i_matrice == -3)
|
||||
*nb_char_token = *nb_char_token - 1;
|
||||
g_nb_char = g_nb_char + *nb_char_token;
|
||||
ft_create_token_label(ft_create_string(line, *nb_char_token),
|
||||
type, token, label);
|
||||
return (1);
|
||||
}
|
||||
else if (i_matrice == -1)
|
||||
return (ft_end_error(nb_char_token, line));
|
||||
else
|
||||
*nb_char_token = *nb_char_token + 1;
|
||||
}
|
||||
}
|
95
srcs/srcs_asm/lexer/ft_lexer.c
Normal file
95
srcs/srcs_asm/lexer/ft_lexer.c
Normal file
@@ -0,0 +1,95 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_lexer.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: jfleury <jfleury@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/05/30 10:48:23 by jfleury #+# #+# */
|
||||
/* Updated: 2019/07/16 16:20:57 by jfleury ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "asm.h"
|
||||
|
||||
static int ft_free_line(char **line, char **tmp)
|
||||
{
|
||||
free(*line);
|
||||
free(*tmp);
|
||||
return (0);
|
||||
}
|
||||
|
||||
static void ft_free_error(t_token *token, t_label *label,
|
||||
t_token *list_token)
|
||||
{
|
||||
t_token *tmp;
|
||||
|
||||
free(token);
|
||||
free(label);
|
||||
if (list_token != NULL)
|
||||
{
|
||||
while (list_token != NULL)
|
||||
{
|
||||
tmp = list_token->next;
|
||||
free(list_token->contents);
|
||||
free(list_token);
|
||||
list_token = tmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
t_token *ft_lexer_token(char **line, t_label **list_label)
|
||||
{
|
||||
t_token *token;
|
||||
t_label *label;
|
||||
t_token *list_token;
|
||||
int nb_char_token;
|
||||
|
||||
list_token = NULL;
|
||||
while ((*line)[0] != '\n' && (*line)[0] != 0)
|
||||
{
|
||||
if (!(token = malloc(sizeof(t_token))))
|
||||
return (NULL);
|
||||
if (!(label = malloc(sizeof(t_label))))
|
||||
return (NULL);
|
||||
nb_char_token = 0;
|
||||
if (!(ft_automaton(*line, token, label, &nb_char_token)))
|
||||
{
|
||||
ft_free_error(token, label, list_token);
|
||||
return (NULL);
|
||||
}
|
||||
ft_append_token_label(token, &list_token, label, list_label);
|
||||
if (!(line = ft_cut_line(line, nb_char_token)))
|
||||
break ;
|
||||
}
|
||||
return (list_token);
|
||||
}
|
||||
|
||||
int ft_lexer(t_lst_tk **list, t_label **list_label, char **argv)
|
||||
{
|
||||
char *line;
|
||||
int fd;
|
||||
static char *tmp;
|
||||
|
||||
fd = open(argv[1], O_RDONLY);
|
||||
line = NULL;
|
||||
while (get_next_line(fd, &line, &tmp) == 1)
|
||||
{
|
||||
g_nb_char = 0;
|
||||
g_nb_line++;
|
||||
if (!(line = ft_check_line(line, fd)))
|
||||
return (ft_free_line(&line, &tmp));
|
||||
if (!(ft_empty_line(line)))
|
||||
{
|
||||
free(line);
|
||||
continue ;
|
||||
}
|
||||
if (!(ft_append_lst_tk(ft_lexer_token(&line, list_label), list)))
|
||||
return (ft_free_line(&line, &tmp));
|
||||
free(line);
|
||||
}
|
||||
if (line != NULL)
|
||||
free(line);
|
||||
free(tmp);
|
||||
return (1);
|
||||
}
|
49
srcs/srcs_asm/lexer/lib_lexer/ft_append_lst_tk.c
Normal file
49
srcs/srcs_asm/lexer/lib_lexer/ft_append_lst_tk.c
Normal file
@@ -0,0 +1,49 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_append_lst_tk.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: jfleury <jfleury@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/06/24 11:38:38 by jfleury #+# #+# */
|
||||
/* Updated: 2019/07/01 11:22:10 by jfleury ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "asm.h"
|
||||
|
||||
t_lst_tk *ft_create_lst_tk(t_token *token)
|
||||
{
|
||||
t_lst_tk *new;
|
||||
|
||||
if (token == NULL)
|
||||
return (NULL);
|
||||
if (!(new = (t_lst_tk*)malloc(sizeof(t_lst_tk))))
|
||||
return (NULL);
|
||||
new->token = token;
|
||||
new->next = NULL;
|
||||
return (new);
|
||||
}
|
||||
|
||||
int ft_append_lst_tk(t_token *token, t_lst_tk **list)
|
||||
{
|
||||
t_lst_tk *begin;
|
||||
|
||||
begin = *list;
|
||||
if (token == NULL)
|
||||
return (0);
|
||||
if (*list == NULL)
|
||||
{
|
||||
if (!(*list = ft_create_lst_tk(token)))
|
||||
return (1);
|
||||
}
|
||||
else
|
||||
{
|
||||
while ((*list)->next != NULL)
|
||||
*list = (*list)->next;
|
||||
if (!((*list)->next = ft_create_lst_tk(token)))
|
||||
return (1);
|
||||
*list = begin;
|
||||
}
|
||||
return (1);
|
||||
}
|
49
srcs/srcs_asm/lexer/lib_lexer/ft_append_token_label.c
Normal file
49
srcs/srcs_asm/lexer/lib_lexer/ft_append_token_label.c
Normal file
@@ -0,0 +1,49 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_append_token_label.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: jfleury <jfleury@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/06/14 13:42:16 by jfleury #+# #+# */
|
||||
/* Updated: 2019/07/15 12:56:53 by jfleury ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "asm.h"
|
||||
|
||||
static void ft_append_label(t_label *label, t_label **list_label)
|
||||
{
|
||||
t_label *tmp_label;
|
||||
|
||||
if (*list_label == NULL)
|
||||
*list_label = label;
|
||||
else
|
||||
{
|
||||
tmp_label = *list_label;
|
||||
while (tmp_label->next != NULL)
|
||||
tmp_label = tmp_label->next;
|
||||
tmp_label->next = label;
|
||||
}
|
||||
}
|
||||
|
||||
void ft_append_token_label(t_token *token, t_token **list_token,
|
||||
t_label *label, t_label **list_label)
|
||||
{
|
||||
t_token *tmp_token;
|
||||
|
||||
if (*list_token == NULL)
|
||||
*list_token = token;
|
||||
else
|
||||
{
|
||||
tmp_token = *list_token;
|
||||
while (tmp_token->next != NULL)
|
||||
tmp_token = tmp_token->next;
|
||||
tmp_token->next = token;
|
||||
tmp_token->line = g_nb_line;
|
||||
}
|
||||
if (token->type == 1)
|
||||
ft_append_label(label, list_label);
|
||||
else
|
||||
free(label);
|
||||
}
|
64
srcs/srcs_asm/lexer/lib_lexer/ft_check_line.c
Normal file
64
srcs/srcs_asm/lexer/lib_lexer/ft_check_line.c
Normal file
@@ -0,0 +1,64 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_check_line.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: jfleury <jfleury@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/06/24 11:24:43 by jfleury #+# #+# */
|
||||
/* Updated: 2019/07/15 18:19:05 by jfleury ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "asm.h"
|
||||
|
||||
static int ft_cal_state(char *line, int state)
|
||||
{
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
state = 0;
|
||||
while (line[i] != 0)
|
||||
{
|
||||
if (line[i] == '"')
|
||||
state = state + 1;
|
||||
i++;
|
||||
}
|
||||
return (state);
|
||||
}
|
||||
|
||||
static char *ft_error_gnl(char *str, char *line, char *tmp)
|
||||
{
|
||||
ft_strdel(&str);
|
||||
ft_strdel(&line);
|
||||
ft_strdel(&tmp);
|
||||
ft_printf("error: quote `\n");
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
char *ft_check_line(char *line, int fd)
|
||||
{
|
||||
char *str;
|
||||
static char *tmp;
|
||||
int i;
|
||||
int state;
|
||||
|
||||
i = 0;
|
||||
state = 0;
|
||||
state = ft_cal_state(line, state);
|
||||
while (state % 2 == 1)
|
||||
{
|
||||
if (get_next_line(fd, &str, &tmp) != 1)
|
||||
return (ft_error_gnl(str, line, tmp));
|
||||
if (!(line = ft_strextend(line, "\n")))
|
||||
return (NULL);
|
||||
if (!(line = ft_strextend(line, str)))
|
||||
return (NULL);
|
||||
ft_strdel(&str);
|
||||
g_nb_line++;
|
||||
g_nb_char = 0;
|
||||
state = ft_cal_state(line, state);
|
||||
}
|
||||
line = ft_strextend(line, "\n");
|
||||
return (line);
|
||||
}
|
57
srcs/srcs_asm/lexer/lib_lexer/ft_create_string.c
Normal file
57
srcs/srcs_asm/lexer/lib_lexer/ft_create_string.c
Normal file
@@ -0,0 +1,57 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_create_string.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: jfleury <jfleury@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/06/14 13:57:44 by jfleury #+# #+# */
|
||||
/* Updated: 2019/07/09 10:44:33 by jfleury ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "asm.h"
|
||||
|
||||
static char *ft_cut_string(char *str)
|
||||
{
|
||||
char *str2;
|
||||
int i;
|
||||
int j;
|
||||
|
||||
i = ft_strlen(str);
|
||||
j = 0;
|
||||
while (str[i - 1] == ' ' || str[i - 1] == '\t'
|
||||
|| str[i - 1] == '\v' || str[i - 1] == '\n')
|
||||
i--;
|
||||
if (!(str2 = ft_strnew(i + 1)))
|
||||
return (NULL);
|
||||
while (j < i)
|
||||
{
|
||||
str2[j] = str[j];
|
||||
j++;
|
||||
}
|
||||
free(str);
|
||||
str = str2;
|
||||
return (str);
|
||||
}
|
||||
|
||||
char *ft_create_string(char *line, int nb_char_token)
|
||||
{
|
||||
char *str;
|
||||
int i;
|
||||
int j;
|
||||
|
||||
i = 0;
|
||||
j = 0;
|
||||
while (line[i] == ' ' || line[i] == '\t' || line[i] == '\v')
|
||||
i++;
|
||||
if (!(str = ft_strnew(nb_char_token - i)))
|
||||
return (NULL);
|
||||
while (j <= nb_char_token - i - 1)
|
||||
{
|
||||
str[j] = line[j + i];
|
||||
j++;
|
||||
}
|
||||
str = ft_cut_string(str);
|
||||
return (str);
|
||||
}
|
27
srcs/srcs_asm/lexer/lib_lexer/ft_create_token_label.c
Normal file
27
srcs/srcs_asm/lexer/lib_lexer/ft_create_token_label.c
Normal file
@@ -0,0 +1,27 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_create_token_label.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: jfleury <jfleury@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/06/14 14:03:27 by jfleury #+# #+# */
|
||||
/* Updated: 2019/07/15 11:03:20 by jfleury ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "asm.h"
|
||||
|
||||
void ft_create_token_label(char *str, int type, t_token *token,
|
||||
t_label *label)
|
||||
{
|
||||
if (type == 1)
|
||||
{
|
||||
label->contents = str;
|
||||
label->next = NULL;
|
||||
}
|
||||
token->type = type;
|
||||
token->line = g_nb_line;
|
||||
token->contents = str;
|
||||
token->next = NULL;
|
||||
}
|
54
srcs/srcs_asm/lexer/lib_lexer/ft_cut_line.c
Normal file
54
srcs/srcs_asm/lexer/lib_lexer/ft_cut_line.c
Normal file
@@ -0,0 +1,54 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_cut_line.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: jfleury <jfleury@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/06/14 13:53:27 by jfleury #+# #+# */
|
||||
/* Updated: 2019/07/09 10:44:50 by jfleury ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "asm.h"
|
||||
|
||||
static int ft_check_line2(char *str)
|
||||
{
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
while (str[i] != 0)
|
||||
{
|
||||
if (str[i] != ' ' && str[i] != '\n' && str[i] != '\t' && str[i] != '\v')
|
||||
return (1);
|
||||
i++;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
char **ft_cut_line(char **line, int nb_char_token)
|
||||
{
|
||||
int len;
|
||||
int i;
|
||||
char *str;
|
||||
|
||||
i = 0;
|
||||
len = ft_strlen(*line);
|
||||
if (len < 1 || len == nb_char_token)
|
||||
return (NULL);
|
||||
if (!(str = ft_strnew(len - nb_char_token + 1)))
|
||||
return (NULL);
|
||||
while ((*line)[i + nb_char_token] != 0)
|
||||
{
|
||||
str[i] = (*line)[nb_char_token + i];
|
||||
i++;
|
||||
}
|
||||
if (!(ft_check_line2(str)))
|
||||
{
|
||||
free(str);
|
||||
return (NULL);
|
||||
}
|
||||
free(*line);
|
||||
*line = str;
|
||||
return (line);
|
||||
}
|
26
srcs/srcs_asm/lexer/lib_lexer/ft_empty_line.c
Normal file
26
srcs/srcs_asm/lexer/lib_lexer/ft_empty_line.c
Normal file
@@ -0,0 +1,26 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_empty_line.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: jfleury <jfleury@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/06/24 15:13:26 by jfleury #+# #+# */
|
||||
/* Updated: 2019/06/24 15:16:17 by jfleury ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "asm.h"
|
||||
|
||||
int ft_empty_line(char *line)
|
||||
{
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
while (line[i] == ' ' || line[i] == '\t' || line[i] == '\v'
|
||||
|| line[i] == '\n')
|
||||
i++;
|
||||
if (line[i] == 0)
|
||||
return (0);
|
||||
return (1);
|
||||
}
|
62
srcs/srcs_asm/lexer/lib_lexer/ft_free_list.c
Normal file
62
srcs/srcs_asm/lexer/lib_lexer/ft_free_list.c
Normal file
@@ -0,0 +1,62 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_free_list.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: mdchane <mdchane@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/06/25 11:04:41 by jfleury #+# #+# */
|
||||
/* Updated: 2019/07/13 15:11:14 by mdchane ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "asm.h"
|
||||
|
||||
static void ft_free_token(t_token *token)
|
||||
{
|
||||
t_token *tmp;
|
||||
|
||||
tmp = NULL;
|
||||
while (token != NULL)
|
||||
{
|
||||
tmp = token->next;
|
||||
ft_strdel(&token->contents);
|
||||
free(token);
|
||||
token = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
static void ft_free_label(t_label *label)
|
||||
{
|
||||
t_label *tmp;
|
||||
|
||||
tmp = NULL;
|
||||
while (label != NULL)
|
||||
{
|
||||
tmp = label->next;
|
||||
free(label);
|
||||
label = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
void ft_free_list(t_lst_tk *list, t_label *label)
|
||||
{
|
||||
t_lst_tk *tmp;
|
||||
|
||||
tmp = NULL;
|
||||
while (list != NULL)
|
||||
{
|
||||
tmp = list->next;
|
||||
ft_free_token(list->token);
|
||||
free(list);
|
||||
list = tmp;
|
||||
}
|
||||
ft_free_label(label);
|
||||
}
|
||||
|
||||
void ft_free_all(t_lst_tk *list, t_label *label, t_header *head)
|
||||
{
|
||||
if (head)
|
||||
free(head);
|
||||
ft_free_list(list, label);
|
||||
}
|
27
srcs/srcs_asm/lexer/lib_lexer/ft_line_strchr.c
Normal file
27
srcs/srcs_asm/lexer/lib_lexer/ft_line_strchr.c
Normal file
@@ -0,0 +1,27 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_line_strchr.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: jfleury <jfleury@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/06/14 13:55:57 by jfleury #+# #+# */
|
||||
/* Updated: 2019/06/14 13:56:11 by jfleury ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "asm.h"
|
||||
|
||||
int ft_line_strchr(char *str, char c)
|
||||
{
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
while (str[i] != 0)
|
||||
{
|
||||
if (str[i] == c)
|
||||
return (1);
|
||||
i++;
|
||||
}
|
||||
return (0);
|
||||
}
|
73
srcs/srcs_asm/lexer/src_variable/var_automaton.c
Normal file
73
srcs/srcs_asm/lexer/src_variable/var_automaton.c
Normal file
@@ -0,0 +1,73 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* var_automaton.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: jfleury <jfleury@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/06/06 10:13:09 by jfleury #+# #+# */
|
||||
/* Updated: 2019/07/02 17:22:36 by jfleury ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "asm.h"
|
||||
|
||||
int g_nb_line = 0;
|
||||
|
||||
int g_nb_char = 0;
|
||||
|
||||
int g_nb_token = 0;
|
||||
|
||||
int g_matrice_automaton[30][17] =
|
||||
{
|
||||
{23, 23, -1, 24, 26, 17, 19, 9, 29, -1, 12, 21, 21, 22, 0, 0, -1},
|
||||
{-2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2},
|
||||
{-2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2},
|
||||
{-3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3},
|
||||
{-3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3},
|
||||
{-3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3},
|
||||
{-3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3},
|
||||
{-3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3},
|
||||
{-2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2},
|
||||
{-2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2},
|
||||
{-3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3},
|
||||
{-2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2},
|
||||
{12, 12, -1, 12, -1, 1, -1, -1, -1, -1, 12, -1, -1, -1, -1, 1, -1},
|
||||
{13, 13, -1, 13, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2, 2, -1},
|
||||
{-1, -1, -1, 14, -1, -1, -1, 3, -1, -1, -1, 3, 3, -1, 3, 3, -1},
|
||||
{15, 15, -1, 15, -1, -1, -1, 4, -1, -1, 15, 4, 4, -1, 4, 4, -1},
|
||||
{-1, -1, -1, 16, -1, -1, -1, 5, -1, -1, -1, 5, 5, -1, 5, 5, -1},
|
||||
{17, 17, -1, 17, -1, -1, -1, 6, -1, -1, 17, 6, 6, -1, 6, 6, -1},
|
||||
{-1, -1, -1, 18, -1, -1, -1, 7, -1, -1, -1, 7, 7, -1, 7, 7, -1},
|
||||
{19, 19, 19, 19, 19, 19, 8, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19},
|
||||
{-1, -1, -1, -1, -1, -1, -1, 9, -1, -1, -1, -1, -1, -1, 9, 9, -1},
|
||||
{21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 10, 21},
|
||||
{22, 22, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 11, 11, -1},
|
||||
{23, 23, -1, 25, -1, 1, -1, -1, -1, -1, 12, -1, -1, -1, 2, 2, -1},
|
||||
{12, 12, -1, 24, -1, 1, -1, 5, -1, -1, 12, -1, -1, -1, 5, 5, -1},
|
||||
{12, 12, -1, 25, -1, 1, -1, 7, -1, -1, 12, 7, 7, -1, 7, 7, -1},
|
||||
{-1, -1, -1, 14, -1, 15, -1, -1, 14, -1, -1, -1, -1, -1, -1, -1, -1},
|
||||
{-1, -1, -1, 16, -1, 17, -1, -1, 16, -1, -1, -1, -1, -1, -1, -1, -1},
|
||||
{-1, -1, -1, 28, -1, -1, -1, 6, -1, -1, -1, 6, 6, -1, 6, 6, -1},
|
||||
{-1, -1, -1, 16, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}
|
||||
};
|
||||
|
||||
char *g_string_automaton[16] =
|
||||
{
|
||||
"r",
|
||||
"abcdefghijklmnopqstuvwxyz",
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ",
|
||||
"0123456789",
|
||||
"%",
|
||||
":",
|
||||
"\"",
|
||||
",",
|
||||
"-",
|
||||
"+",
|
||||
"_",
|
||||
"#",
|
||||
";",
|
||||
".",
|
||||
"\t\f ",
|
||||
"\n"
|
||||
};
|
Reference in New Issue
Block a user