mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-21 12:00:18 +00:00
up
This commit is contained in:
parent
b56978fd3d
commit
4d7b9d1c7c
@ -359,21 +359,24 @@ private:
|
|||||||
|
|
||||||
// PASS
|
// PASS
|
||||||
void exprList() {
|
void exprList() {
|
||||||
auto e = expr_prev_line<ListExpr>();
|
int line = prev().line;
|
||||||
|
std::vector<Expr_> items;
|
||||||
do {
|
do {
|
||||||
match_newlines(mode()==REPL_MODE);
|
match_newlines(mode()==REPL_MODE);
|
||||||
if (curr().type == TK("]")) break;
|
if (curr().type == TK("]")) break;
|
||||||
EXPR();
|
EXPR();
|
||||||
e->items.push_back(ctx()->s_expr.popx());
|
items.push_back(ctx()->s_expr.popx());
|
||||||
match_newlines(mode()==REPL_MODE);
|
match_newlines(mode()==REPL_MODE);
|
||||||
if(e->items.size()==1 && match(TK("for"))){
|
if(items.size()==1 && match(TK("for"))){
|
||||||
_consume_comp<ListCompExpr>(std::move(e->items[0]));
|
_consume_comp<ListCompExpr>(std::move(items[0]));
|
||||||
consume(TK("]"));
|
consume(TK("]"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
match_newlines(mode()==REPL_MODE);
|
match_newlines(mode()==REPL_MODE);
|
||||||
} while (match(TK(",")));
|
} while (match(TK(",")));
|
||||||
consume(TK("]"));
|
consume(TK("]"));
|
||||||
|
auto e = expr_prev_line<ListExpr>(std::move(items));
|
||||||
|
e->line = line; // override line
|
||||||
ctx()->s_expr.push(std::move(e));
|
ctx()->s_expr.push(std::move(e));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -269,6 +269,7 @@ struct SliceExpr: Expr{
|
|||||||
|
|
||||||
struct SequenceExpr: Expr{
|
struct SequenceExpr: Expr{
|
||||||
std::vector<Expr_> items;
|
std::vector<Expr_> items;
|
||||||
|
SequenceExpr(std::vector<Expr_>&& items): items(std::move(items)) {}
|
||||||
virtual Opcode opcode() const = 0;
|
virtual Opcode opcode() const = 0;
|
||||||
|
|
||||||
void emit(CodeEmitContext* ctx) override {
|
void emit(CodeEmitContext* ctx) override {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user