Skip to content

Commit

Permalink
Merge branch 'cycle' into 'master'
Browse files Browse the repository at this point in the history
AST: Add stmt_name for cycle

See merge request lfortran/lfortran!910
  • Loading branch information
certik committed Apr 20, 2021
2 parents 15e538b + 6a16889 commit 67a2cd4
Show file tree
Hide file tree
Showing 16 changed files with 37 additions and 24 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,5 @@ MANIFEST
output
*.o
*.out
*.mod
/.ccls-cache/
4 changes: 2 additions & 2 deletions grammar/AST.asdl
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,10 @@ stmt
| Backspace(int label, expr* args, keyword* kwargs)
| Close(int label, expr* args, keyword* kwargs)
| Continue(int label)
| Cycle(int label)
| Cycle(int label, identifier? stmt_name)
| Deallocate(int label, fnarg* args)
| ErrorStop(int label, expr? code)
| Exit(int label)
| Exit(int label, identifier? stmt_name)
| Format(int label, string fmt)
| GoTo(int label, int goto_label)
| Inquire(int label, expr* args, keyword* kwargs, expr* values)
Expand Down
8 changes: 8 additions & 0 deletions src/lfortran/ast_to_src.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1394,6 +1394,10 @@ class ASTToSRCVisitor : public BaseVisitor<ASTToSRCVisitor>
r += syn(gr::Keyword);
r.append("cycle");
r += syn();
if (x.m_stmt_name) {
r += " ";
r += x.m_stmt_name;
}
r += "\n";
s = r;
}
Expand All @@ -1414,6 +1418,10 @@ class ASTToSRCVisitor : public BaseVisitor<ASTToSRCVisitor>
r += syn(gr::Keyword);
r.append("exit");
r += syn();
if (x.m_stmt_name) {
r += " ";
r += x.m_stmt_name;
}
r += "\n";
s = r;
}
Expand Down
6 changes: 4 additions & 2 deletions src/lfortran/parser/parser.yy
Original file line number Diff line number Diff line change
Expand Up @@ -1405,15 +1405,17 @@ endwhere
;

exit_statement
: KW_EXIT id_opt { $$ = EXIT(@$); }
: KW_EXIT { $$ = EXIT(@$); }
| KW_EXIT id { $$ = EXIT2($2, @$); }
;

return_statement
: KW_RETURN { $$ = RETURN(@$); }
;

cycle_statement
: KW_CYCLE id_opt { $$ = CYCLE(@$); }
: KW_CYCLE { $$ = CYCLE(@$); }
| KW_CYCLE id { $$ = CYCLE2($2, @$); }
;

