init parser
This commit is contained in:
@@ -1,8 +1,4 @@
|
||||
#include "computorv1.h"
|
||||
#include "libft.h"
|
||||
#include "lexer.h"
|
||||
#include "errors.h"
|
||||
#include <stdio.h> // tmp for float debug
|
||||
|
||||
void remove_spaces(char *s)
|
||||
{
|
||||
@@ -63,7 +59,11 @@ int main(int ac, char **av)
|
||||
ft_putchar('\n'); // debug
|
||||
|
||||
token tokens[arg_len];
|
||||
lexerize(input, tokens);
|
||||
int token_count = lexerize(input, tokens);
|
||||
|
||||
ft_putstr("-> token_count : "); // debug
|
||||
ft_putnbr(token_count); // debug
|
||||
ft_putchar('\n'); // debug
|
||||
|
||||
// tmp debug output
|
||||
ft_putchar('\n'); // debug
|
||||
@@ -105,6 +105,15 @@ int main(int ac, char **av)
|
||||
}
|
||||
i++;
|
||||
}
|
||||
ft_putchar('\n'); // debug
|
||||
// END tmp debug output
|
||||
|
||||
term terms[token_count / 2];
|
||||
int term_count = parse(tokens, terms);
|
||||
|
||||
ft_putstr("-> term_count : "); // debug
|
||||
ft_putnbr(term_count); // debug
|
||||
ft_putchar('\n'); // debug
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
#include "lexer.h"
|
||||
#include "libft.h"
|
||||
#include "errors.h"
|
||||
#include <stdbool.h>
|
||||
|
||||
// any single letter is a valid variable, like 'x' or 'y'
|
||||
static bool token_is_variable(const char *input, int input_pos, int *token_size)
|
||||
@@ -153,7 +150,7 @@ static bool token_is_equal(const char *input, int input_pos, int *token_size)
|
||||
/**
|
||||
* LEXER
|
||||
*/
|
||||
void lexerize(const char *input, token *tokens)
|
||||
int lexerize(const char *input, token *tokens)
|
||||
{
|
||||
int token_count;
|
||||
int input_pos;
|
||||
@@ -222,4 +219,6 @@ void lexerize(const char *input, token *tokens)
|
||||
|
||||
tokens[token_count].type = TOKEN_END;
|
||||
tokens[token_count].value_char = '\0';
|
||||
|
||||
return token_count;
|
||||
}
|
||||
|
||||
10
src/parser.c
Normal file
10
src/parser.c
Normal file
@@ -0,0 +1,10 @@
|
||||
#include "parser.h"
|
||||
|
||||
int parse(token *tokens, term *terms)
|
||||
{
|
||||
if (tokens)
|
||||
{
|
||||
terms[0].type = 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
Reference in New Issue
Block a user