Code: Jennifer for the classroom
Jennifer for the classroom: the code
The programs behind the slides. They need no server, no decks and no setup beyond Jennifer 0.26.0, and run from this folder. Programs that the slides show being rejected cannot be kept here as .j files (every program in this folder must pass jennifer lint), so two scripts write them to a temporary directory and run them there.
Machine-dependent output: error messages, lint findings and profile rows print the full path of the file (the slides shorten it to the file name), and lint prints the source line with a caret under each finding. The profiler's times differ on every run and machine; the hit counts do not.
repl.shwithrepl.txt: "An interactive REPL". Pipes the lines ofrepl.txtintojennifer repl; piped input is not echoed, so the answers follow the>>>prompts without the typed lines. Run:sh repl.shaverage.j: "A grammar you can read aloud", printsaverage: 85.0. Run:jennifer run average.jlint.sh: "A linter that says what and why". Writes the faultyaverage.j(a mistyped library, an unused local, a line afterreturn) to a temporary directory and lints it. Run:sh lint.shgrade.j: "One format for everyone", the unformatted function. Run:jennifer fmt grade.j(prints the formatted version;jennifer fmt -l grade.jlists it and exits with status 1)fib.j: "A profiler for why is it slow?", recursive Fibonacci of 20. Run:jennifer profile fib.j(add--allocsfor copies of values)tests/grade.jandtests/grade_test.j: "Tests are part of the language".jennifer testloadsgrade.jnext to the test file;testFailfails on purpose, so the run ends with status 1. Run:cd tests && jennifer test grade_test.jrejected.sh: "Conditions must be bool" (cond.j), "Conversions are spelled out" (conv.j) and "Names never shadow" (shadow.j): writes each to a temporary directory and runs it. Run:sh rejected.shconvert.j: the fix from "Conversions are spelled out", printstotal: 10. Run:jennifer run convert.jformat.j: "Formatting you can read", the Jennifer line and the two modifier examples (+0042,dead_beef). Run:jennifer run format.jformat.c.txt: the Cprintfline for comparison, not run here (the shell'sprintf '%-8s %6d %.1f%%\n' Ada 42 97.2gives the same text in a locale with a decimal point).hello.j: "Tokens: what the lexer sees" and "The AST: what the parser builds"; line 2 isdef n as int init 2 + 3;. Run:jennifer tokens hello.jandjennifer ast hello.j(the AST slide shows only theinitpart, trimmed to a few fields per node)
| File | Size | |
|---|---|---|
| LICENSE | 899 B | raw |
| README.md | 2.6 KiB | raw |
| average.j | 190 B | raw |
| convert.j | 210 B | raw |
| fib.j | 140 B | raw |
| format.c.txt | 265 B | raw |
| format.j | 243 B | raw |
| grade.j | 72 B | raw |
| hello.j | 56 B | raw |
| lint.sh | 782 B | raw |
| rejected.sh | 802 B | raw |
| repl.sh | 254 B | raw |
| repl.txt | 38 B | raw |
| tests/grade.j | 212 B | raw |
| tests/grade_test.j | 379 B | raw |