continue_statement
Expand Down
6 changes: 4 additions & 2 deletions src/lfortran/parser/semantics.h
Original file line number Diff line number Diff line change
Expand Up @@ -838,9 +838,11 @@ char* format_to_str(Allocator &al, Location &loc, const std::string &inp) {
#define ERROR_STOP(l) make_ErrorStop_t(p.m_a, l, 0, nullptr)
#define ERROR_STOP1(e, l) make_ErrorStop_t(p.m_a, l, 0, EXPR(e))

#define EXIT(l) make_Exit_t(p.m_a, l, 0)
#define EXIT(l) make_Exit_t(p.m_a, l, 0, nullptr)
#define EXIT2(id, l) make_Exit_t(p.m_a, l, 0, name2char(id))
#define RETURN(l) make_Return_t(p.m_a, l, 0)
#define CYCLE(l) make_Cycle_t(p.m_a, l, 0)
#define CYCLE(l) make_Cycle_t(p.m_a, l, 0, nullptr)
#define CYCLE2(id, l) make_Cycle_t(p.m_a, l, 0, name2char(id))
#define CONTINUE(l) make_Continue_t(p.m_a, l, 0)
#define SUBROUTINE(name, args, bind, use, import, implicit, decl, stmts, contains, l) \
make_Subroutine_t(p.m_a, l, \
Expand Down
12 changes: 6 additions & 6 deletions src/lfortran/tests/ref_pickle.txt
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ stop
(WhileLoop 0 () x [(= 0 enddo 5)])
(WhileLoop 0 () (> x 5) [(= 0 a 5)])
(WhileLoop 0 () (> x 5) [(= 0 a 5)])
(WhileLoop 0 () (== x y) [(= 0 i (+ i 1)) (Cycle 0) (Exit 0)])
(WhileLoop 0 () (== x y) [(= 0 i (+ i 1)) (Cycle 0 ()) (Exit 0 ())])
(Select 0 () k [(CaseStmt [1] [(SubroutineCall 0 a [] [])]) (CaseStmt [i] [(SubroutineCall 0 b [] []) (SubroutineCall 0 c [] [])])] [])
(Select 0 () k [(CaseStmt [1] [(SubroutineCall 0 a [] [])]) (CaseStmt [i] [(SubroutineCall 0 b [] []) (= 0 a 5)])] [(SubroutineCall 0 c [] [])])
(Where 0 () (< a 5) [(= 0 B 1)] [])
Expand Down Expand Up @@ -280,16 +280,16 @@ return
(+ return 1)
(= 0 return 1)
(= 0 a return)
(DoLoop 0 () i 1 5 () [(Cycle 0)])
(WhileLoop 0 () x [(Cycle 0)])
(DoLoop 0 () i 1 5 () [(Cycle 0 ())])
(WhileLoop 0 () x [(Cycle 0 ())])
(DoLoop 0 () i 1 5 () [(= 0 cycle 5)])
cycle
(+ cycle 1)
(= 0 cycle 1)
(= 0 a cycle)
(DoLoop 0 () i 1 5 () [(Exit 0)])
(DoLoop 0 () () () () () [(Exit 0)])
(WhileLoop 0 () x [(Exit 0)])
(DoLoop 0 () i 1 5 () [(Exit 0 ())])
(DoLoop 0 () () () () () [(Exit 0 ())])
(WhileLoop 0 () x [(Exit 0 ())])
(DoLoop 0 () i 1 5 () [(= 0 exit 5)])
exit
(+ exit 1)
Expand Down
2 changes: 1 addition & 1 deletion tests/reference/ast-doloop_04-4703a43.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"outfile": null,
"outfile_hash": null,
"stdout": "ast-doloop_04-4703a43.stdout",
"stdout_hash": "b10af316753d804fc892445d8fc1a552e1408c97290c78b726516876",
"stdout_hash": "633f8d4f39046d3d5a831f7e32602acfa56c7267fbda558d2489d18e",
"stderr": null,
"stderr_hash": null,
"returncode": 0
Expand Down
2 changes: 1 addition & 1 deletion tests/reference/ast-doloop_04-4703a43.stdout
Original file line number Diff line number Diff line change
@@ -1 +1 @@
(TranslationUnit [(Program doloop_04 [] [(ImplicitNone [])] [(Declaration (AttrType TypeInteger [] ()) [] [(i [] ()) (j [] ())])] [(= 0 j 0) (DoLoop 0 a i 1 10 () [(= 0 j (+ j i)) (If 0 () (== i 2) [(Exit 0)] [])]) (If 0 () (/= j 3) [(ErrorStop 0 ())] []) (= 0 j 0) (DoLoop 0 b i 1 10 2 [(= 0 j (+ j i)) (If 0 () (== i 3) [(Exit 0)] [])]) (If 0 () (/= j 4) [(ErrorStop 0 ())] []) (= 0 j 0) (= 0 i 1) (DoLoop 0 c () () () () [(= 0 j (+ j i)) (If 0 () (== i 2) [(Exit 0)] []) (= 0 i (+ i 1))]) (If 0 () (/= j 3) [(ErrorStop 0 ())] [])] [])])
(TranslationUnit [(Program doloop_04 [] [(ImplicitNone [])] [(Declaration (AttrType TypeInteger [] ()) [] [(i [] ()) (j [] ())])] [(= 0 j 0) (DoLoop 0 a i 1 10 () [(= 0 j (+ j i)) (If 0 () (== i 2) [(Exit 0 a)] [])]) (If 0 () (/= j 3) [(ErrorStop 0 ())] []) (= 0 j 0) (DoLoop 0 b i 1 10 2 [(= 0 j (+ j i)) (If 0 () (== i 3) [(Exit 0 b)] [])]) (If 0 () (/= j 4) [(ErrorStop 0 ())] []) (= 0 j 0) (= 0 i 1) (DoLoop 0 c () () () () [(= 0 j (+ j i)) (If 0 () (== i 2) [(Exit 0 c)] []) (= 0 i (+ i 1))]) (If 0 () (/= j 3) [(ErrorStop 0 ())] [])] [])])
2 changes: 1 addition & 1 deletion tests/reference/ast-modules_02-dc19c13.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"outfile": null,
"outfile_hash": null,
"stdout": "ast-modules_02-dc19c13.stdout",
"stdout_hash": "f449f0c403133f3e7b7b75cb61e30fdf8d55aee907af5ef8438cc9b6",
"stdout_hash": "43063d6786fe086bf0d45a7f9b5578fdf5c9d85f55315644d9e12eb8",
"stderr": null,
"stderr_hash": null,
"returncode": 0
Expand Down
2 changes: 1 addition & 1 deletion tests/reference/ast-modules_02-dc19c13.stdout
Original file line number Diff line number Diff line change
@@ -1 +1 @@
(TranslationUnit [(Module random [(Use types [(UseSymbol dp ())]) (Use utils [(UseSymbol stop_error ())])] [(ImplicitNone [])] [(Declaration () [(SimpleAttribute AttrPrivate)] []) (Declaration () [(SimpleAttribute AttrPublic)] [(randn [] ()) (rand_gamma [] ())]) (Interface (InterfaceHeader2 randn) [(InterfaceModuleProcedure [randn_scalar]) (InterfaceModuleProcedure [randn_vector]) (InterfaceModuleProcedure [randn_matrix]) (InterfaceModuleProcedure [randn_vector_n])]) (Interface (InterfaceHeader2 rand_gamma) [(InterfaceModuleProcedure [rand_gamma_scalar]) (InterfaceModuleProcedure [rand_gamma_vector]) (InterfaceModuleProcedure [rand_gamma_matrix]) (InterfaceModuleProcedure [rand_gamma_vector_n])])] [(Subroutine randn_scalar [(x)] () [] [] [] [(Declaration (AttrType TypeReal [(() dp Value)] ()) [(AttrIntent Out)] [(x [] ())]) (Declaration (AttrType TypeLogical [] ()) [(SimpleAttribute AttrSave)] [(first [] (Logical .true.))]) (Declaration (AttrType TypeReal [(() dp Value)] ()) [(SimpleAttribute AttrSave)] [(u [(1 2 DimensionExpr)] ())]) (Declaration (AttrType TypeReal [(() dp Value)] ()) [] [(r2 [] ())])] [(If 0 () first [(DoLoop 0 () () () () () [(SubroutineCall 0 random_number [(() u ())] []) (= 0 u (- (* 2 u) 1)) (= 0 r2 (FuncCallOrArray sum [] [(() (** u 2) ())] [])) (If 0 () (BoolOp (< r2 1) And (> r2 0)) [(Exit 0)] [])]) (= 0 u (* u (FuncCallOrArray sqrt [] [(() (/ (* (u- 2) (FuncCallOrArray log [] [(() r2 ())] [])) r2) ())] []))) (= 0 x (FuncCallOrArray u [] [(() 1 ())] []))] [(= 0 x (FuncCallOrArray u [] [(() 2 ())] []))]) (= 0 first (not first))] []) (Subroutine randn_vector_n [(n) (x)] () [] [] [] [(Declaration (AttrType TypeInteger [] ()) [(AttrIntent In)] [(n [] ())]) (Declaration (AttrType TypeReal [(() dp Value)] ()) [(AttrIntent Out)] [(x [(1 n DimensionExpr)] ())]) (Declaration (AttrType TypeInteger [] ()) [] [(i [] ())])] [(DoLoop 0 () i 1 (FuncCallOrArray size [] [(() x ())] []) () [(SubroutineCall 0 randn [(() (FuncCallOrArray x [] [(() i ())] []) ())] [])])] []) (Subroutine randn_vector [(x)] () [] [] [] [(Declaration (AttrType TypeReal [(() dp Value)] ()) [(AttrIntent Out)] [(x [(() () DimensionExpr)] ())])] [(SubroutineCall 0 randn_vector_n [(() (FuncCallOrArray size [] [(() x ())] []) ()) (() x ())] [])] []) (Subroutine randn_matrix [(x)] () [] [] [] [(Declaration (AttrType TypeReal [(() dp Value)] ()) [(AttrIntent Out)] [(x [(() () DimensionExpr) (() () DimensionExpr)] ())])] [(SubroutineCall 0 randn_vector_n [(() (FuncCallOrArray size [] [(() x ())] []) ()) (() x ())] [])] []) (Subroutine rand_gamma0 [(a) (first) (fn_val)] () [] [] [] [(Declaration (AttrType TypeReal [(() dp Value)] ()) [(AttrIntent In)] [(a [] ())]) (Declaration (AttrType TypeLogical [] ()) [(AttrIntent In)] [(first [] ())]) (Declaration (AttrType TypeReal [(() dp Value)] ()) [(AttrIntent Out)] [(fn_val [] ())]) (Declaration (AttrType TypeReal [(() dp Value)] ()) [(SimpleAttribute AttrSave)] [(c [] ()) (d [] ())]) (Declaration (AttrType TypeReal [(() dp Value)] ()) [] [(U [] ()) (v [] ()) (x [] ())])] [(If 0 () (< a 1) [(SubroutineCall 0 stop_error [(() (Str "Shape parameter must be >= 1") ())] [])] []) (If 0 () first [(= 0 d (- a (/ (Real "1._dp") 3))) (= 0 c (/ 1 (FuncCallOrArray sqrt [] [(() (* 9 d) ())] [])))] []) (DoLoop 0 () () () () () [(DoLoop 0 () () () () () [(SubroutineCall 0 randn [(() x ())] []) (= 0 v (** (+ 1 (* c x)) 3)) (If 0 () (> v 0) [(Exit 0)] [])]) (SubroutineCall 0 random_number [(() U ())] []) (If 0 () (< U (- 1 (* (Real "0.0331_dp") (** x 4)))) [(= 0 fn_val (* d v)) (Exit 0)] [(If 0 () (< (FuncCallOrArray log [] [(() U ())] []) (+ (/ (** x 2) 2) (* d (+ (- 1 v) (FuncCallOrArray log [] [(() v ())] []))))) [(= 0 fn_val (* d v)) (Exit 0)] [])])])] []) (Subroutine rand_gamma_scalar [(a) (x)] () [] [] [] [(Declaration (AttrType TypeReal [(() dp Value)] ()) [(AttrIntent In)] [(a [] ())]) (Declaration (AttrType TypeReal [(() dp Value)] ()) [(AttrIntent Out)] [(x [] ())])] [(SubroutineCall 0 rand_gamma0 [(() a ()) (() (Logical .true.) ()) (() x ())] [])] []) (Subroutine rand_gamma_vector_n [(a) (n) (x)] () [] [] [] [(Declaration (AttrType TypeReal [(() dp Value)] ()) [(AttrIntent In)] [(a [] ())]) (Declaration (AttrType TypeInteger [] ()) [(AttrIntent In)] [(n [] ())]) (Declaration (AttrType TypeReal [(() dp Value)] ()) [(AttrIntent Out)] [(x [(1 n DimensionExpr)] ())]) (Declaration (AttrType TypeInteger [] ()) [] [(i [] ())])] [(SubroutineCall 0 rand_gamma0 [(() a ()) (() (Logical .true.) ()) (() (FuncCallOrArray x [] [(() 1 ())] []) ())] []) (DoLoop 0 () i 2 (FuncCallOrArray size [] [(() x ())] []) () [(SubroutineCall 0 rand_gamma0 [(() a ()) (() (Logical .false.) ()) (() (FuncCallOrArray x [] [(() i ())] []) ())] [])])] []) (Subroutine rand_gamma_vector [(a) (x)] () [] [] [] [(Declaration (AttrType TypeReal [(() dp Value)] ()) [(AttrIntent In)] [(a [] ())]) (Declaration (AttrType TypeReal [(() dp Value)] ()) [(AttrIntent Out)] [(x [(() () DimensionExpr)] ())])] [(SubroutineCall 0 rand_gamma_vector_n [(() a ()) (() (FuncCallOrArray size [] [(() x ())] []) ()) (() x ())] [])] []) (Subroutine rand_gamma_matrix [(a) (x)] () [] [] [] [(Declaration (AttrType TypeReal [(() dp Value)] ()) [(AttrIntent In)] [(a [] ())]) (Declaration (AttrType TypeReal [(() dp Value)] ()) [(AttrIntent Out)] [(x [(() () DimensionExpr) (() () DimensionExpr)] ())])] [(SubroutineCall 0 rand_gamma_vector_n [(() a ()) (() (FuncCallOrArray size [] [(() x ())] []) ()) (() x ())] [])] [])])])
(TranslationUnit [(Module random [(Use types [(UseSymbol dp ())]) (Use utils [(UseSymbol stop_error ())])] [(ImplicitNone [])] [(Declaration () [(SimpleAttribute AttrPrivate)] []) (Declaration () [(SimpleAttribute AttrPublic)] [(randn [] ()) (rand_gamma [] ())]) (Interface (InterfaceHeader2 randn) [(InterfaceModuleProcedure [randn_scalar]) (InterfaceModuleProcedure [randn_vector]) (InterfaceModuleProcedure [randn_matrix]) (InterfaceModuleProcedure [randn_vector_n])]) (Interface (InterfaceHeader2 rand_gamma) [(InterfaceModuleProcedure [rand_gamma_scalar]) (InterfaceModuleProcedure [rand_gamma_vector]) (InterfaceModuleProcedure [rand_gamma_matrix]) (InterfaceModuleProcedure [rand_gamma_vector_n])])] [(Subroutine randn_scalar [(x)] () [] [] [] [(Declaration (AttrType TypeReal [(() dp Value)] ()) [(AttrIntent Out)] [(x [] ())]) (Declaration (AttrType TypeLogical [] ()) [(SimpleAttribute AttrSave)] [(first [] (Logical .true.))]) (Declaration (AttrType TypeReal [(() dp Value)] ()) [(SimpleAttribute AttrSave)] [(u [(1 2 DimensionExpr)] ())]) (Declaration (AttrType TypeReal [(() dp Value)] ()) [] [(r2 [] ())])] [(If 0 () first [(DoLoop 0 () () () () () [(SubroutineCall 0 random_number [(() u ())] []) (= 0 u (- (* 2 u) 1)) (= 0 r2 (FuncCallOrArray sum [] [(() (** u 2) ())] [])) (If 0 () (BoolOp (< r2 1) And (> r2 0)) [(Exit 0 ())] [])]) (= 0 u (* u (FuncCallOrArray sqrt [] [(() (/ (* (u- 2) (FuncCallOrArray log [] [(() r2 ())] [])) r2) ())] []))) (= 0 x (FuncCallOrArray u [] [(() 1 ())] []))] [(= 0 x (FuncCallOrArray u [] [(() 2 ())] []))]) (= 0 first (not first))] []) (Subroutine randn_vector_n [(n) (x)] () [] [] [] [(Declaration (AttrType TypeInteger [] ()) [(AttrIntent In)] [(n [] ())]) (Declaration (AttrType TypeReal [(() dp Value)] ()) [(AttrIntent Out)] [(x [(1 n DimensionExpr)] ())]) (Declaration (AttrType TypeInteger [] ()) [] [(i [] ())])] [(DoLoop 0 () i 1 (FuncCallOrArray size [] [(() x ())] []) () [(SubroutineCall 0 randn [(() (FuncCallOrArray x [] [(() i ())] []) ())] [])])] []) (Subroutine randn_vector [(x)] () [] [] [] [(Declaration (AttrType TypeReal [(() dp Value)] ()) [(AttrIntent Out)] [(x [(() () DimensionExpr)] ())])] [(SubroutineCall 0 randn_vector_n [(() (FuncCallOrArray size [] [(() x ())] []) ()) (() x ())] [])] []) (Subroutine randn_matrix [(x)] () [] [] [] [(Declaration (AttrType TypeReal [(() dp Value)] ()) [(AttrIntent Out)] [(x [(() () DimensionExpr) (() () DimensionExpr)] ())])] [(SubroutineCall 0 randn_vector_n [(() (FuncCallOrArray size [] [(() x ())] []) ()) (() x ())] [])] []) (Subroutine rand_gamma0 [(a) (first) (fn_val)] () [] [] [] [(Declaration (AttrType TypeReal [(() dp Value)] ()) [(AttrIntent In)] [(a [] ())]) (Declaration (AttrType TypeLogical [] ()) [(AttrIntent In)] [(first [] ())]) (Declaration (AttrType TypeReal [(() dp Value)] ()) [(AttrIntent Out)] [(fn_val [] ())]) (Declaration (AttrType TypeReal [(() dp Value)] ()) [(SimpleAttribute AttrSave)] [(c [] ()) (d [] ())]) (Declaration (AttrType TypeReal [(() dp Value)] ()) [] [(U [] ()) (v [] ()) (x [] ())])] [(If 0 () (< a 1) [(SubroutineCall 0 stop_error [(() (Str "Shape parameter must be >= 1") ())] [])] []) (If 0 () first [(= 0 d (- a (/ (Real "1._dp") 3))) (= 0 c (/ 1 (FuncCallOrArray sqrt [] [(() (* 9 d) ())] [])))] []) (DoLoop 0 () () () () () [(DoLoop 0 () () () () () [(SubroutineCall 0 randn [(() x ())] []) (= 0 v (** (+ 1 (* c x)) 3)) (If 0 () (> v 0) [(Exit 0 ())] [])]) (SubroutineCall 0 random_number [(() U ())] []) (If 0 () (< U (- 1 (* (Real "0.0331_dp") (** x 4)))) [(= 0 fn_val (* d v)) (Exit 0 ())] [(If 0 () (< (FuncCallOrArray log [] [(() U ())] []) (+ (/ (** x 2) 2) (* d (+ (- 1 v) (FuncCallOrArray log [] [(() v ())] []))))) [(= 0 fn_val (* d v)) (Exit 0 ())] [])])])] []) (Subroutine rand_gamma_scalar [(a) (x)] () [] [] [] [(Declaration (AttrType TypeReal [(() dp Value)] ()) [(AttrIntent In)] [(a [] ())]) (Declaration (AttrType TypeReal [(() dp Value)] ()) [(AttrIntent Out)] [(x [] ())])] [(SubroutineCall 0 rand_gamma0 [(() a ()) (() (Logical .true.) ()) (() x ())] [])] []) (Subroutine rand_gamma_vector_n [(a) (n) (x)] () [] [] [] [(Declaration (AttrType TypeReal [(() dp Value)] ()) [(AttrIntent In)] [(a [] ())]) (Declaration (AttrType TypeInteger [] ()) [(AttrIntent In)] [(n [] ())]) (Declaration (AttrType TypeReal [(() dp Value)] ()) [(AttrIntent Out)] [(x [(1 n DimensionExpr)] ())]) (Declaration (AttrType TypeInteger [] ()) [] [(i [] ())])] [(SubroutineCall 0 rand_gamma0 [(() a ()) (() (Logical .true.) ()) (() (FuncCallOrArray x [] [(() 1 ())] []) ())] []) (DoLoop 0 () i 2 (FuncCallOrArray size [] [(() x ())] []) () [(SubroutineCall 0 rand_gamma0 [(() a ()) (() (Logical .false.) ()) (() (FuncCallOrArray x [] [(() i ())] []) ())] [])])] []) (Subroutine rand_gamma_vector [(a) (x)] () [] [] [] [(Declaration (AttrType TypeReal [(() dp Value)] ()) [(AttrIntent In)] [(a [] ())]) (Declaration (AttrType TypeReal [(() dp Value)] ()) [(AttrIntent Out)] [(x [(() () DimensionExpr)] ())])] [(SubroutineCall 0 rand_gamma_vector_n [(() a ()) (() (FuncCallOrArray size [] [(() x ())] []) ()) (() x ())] [])] []) (Subroutine rand_gamma_matrix [(a) (x)] () [] [] [] [(Declaration (AttrType TypeReal [(() dp Value)] ()) [(AttrIntent In)] [(a [] ())]) (Declaration (AttrType TypeReal [(() dp Value)] ()) [(AttrIntent Out)] [(x [(() () DimensionExpr) (() () DimensionExpr)] ())])] [(SubroutineCall 0 rand_gamma_vector_n [(() a ()) (() (FuncCallOrArray size [] [(() x ())] []) ()) (() x ())] [])] [])])])
2 changes: 1 addition & 1 deletion tests/reference/ast-program_01-3f7a7b3.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"outfile": null,
"outfile_hash": null,
"stdout": "ast-program_01-3f7a7b3.stdout",
"stdout_hash": "efb2ddfaa209b4b36cc18c725f72ed74544fb6bc824cbda8c03fb986",
"stdout_hash": "0911dcd95c79bbf5f7f1dd2f2acd197d0ce7c5953fe29c90360fca37",
"stderr": null,
"stderr_hash": null,
"returncode": 0
Expand Down
2 changes: 1 addition & 1 deletion tests/reference/ast-program_01-3f7a7b3.stdout
Original file line number Diff line number Diff line change
@@ -1 +1 @@
(TranslationUnit [(Program program_01 [] [(ImplicitNone [])] [(Declaration (AttrType TypeInteger [] ()) [(SimpleAttribute AttrParameter)] [(dp [] (FuncCallOrArray kind [] [(() (Real "0.d0") ())] []))]) (Declaration (AttrType TypeReal [(() dp Value)] ()) [] [(a [] ())]) (Declaration (AttrType TypeInteger [] ()) [] [(i [] ())])] [(Print 0 () [(Str "Normal random numbers:")]) (DoLoop 0 () i 1 10 () [(SubroutineCall 0 rand [(() a ())] []) (Print 0 () [a])])] [(Subroutine rand [(x)] () [] [] [] [(Declaration (AttrType TypeReal [(() dp Value)] ()) [(AttrIntent Out)] [(x [] ())]) (Declaration (AttrType TypeLogical [] ()) [(SimpleAttribute AttrSave)] [(first [] (Logical .true.))]) (Declaration (AttrType TypeReal [(() dp Value)] ()) [(SimpleAttribute AttrSave)] [(u [(1 2 DimensionExpr)] ())]) (Declaration (AttrType TypeReal [(() dp Value)] ()) [] [(r2 [] ())])] [(If 0 () first [(DoLoop 0 () () () () () [(SubroutineCall 0 random_number [(() u ())] []) (= 0 u (- (* 2 u) 1)) (= 0 r2 (FuncCallOrArray sum [] [(() (** u 2) ())] [])) (If 0 () (BoolOp (< r2 1) And (> r2 0)) [(Exit 0)] [])]) (= 0 u (* u (FuncCallOrArray sqrt [] [(() (/ (* (u- 2) (FuncCallOrArray log [] [(() r2 ())] [])) r2) ())] []))) (= 0 x (FuncCallOrArray u [] [(() 1 ())] []))] [(= 0 x (FuncCallOrArray u [] [(() 2 ())] []))]) (= 0 first (not first))] [])])])
(TranslationUnit [(Program program_01 [] [(ImplicitNone [])] [(Declaration (AttrType TypeInteger [] ()) [(SimpleAttribute AttrParameter)] [(dp [] (FuncCallOrArray kind [] [(() (Real "0.d0") ())] []))]) (Declaration (AttrType TypeReal [(() dp Value)] ()) [] [(a [] ())]) (Declaration (AttrType TypeInteger [] ()) [] [(i [] ())])] [(Print 0 () [(Str "Normal random numbers:")]) (DoLoop 0 () i 1 10 () [(SubroutineCall 0 rand [(() a ())] []) (Print 0 () [a])])] [(Subroutine rand [(x)] () [] [] [] [(Declaration (AttrType TypeReal [(() dp Value)] ()) [(AttrIntent Out)] [(x [] ())]) (Declaration (AttrType TypeLogical [] ()) [(SimpleAttribute AttrSave)] [(first [] (Logical .true.))]) (Declaration (AttrType TypeReal [(() dp Value)] ()) [(SimpleAttribute AttrSave)] [(u [(1 2 DimensionExpr)] ())]) (Declaration (AttrType TypeReal [(() dp Value)] ()) [] [(r2 [] ())])] [(If 0 () first [(DoLoop 0 () () () () () [(SubroutineCall 0 random_number [(() u ())] []) (= 0 u (- (* 2 u) 1)) (= 0 r2 (FuncCallOrArray sum [] [(() (** u 2) ())] [])) (If 0 () (BoolOp (< r2 1) And (> r2 0)) [(Exit 0 ())] [])]) (= 0 u (* u (FuncCallOrArray sqrt [] [(() (/ (* (u- 2) (FuncCallOrArray log [] [(() r2 ())] [])) r2) ())] []))) (= 0 x (FuncCallOrArray u [] [(() 1 ())] []))] [(= 0 x (FuncCallOrArray u [] [(() 2 ())] []))]) (= 0 first (not first))] [])])])
2 changes: 1 addition & 1 deletion tests/reference/ast_f90-doloop_04-5f9c26b.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"outfile": null,
"outfile_hash": null,
"stdout": "ast_f90-doloop_04-5f9c26b.stdout",
"stdout_hash": "10ad333cda0662f88ea03e38d3eb7bd85be9772d2b4d1f3463e35456",
"stdout_hash": "a73a5fdea5e1694c864a17d5e918a42398a62fdd473561fa909b7691",
"stderr": null,
"stderr_hash": null,
"returncode": 0
Expand Down
6 changes: 3 additions & 3 deletions tests/reference/ast_f90-doloop_04-5f9c26b.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ j = 0
a: do i = 1, 10
j = (j) + (i)
if ((i)==(2)) then
exit
exit a
end if
end do a
if ((j)/=(3)) then
Expand All @@ -15,7 +15,7 @@ j = 0
b: do i = 1, 10, 2
j = (j) + (i)
if ((i)==(3)) then
exit
exit b
end if
end do b
if ((j)/=(4)) then
Expand All @@ -26,7 +26,7 @@ i = 1
c: do
j = (j) + (i)
if ((i)==(2)) then
exit
exit c
end if
i = (i) + (1)
end do c
Expand Down
2 changes: 1 addition & 1 deletion tests/reference/ast_f90-doloop_05-e26ce68.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"outfile": null,
"outfile_hash": null,
"stdout": "ast_f90-doloop_05-e26ce68.stdout",
"stdout_hash": "52e2f8c0acb07f87245d3aac94cbb411e08a3353dbdc017700e54957",
"stdout_hash": "a4927c1ecd89cf64721d1305fc5440c8af4689f9cce62460c73f2497",
"stderr": null,
"stderr_hash": null,
"returncode": 0
Expand Down
Loading

0 comments on commit 67a2cd4

Please sign in to comment.