evalexpr: parse: rename recursive parsing function
This commit is contained in:
parent
a92e39dbec
commit
ad56ea521a
2
Makefile
2
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)
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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;
|
Loading…
Reference in a new issue