From 9346a85884c29a781ea005dce697d43983dcffb5 Mon Sep 17 00:00:00 2001 From: Eatswap Date: Sun, 11 Dec 2022 19:49:32 +0800 Subject: [PATCH] fix: use R-values but not only S-Expr --- DragonLisp.y | 6 +++--- sample.lisp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/DragonLisp.y b/DragonLisp.y index 47acfd3..f7c8a13 100644 --- a/DragonLisp.y +++ b/DragonLisp.y @@ -228,9 +228,9 @@ S-Expr-if ; S-Expr-loop - : LOOP S-Exprs { std::printf("Parsed S-Expr-loop -> LOOP S-Exprs\n"); } - | LOOP FOR IDENTIFIER FROM S-Expr TO S-Expr DO S-Exprs { std::printf("Parsed S-Expr-loop -> LOOP FOR IDENTIFIER FROM S-Expr TO S-Expr DO S-Exprs\n"); } - | DOTIMES LPAREN IDENTIFIER S-Expr RPAREN S-Exprs { std::printf("Parsed S-Expr-loop -> DOTIMES ( IDENTIFIER S-Expr ) S-Exprs\n"); } + : LOOP S-Exprs { std::printf("Parsed S-Expr-loop -> LOOP S-Exprs\n"); } + | LOOP FOR IDENTIFIER FROM R-Value TO R-Value DO S-Exprs { std::printf("Parsed S-Expr-loop -> LOOP FOR IDENTIFIER FROM R-Value TO R-Value DO S-Exprs\n"); } + | DOTIMES LPAREN IDENTIFIER R-Value RPAREN S-Exprs { std::printf("Parsed S-Expr-loop -> DOTIMES LPAREN IDENTIFIER R-Value RPAREN S-Exprs\n"); } ; func-def diff --git a/sample.lisp b/sample.lisp index b009ed9..224ba05 100644 --- a/sample.lisp +++ b/sample.lisp @@ -43,7 +43,7 @@ (print "Hello, world!") ; prints Hello, world! (loop - for i from 1 to 10 + for i from 1 to (+ 1505 -1495) do (print i) ) ; prints 1 2 3 4 5 6 7 8 9 10