The quiz will made available online immediately after class on March 18, and must be turned in by 11:59 p.m. America/Los Angeles time, on March 22. You are allowed only 90 minutes to work on it, but you can choose any 90-minute period in the allotted range.
You need to know:
- A little bit of Computer Science History
- How to write grammars
- Difference between variables and alphabet symbols in a grammar
- Difference between capitalized and non-capitalized variables
- How to give a parse tree for a given derivation in a grammar
- What it means for a grammar to be ambiguous
- How to read and write grammars for simple formal languages and for little programming languages
- Going between prose descriptions of languages and their grammars (both ways)
- What a context-free grammar is
- A sense of what kind of grammars are context-free and which are not
- How to read and make syntax diagrams
- The difference between lexical analysis and parsing
- What tokens are
- The difference between lexical and phrase rules
- Differences between CST and AST and how to draw them
- What the frontier of the CST is made up of
- A lot about ambiguity
- A lot about precedence
- Associativity (L, R, None, or indeterminate)
- The use of non-associativity, esp. in relational operators
- How can we make
-2**2
illegal (like it is in JS)
- How to write an Ohm grammar
- Ordering of rules in Ohm (“big” things first)
- Using Ohm:
ohm.grammar
, ohm.createSemantics
- How to draw an abbreviated AST
- How to draw an internal representation of an AST
- Why we only use context free grammars to define programming languages
- The difference between a compiler and an interpreter
- The phases of a traditional compiler
- How modern compilers are structured (Anders Hejlsberg video)
- AOT vs JIT
- What is syntax, what is static semantics
- How to distinguish syntax errors from contextual errors
- Given an English description of a language figure out which checks are syntactic vs semantic
- Given an Ohm grammar, explain what it is saying (at a high level)
- How to write an AST for sophisticated JavaScript
Things to do in preparation:
- Review the course notes
- Review Ohm docs
- Do whichever reinforcement problems that seem to make sense for this class, as well as all of the recall questions at the bottom of the relevant pages of notes.
- Practice writing grammars
- Write your own ASTs for snippets of JavaScript (Practice with friends)
- Study the Bella and Carlos grammars, and make sure you know what each are saying
- Make a big list of things that are semantic errors (and not syntax errors) in high-level languages you already know (e.g. JavaScript, Swift, Python, C++, Java, etc.)
If you work on the practice problems that sufficiently look like they cover material we’ve discussed in class, you should be fine. I recommend studying in groups with friends. Take over a whiteboard. Bring food. Play some nice background music. Studying should be fun and not stressful. You should learn things together.