diff --git a/Makefile b/Makefile index 8dfccac..d12d9dd 100644 --- a/Makefile +++ b/Makefile @@ -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) diff --git a/src/evalexpr.c b/src/evalexpr.c index 15f1d1c..50c431b 100644 --- a/src/evalexpr.c +++ b/src/evalexpr.c @@ -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) { diff --git a/src/parse/parse.h b/src/parse/parse.h index 0121bc7..0dc7716 100644 --- a/src/parse/parse.h +++ b/src/parse/parse.h @@ -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 */ diff --git a/src/parse/parse.c b/src/parse/recursive_parse.c similarity index 92% rename from src/parse/parse.c rename to src/parse/recursive_parse.c index a644488..c24e905 100644 --- a/src/parse/parse.c +++ b/src/parse/recursive_parse.c @@ -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;