From 298c60130072f93ee884b9fa39161a6bceeb2c61 Mon Sep 17 00:00:00 2001 From: Kelvin Sherlock Date: Wed, 23 Nov 2022 18:18:32 -0500 Subject: [PATCH] include trailing text with the ) token so redirection works correctly --- phase2.rl | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/phase2.rl b/phase2.rl index bad23f7..2d625af 100644 --- a/phase2.rl +++ b/phase2.rl @@ -60,6 +60,7 @@ } } + action parse_lparen { if (scratch.empty()) { parse(LPAREN, "("); @@ -71,7 +72,8 @@ action parse_rparen { if (pcount <= 0) { flush(); - parse(RPAREN, ")"); + // parse(RPAREN, ")"); + scratch.push_back(fc); fgoto main; } --pcount; @@ -179,6 +181,10 @@ int phase2::classify() { %%write data; if (type) return type; + if (scratch.front() == ')') { + type = RPAREN; + return type; + } std::string argv0; const unsigned char *p = (const unsigned char *)scratch.data();