deduplicate parsing constant
This commit is contained in:
parent
3dc60ff7e3
commit
0e6fc1262d
2 changed files with 5 additions and 6 deletions
|
|
@ -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<variable*, parse_context> parse_var(parse_context ct, bool specialvars
|
|||
std::pair<arithmetic*, parse_context> parse_arithmetic(parse_context ct);
|
||||
std::pair<variable*, parse_context> parse_manipulation(parse_context ct);
|
||||
// arg parser
|
||||
std::pair<arg*, parse_context> parse_arg(parse_context ct, const char* end=ARG_END, const char* unexpected=SPECIAL_TOKENS, bool doquote=true);
|
||||
std::pair<arg*, parse_context> parse_arg(parse_context ct, const char* end=ARG_END, const char* unexpected=ARGLIST_END, bool doquote=true);
|
||||
// redirect parser
|
||||
std::pair<redirect*, parse_context> parse_redirect(parse_context ct);
|
||||
// arglist parser
|
||||
|
|
|
|||
|
|
@ -803,7 +803,7 @@ std::pair<arglist*, parse_context> 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<arglist*, parse_context> 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<cmd*, parse_context> 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<case_block*, parse_context> 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 );
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue