In this assignment you will demonstrate:
Although your team will be turning in only one submission, every team member is individually responsible for each of the following:
Skim:
Watch:
As usual, turn in a single submission for your entire group via BrightSpace. Remember to not simply partition the work among team members, as this reduces your learning.
Your team's BrightSpace submission should be an attached PDF or text file with:
Solutions to these problems will appear in the beautifully formatted PDF that you will submit to BrightSpace. For problems involving code to write, host your code on GitHub or Replit or OneCompiler (or similar) and provide the link to the hosting site in your BrightSpace submission.
Classify the following as a syntax error, static semantic (contextual) error, or not a compile time error. In the case where code is given, assume all identifiers are declared, have the expected type, and are in scope. All items refer to the Java language.
x+++-y
x---+y
null instanceof C
!!x
x > y > zif (a instanceof Dog d) {...}var s = """This is weird""";switch = 200;x = switch (e) {case 1->5; default->8;};
var x = 3; // line 1
function f() { // line 2
print(x); // line 3
var x = x + 2; // line 4
print(x); // line 5
} // line 6
f(); // line 7
You are going to play the role of a language designer here. Assume static, nested scoping. For each of the following outputs, define precise rules that might lead to the given output. For example, if the output were 3 then 5, you would say “Variables come into scope after their declaration and before their declaration identifiers refer to whatever is already in scope.”
undefined
NaN
Error on line 3: x is not declared
75354253672
75354253674
3
-23482937128
Error on line 4: x used in its own declaration
function countDownFrom10() {
let i = 10;
function update() {
document.getElementById("t").innerHTML = i;
if (i-- > 0) setTimeout(update, 1000);
}
update();
}

Your other friend says “Yikes, you are updating a non-local variable! Here is a better way:”
function countDownFromTen() {
function update(i) {
document.getElementById("t").innerHTML = i;
if (i-- > 0) setTimeout(update(i), 1000);
}
update(10);
}

What does your second friend’s function do when called? Why does it fail? Your friend is on the right path though. Fix their code and explain why your fix works.
import java.util.HashMap;
class C {
static final HashMap<String, Integer> m = new HashMap<String, Integer>();
static int zero() {
return 0;
}
public C() {
}
}

You can use SonarLint or FindBugs or FindSecBugs or PMD or whatever you prefer. You might even need to use a combination of tools because it is possible no tool finds them all. (Please note you are not expected to already know what all the issues are here. The idea is to practice with tools and have good discussions with teammates. Find as many as you can, and read and understand each problem that is reported to you so you learn (1) what kinds of potential bugs and security problems can exist even in compilable and runnable code, and (2) the kinds of things that a static analyzer can detect.)
Continue your compiler project in the public GitHub repository you created in the first assignment. You will be expanding your repo to have the following:
.
├── .gitignore
├── README.md
├── LICENSE
├── package.json -- configuration because this is a Node.js app
├── .prettierrc.json -- (optional, you don’t have to have one)
├── docs
│ └── ... -- now with the companion website
├── examples
│ └── ... -- lots of example programs
├── src
│ ├── (yourlanguagename).js
│ ├── (yourlanguagename).ohm
│ ├── compiler.js -- slightly expanded to include the static analyzer
│ ├── core.js -- new!
│ ├── parser.js -- as before
│ ├── analyzer.js -- with a completed static analyzer!
│ ├── optimizer.js -- still contains just the stub function
│ └── generator.js -- still contains just the stub function
└── test
├── compiler.test.js -- expanded form before
├── parser.test.js -- as before, but improve from HW2 feedback
└── analyzer.test.js -- add in tests for context checking
Your tasks for this assignment are twofold. First, you are to implement the static analyzer for your compiler. Second, you are to start a companion website for your language.
return, break, etc.
Make sure your language has a non-trivial number of contextual rules to be enforced at compile time. Generally speaking, your language should feature static types. If it does not, make up for the lack of type checking with something really special, like really a really sophisticated concurrency mechanism that will require more sophisticated code generation and optimization in later assignments.
For your language website (a.k.a. a “Home Page”) for your programming language using GitHub Pages. The site’s page (or pages) should consist of a single page and:
To help you get a good score, here are all the things you will be graded on.
Problem 1 (13 pts) accuracy
Problem 2 (10 pts) accuracy
Problem 3 (5 pts) accuracy
Problem 4 (5 pts) accuracy
Problem 5 (5 pts) accuracy
Problem 6 (5 pts) accuracy
Problem 7 (5 pts) accuracy
Your project can be cloned (1 pt)
In the project README, there is a link to your GitHub Pages site (1 pt)
I can run npm test immediately after cloning (1 pt)
All tests pass, and there are enough of them (3 pts)
The context is managed well—preferably in an object (7 pts)
The error handling is well-structured—nice check functions or methods (5 pts)
At least five interesting static checks (7 pts)
Analysis method are written like a pro—they work, and well named, etc. (6 pts)
You have at least 50 tests in your suite (5 pts, all or nothing)
The list of static errors are on the README or on your language website (3 pts)
Test coverage is 100% (3 pts, all or nothing)
The GH Pages site looks great: nice template, or hand-crafted CSS (3 pts)
Site has the story of your language in no more than three paragraphs (2 pts)
Site shows at least fives example programs your language (2 pts)
Site has developer names and short bios (2 pts)
Site points back to the repo (1 pt)