@@ -1200,9 +1200,9 @@ class DictExpr : public Expression {
12001200
12011201class SliceExpr : public Expression {
12021202public:
1203- std::shared_ptr<Expression> start, end;
1204- SliceExpr (const Location & loc, std::shared_ptr<Expression> && s, std::shared_ptr<Expression> && e)
1205- : Expression(loc), start(std::move(s)), end(std::move(e)) {}
1203+ std::shared_ptr<Expression> start, end, step ;
1204+ SliceExpr (const Location & loc, std::shared_ptr<Expression> && s, std::shared_ptr<Expression> && e, std::shared_ptr<Expression> && st = nullptr )
1205+ : Expression(loc), start(std::move(s)), end(std::move(e)), step(std::move(st)) {}
12061206 Value do_evaluate (const std::shared_ptr<Context> &) const override {
12071207 throw std::runtime_error (" SliceExpr not implemented" );
12081208 }
@@ -2084,8 +2084,14 @@ class Parser {
20842084 if (!consumeToken (" [" ).empty ()) {
20852085 std::shared_ptr<Expression> index;
20862086 if (!consumeToken (" :" ).empty ()) {
2087- auto slice_end = parseExpression ();
2088- index = std::make_shared<SliceExpr>(slice_end->location , nullptr , std::move (slice_end));
2087+ if (!consumeToken (" :" ).empty ()) { // case [::N]
2088+ auto step = parseExpression ();
2089+ index = std::make_shared<SliceExpr>(step->location , nullptr , nullptr , std::move (step));
2090+ }
2091+ else {
2092+ auto slice_end = parseExpression ();
2093+ index = std::make_shared<SliceExpr>(slice_end->location , nullptr , std::move (slice_end));
2094+ }
20892095 } else {
20902096 auto slice_start = parseExpression ();
20912097 if (!consumeToken (" :" ).empty ()) {
0 commit comments