From 197e361cb64ce8262bbc917fd93a22a0f65db27b Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Thu, 31 Dec 2015 13:13:11 -0800 Subject: [PATCH] Hide complicated hold manipulation behind CYHLD(). --- Parser.ypp.in | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Parser.ypp.in b/Parser.ypp.in index 5efee05..c2927f2 100644 --- a/Parser.ypp.in +++ b/Parser.ypp.in @@ -184,6 +184,13 @@ type; }) yyla.type = yytranslate_(token::to); \ } while (false) +#define CYHLD(location, token) do { \ + if (driver.hold_ != empty_symbol) \ + CYERR(location, "unexpected hold"); \ + driver.hold_ = yyla.type; \ + yyla.type = yytranslate_(token); \ +} while (false) + #define CYERR(location, message) do { \ error(location, message); \ YYABORT; \ @@ -778,11 +785,11 @@ LexPushYieldOff: { driver.yield_.push(false); }; LexPopYield: { driver.yield_.pop(); }; LexNewLineOrOpt - : { CYLEX(); if (driver.hold_ != empty_symbol) CYERR(@$, "unexpected hold"); if (driver.newline_) { driver.hold_ = yyla.type; yyla.type = yytranslate_(cy::parser::token::NewLine); } } + : { CYLEX(); if (driver.newline_) { CYHLD(@$, tk::NewLine); } } ; LexNewLineOrNot - : { CYLEX(); if (driver.hold_ != empty_symbol) CYERR(@$, "unexpected hold"); driver.hold_ = yyla.type; yyla.type = yytranslate_(driver.newline_ ? cy::parser::token::NewLine : cy::parser::token::__); } + : { CYLEX(); CYHLD(@$, driver.newline_ ? tk::NewLine : tk::__); } ; LexNoStar -- 2.47.2