Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loop argument parsing issue #249

Merged
merged 5 commits into from
May 11, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion compiler/ast_to_ir.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,6 @@ def replace_ast_regions(ast_objects, irFileGen, config):
# log("Preprocessing AST {}".format(i))
# log(ast_object)
ast, original_text, _linno_before, _linno_after = ast_object

## TODO: Turn the untyped ast to an AstNode

## Goals: This transformation can approximate in several directions.
Expand Down
2 changes: 1 addition & 1 deletion compiler/parser/ceda/ast2a.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def of_node (n_ptr):
elif (n.type == NFOR):
return ["For",
[n.nfor.linno,
to_arg (n.nfor.args.contents.narg),
to_args (n.nfor.args),
of_node (n.nfor.body),
n.nfor.var.decode ("charmap")]];
elif (n.type == NDEFUN):
Expand Down
2 changes: 1 addition & 1 deletion compiler/parser/ceda/ast2shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def to_string (ast):
elif (type == "For"):
(_, a, body, var) = params;

return "for " + var + " in " + string_of_arg (a) + "; do " + \
return "for " + var + " in " + separated (string_of_arg, a) + "; do " + \
to_string (body) + "; done";
elif (type == "Case"):
(_, a, cs) = params;
Expand Down
3 changes: 3 additions & 0 deletions evaluation/tests/interface_tests/loop1.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
for idFor1 in A B ; do
echo $idFor1
done
9 changes: 8 additions & 1 deletion evaluation/tests/interface_tests/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,19 @@ test4()
$shell -c 'shift; echo $1 $2' pash 2 3 4 5
}

test6()
{
local shell=$1
$shell loop1.sh
}

## We run all tests composed with && to exit on the first that fails
if [ "$#" -eq 0 ]; then
run_test test1 &&
run_test test2 &&
run_test test3 &&
run_test test4
run_test test4 &&
run_test test6
else
for testname in $@
do
Expand Down