evalexpr: parse: rename recursive parsing function

This commit is contained in:
Bruno BELANYI 2020-10-28 17:09:22 +01:00
parent a92e39dbec
commit ad56ea521a
4 changed files with 17 additions and 17 deletions

View file

@ -6,7 +6,7 @@ VPATH = src/
SRC = \
src/ast/ast.c \
src/eval/eval.c \
src/parse/parse.c \
src/parse/recursive_parse.c \
BIN = evalexpr
OBJ = $(SRC:.c=.o)

View file

@ -13,7 +13,7 @@ int main(void)
while ((getline(&line, &size, stdin)) > 0)
{
struct ast_node *ast = parse_string(line);
struct ast_node *ast = recursive_parse(line);
if (ast == NULL)
{

View file

@ -3,6 +3,6 @@
#include "ast/ast.h"
struct ast_node *parse_string(const char *input);
struct ast_node *recursive_parse(const char *input);
#endif /* !PARSE_H */

View file

@ -26,21 +26,21 @@ static void skip_whitespace(const char **input)
}
/*
** Simple recursive descent using the following grammar, using E as start:
**
** E : T [ ('+'|'-') T ]*
** T : F [ ('*'|'/') F ]*
** F : [ ('-'|'+') ]* P
** P : G [ ('^') F ]*
** G : '(' E ')' | CONSTANT [ '!' ]
**
** Whitespace is ignored in the input string, only serving to delimit numbers.
**
** The input shall consist of a single expression, having a trailing
** expression in the input results in an error.
**/
* Simple recursive descent using the following grammar, using E as start:
*
* E : T [ ('+'|'-') T ]*
* T : F [ ('*'|'/') F ]*
* F : [ ('-'|'+') ]* P
* P : G [ ('^') F ]*
* G : '(' E ')' | CONSTANT [ '!' ]
*
* Whitespace is ignored in the input string, only serving to delimit numbers.
*
* The input shall consist of a single expression, having a trailing
* expression in the input results in an error.
*/
struct ast_node *parse_string(const char *input)
struct ast_node *recursive_parse(const char *input)
{
if (input == NULL)
return NULL;