feat: starting the parser (header and main function)
This commit is contained in:
parent
bbf7141da6
commit
0441253ef1
4 changed files with 75 additions and 1 deletions
|
|
@ -1 +1 @@
|
||||||
../parser/include/parser
|
../parser/includes
|
||||||
6
parser/Filelist.parser.mk
Normal file
6
parser/Filelist.parser.mk
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
SRC_FILES = \
|
||||||
|
\
|
||||||
|
|
||||||
|
GEN_FILES = \
|
||||||
|
\
|
||||||
|
|
||||||
39
parser/includes/token/token.h
Normal file
39
parser/includes/token/token.h
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* token.h :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2024/09/25 11:38:28 by rparodi #+# #+# */
|
||||||
|
/* Updated: 2024/09/25 16:32:40 by rparodi ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#ifndef TOKEN_H
|
||||||
|
# define TOKEN_H
|
||||||
|
|
||||||
|
#include "me/string/string.h"
|
||||||
|
|
||||||
|
enum e_token
|
||||||
|
{
|
||||||
|
AMP,
|
||||||
|
DOLLAR,
|
||||||
|
DQUOTE,
|
||||||
|
LPAREN,
|
||||||
|
NQUOTE,
|
||||||
|
PIPE,
|
||||||
|
CARRET,
|
||||||
|
RPAREN,
|
||||||
|
SEMICOLON,
|
||||||
|
SQUOTE,
|
||||||
|
WHITESPACE
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct s_token
|
||||||
|
{
|
||||||
|
t_string raw;
|
||||||
|
enum e_token TokenType;
|
||||||
|
} t_token;
|
||||||
|
|
||||||
|
#endif
|
||||||
29
parser/token/token.c
Normal file
29
parser/token/token.c
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* token.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2024/09/25 16:27:03 by rparodi #+# #+# */
|
||||||
|
/* Updated: 2024/09/25 16:54:08 by rparodi ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "parser/token/token.h"
|
||||||
|
#include "me/string/string.h"
|
||||||
|
#include "me/types.h"
|
||||||
|
|
||||||
|
t_error handle_quote(t_string raw, enum e_token actual, int *output);
|
||||||
|
t_error handle_arithmetic(t_string raw, enum e_token actual, int *output);
|
||||||
|
|
||||||
|
t_error tokeniser(t_string raw, enum e_token actual, int *output)
|
||||||
|
{
|
||||||
|
if (!raw.buf || raw.len == 0 || raw.capacity == 0)
|
||||||
|
return (ERROR);
|
||||||
|
if (handle_quote(raw, actual, output))
|
||||||
|
return (ERROR);
|
||||||
|
else if (handle_arithmetic(raw, actual, output))
|
||||||
|
return (ERROR);
|
||||||
|
return (NO_ERROR);
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue