From 0e6fc1262d2856192c5b0d9dd286a1604fe1c948 Mon Sep 17 00:00:00 2001 From: zawz Date: Wed, 23 Jun 2021 16:54:21 +0200 Subject: [PATCH] deduplicate parsing constant --- include/parse.hpp | 3 +-- src/parse.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/include/parse.hpp b/include/parse.hpp index adc743c..0c0619c 100644 --- a/include/parse.hpp +++ b/include/parse.hpp @@ -18,7 +18,6 @@ #define CONTROL_END "#)" #define PIPELINE_END "\n;#()&" #define ARGLIST_END "\n;#()&|" -#define SPECIAL_TOKENS "\n;#()&|" #define ALL_TOKENS "\n;#()&|{}" #define ARITHMETIC_OPERATOR_END " \t\n$)" @@ -93,7 +92,7 @@ std::pair parse_var(parse_context ct, bool specialvars std::pair parse_arithmetic(parse_context ct); std::pair parse_manipulation(parse_context ct); // arg parser -std::pair parse_arg(parse_context ct, const char* end=ARG_END, const char* unexpected=SPECIAL_TOKENS, bool doquote=true); +std::pair parse_arg(parse_context ct, const char* end=ARG_END, const char* unexpected=ARGLIST_END, bool doquote=true); // redirect parser std::pair parse_redirect(parse_context ct); // arglist parser diff --git a/src/parse.cpp b/src/parse.cpp index 8396313..48ac74d 100644 --- a/src/parse.cpp +++ b/src/parse.cpp @@ -803,7 +803,7 @@ std::pair parse_arglist(parse_context ctx, bool hard_er } } } - else if(is_in(ctx[ctx.i], SPECIAL_TOKENS) && !word_eq("&>", ctx)) + else if(is_in(ctx[ctx.i], ARGLIST_END) && !word_eq("&>", ctx)) { if(hard_error) { @@ -861,7 +861,7 @@ std::pair parse_arglist(parse_context ctx, bool hard_er } if(ctx.i>=ctx.size) return std::make_pair(ret, ctx); - if( is_in(ctx[ctx.i], SPECIAL_TOKENS) ) + if( is_in(ctx[ctx.i], ARGLIST_END) ) return std::make_pair(ret, ctx); } @@ -1278,7 +1278,7 @@ std::pair parse_cmd(parse_context ctx) ctx = parse_cmd_varassigns(ret, ctx, true, wp.first); } - if(!is_in(ctx[ctx.i], SPECIAL_TOKENS)) + if(!is_in(ctx[ctx.i], ARGLIST_END)) { auto pp=parse_arglist(ctx, true, &ret->redirs); ret->args = pp.first; @@ -1342,7 +1342,7 @@ std::pair parse_case(parse_context ctx) } if(ctx[ctx.i] == ')') break; - if(ctx[ctx.i] != '|' && is_in(ctx[ctx.i], SPECIAL_TOKENS)) + if(is_in(ctx[ctx.i], PIPELINE_END)) { parse_error( unexpected_token(ctx[ctx.i])+", expecting ')'", ctx ); }