evalexpr: allow choosing parser at build time

This commit is contained in:
Bruno BELANYI 2020-10-28 17:20:13 +01:00
parent 9a6da7b19a
commit 92ae5e3ab9
2 changed files with 10 additions and 1 deletions

View File

@ -1,7 +1,8 @@
CC = gcc CC = gcc
CPPFLAGS = -Isrc/ -D_POSIX_C_SOURCE=200809L CPPFLAGS = -Isrc/ -D_POSIX_C_SOURCE=200809L -D_USE_CLIMBING=$(USE_CLIMBING)
CFLAGS = -Wall -Wextra -pedantic -Werror -std=c99 CFLAGS = -Wall -Wextra -pedantic -Werror -std=c99
VPATH = src/ VPATH = src/
USE_CLIMBING = 1
SRC = \ SRC = \
src/ast/ast.c \ src/ast/ast.c \

View File

@ -5,6 +5,10 @@
#include "eval/eval.h" #include "eval/eval.h"
#include "parse/parse.h" #include "parse/parse.h"
#ifndef _USE_CLIMBING
# define _USE_CLIMBING 0
#endif
int main(void) int main(void)
{ {
char *line = NULL; char *line = NULL;
@ -13,7 +17,11 @@ int main(void)
while ((getline(&line, &size, stdin)) > 0) while ((getline(&line, &size, stdin)) > 0)
{ {
#if _USE_CLIMBING
struct ast_node *ast = climbing_parse(line);
#else
struct ast_node *ast = recursive_parse(line); struct ast_node *ast = recursive_parse(line);
#endif
if (ast == NULL) if (ast == NULL)
{ {