mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 03:20:18 +00:00
...
This commit is contained in:
parent
1898c8a434
commit
19c0e8cac6
30
src/lexer.h
30
src/lexer.h
@ -266,24 +266,20 @@ struct Lexer {
|
|||||||
};
|
};
|
||||||
// handle "not in", "is not", "yield from"
|
// handle "not in", "is not", "yield from"
|
||||||
if(!nexts.empty()){
|
if(!nexts.empty()){
|
||||||
switch(nexts.back().type){
|
auto& back = nexts.back();
|
||||||
case TK("not"):
|
if(back.type == TK("not") && type == TK("in")){
|
||||||
if(type == TK("in")) {
|
back.type = TK("not in");
|
||||||
nexts.back().type = TK("not in");
|
return;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user