From 19c0e8cac62496bada831a41848244c2eb7c454d Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Mon, 5 Jun 2023 18:35:37 +0800 Subject: [PATCH] ... --- src/lexer.h | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/src/lexer.h b/src/lexer.h index e8d9f945..c25cb2a9 100644 --- a/src/lexer.h +++ b/src/lexer.h @@ -266,24 +266,20 @@ struct Lexer { }; // handle "not in", "is not", "yield from" if(!nexts.empty()){ - switch(nexts.back().type){ - case TK("not"): - if(type == TK("in")) { - nexts.back().type = TK("not in"); - return; - } - case TK("is"): - if(type == TK("not")){ - nexts.back().type = TK("is not"); - return; - } - case TK("yield"): - if(type == TK("from")){ - nexts.back().type = TK("yield from"); - return; - } - default: nexts.push_back(token); return; + auto& back = nexts.back(); + if(back.type == TK("not") && type == TK("in")){ + back.type = TK("not in"); + return; } + if(back.type == TK("is") && type == TK("not")){ + back.type = TK("is not"); + return; + } + if(back.type == TK("yield") && type == TK("from")){ + back.type = TK("yield from"); + return; + } + nexts.push_back(token); } }