Skip to content

Commit 9b5634a

Browse files
committed
add slides, minor tweaks to whitespace
1 parent ed0c140 commit 9b5634a

File tree

4 files changed

+29
-25
lines changed

4 files changed

+29
-25
lines changed

SOLUTION/solution.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ def main():
397397
# REPLACE # Uncomment when you get to step 4
398398
subshell_test = step1_parse_script("sh/subshells.sh") # COMMENT
399399
subshell_count = step4_subshells(subshell_test) # COMMENT
400-
assert 4 <= subshell_count and subshell_count <= 5, "subshell counting is not correct" # COMMENT
400+
assert subshell_count in [4, 5], "subshell counting is not correct" # COMMENT
401401

402402
## Step 5: Safe to expand subtrees
403403

sh/redact.sh

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ fi
1212

1313
[ -f "$1" ] || { echo "redact.sh: '$1' is not a regular file"; exit 1; }
1414

15-
grep -v "# REMOVE" "$1" |
16-
sed -E 's/^(\s*).*# REPLACE (.*)$/\1\2/' |
17-
sed -E 's/^(\s*)(.*)# COMMENT.*$/\1# \2/' |
18-
sed -E 's/SOLUTION/src/g'
19-
15+
grep -v "# REMOVE" "$1" |
16+
sed -E 's/^(\s*).*# REPLACE (.*)$/\1\2/' |
17+
sed -E 's/^(\s*)(.*) \s*# COMMENT.*$/\1# \2/' |
18+
sed -E 's/SOLUTION/src/g'

slides.pdf

770 KB
Binary file not shown.

src/solution.py

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -355,15 +355,20 @@ def main():
355355

356356
## Step 2: Walk and print
357357
# Uncomment when you get to step 2
358-
# step2_walk_print(original_ast)
358+
# step2_walk_print(original_ast)
359359

360360
## Step 3: Unparse
361361
# Uncomment when you get to step 3
362-
# step3_unparse(original_ast)
362+
# step3_unparse(original_ast)
363363

364364
## Step 4: Feature counter
365365
# Uncomment when you get to step 4
366-
# step4_subshells(original_ast)
366+
# step4_subshells(original_ast)
367+
368+
# Uncomment when you get to step 4
369+
# subshell_test = step1_parse_script("sh/subshells.sh")
370+
# subshell_count = step4_subshells(subshell_test)
371+
# assert subshell_count in [4, 5], "subshell counting is not correct"
367372

368373
# Uncomment when you get to step 4
369374
# subshell_test = step1_parse_script("sh/subshells.sh")
@@ -374,34 +379,34 @@ def main():
374379

375380
# tests for is_effect_free
376381
# Uncomment when you get to step 5
377-
# ef_test = step1_parse_script("sh/effectful.sh")
378-
# for (node, _, _, _) in ef_test:
379-
# pretty = node.pretty()
380-
# safe = is_effect_free(node)
381-
# assert safe == ("I am not effectful" in pretty)
382-
# print("🎉 CONGRATULATIONS! YOU WROTE YOUR FIRST SHELL ANALYSIS!!!!! 🎉")
382+
# ef_test = step1_parse_script("sh/effectful.sh")
383+
# for (node, _, _, _) in ef_test:
384+
# pretty = node.pretty()
385+
# safe = is_effect_free(node)
386+
# assert safe == ("I am not effectful" in pretty)
387+
# print("🎉 CONGRATULATIONS! YOU WROTE YOUR FIRST SHELL ANALYSIS!!!!! 🎉")
383388

384-
# step5_effect_free(original_ast)
389+
# step5_effect_free(original_ast)
385390

386391
## Part 2
387392

388393
## Step 6: Preprocess and print each command
389394
# Uncomment when you get to step 6
390-
# preprocessed_script = step6_stubs(original_ast)
391-
# with open(f"{input_script}.preprocessed.1", "w", encoding="utf-8") as out_file:
392-
# print(preprocessed_script, file=out_file)
395+
# preprocessed_script = step6_stubs(original_ast)
396+
# with open(f"{input_script}.preprocessed.1", "w", encoding="utf-8") as out_file:
397+
# print(preprocessed_script, file=out_file)
393398

394399
## Step 7: Preprocess using the JIT
395400
# Uncomment when you get to step 7
396-
# preprocessed_script = step7_debug_jit(original_ast)
397-
# with open(f"{input_script}.preprocessed.2", "w", encoding="utf-8") as out_file:
398-
# print(preprocessed_script, file=out_file)
401+
# preprocessed_script = step7_debug_jit(original_ast)
402+
# with open(f"{input_script}.preprocessed.2", "w", encoding="utf-8") as out_file:
403+
# print(preprocessed_script, file=out_file)
399404

400405
## Step 8: Preprocess using the JIT and expand before executing
401406
# Uncomment when you get to step 8
402-
# preprocessed_script = step8_try_unsafe(original_ast)
403-
# with open(f"{input_script}.preprocessed.3", "w", encoding="utf-8") as out_file:
404-
# print(preprocessed_script, file=out_file)
407+
# preprocessed_script = step8_try_unsafe(original_ast)
408+
# with open(f"{input_script}.preprocessed.3", "w", encoding="utf-8") as out_file:
409+
# print(preprocessed_script, file=out_file)
405410

406411

407412
if __name__ == "__main__":

0 commit comments

Comments
 (0)