From 56ed26ed96ec250f45dc2d7503e54d7136f5645b Mon Sep 17 00:00:00 2001 From: zawz Date: Tue, 22 Jun 2021 10:01:29 +0200 Subject: [PATCH] fix parsing errors on variables in arithmetics --- include/parse.hpp | 8 ++------ src/parse.cpp | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/include/parse.hpp b/include/parse.hpp index 9a49959..adc743c 100644 --- a/include/parse.hpp +++ b/include/parse.hpp @@ -21,17 +21,13 @@ #define SPECIAL_TOKENS "\n;#()&|" #define ALL_TOKENS "\n;#()&|{}" +#define ARITHMETIC_OPERATOR_END " \t\n$)" + #define SPECIAL_VARS "!#*@$?" // bash specific #define ARRAY_ARG_END " \t\n;#()&|<>]" -// macros -// #define PARSE_ERROR_I(str, ctx, i) format_error(str, ctx.filename, ctx.data, i) -// #define PARSE_ERROR(str, ctx) format_error(str, ctx.filename, ctx.data, ctx.i) -// #define PARSE_ERROR_I(str, ctx, i) { printFormatError(format_error(str, ctx.filename, ctx.data, i)); ctx.has_errored=true; } -// #define PARSE_ERROR(str, ctx) { printFormatError(format_error(str, ctx.filename, ctx.data, ctx.i)); ctx.has_errored=true; } - // structs struct list_parse_options { diff --git a/src/parse.cpp b/src/parse.cpp index 2891aa9..079d769 100644 --- a/src/parse.cpp +++ b/src/parse.cpp @@ -239,7 +239,7 @@ std::pair get_operator(parse_context ctx) std::string ret; uint32_t start=ctx.i; - while(!is_alphanum(ctx[ctx.i]) && !is_in(ctx[ctx.i], SEPARATORS) && ctx[ctx.i]!=')' ) + while(!is_alphanum(ctx[ctx.i]) && !is_in(ctx[ctx.i], ARITHMETIC_OPERATOR_END)) ctx.i++; ret = std::string(ctx.data+start, ctx.i-start);