CS152
Chris Pollett
Sep 15, 2021
//For C: #pragma once // says include a header only once, can use instead of #ifndef.. #pragma warning (disable : 1337 ) //says not to generate 1337 warnings //For Java @Override //compiler should complain if not overriding something from parent class void mySuperMethod() { ... } @Readonly List<@Readonly T> list; // list's value should not change
sentence → noun-phrase verb-phrase . noun-phrase → article noun article → a | the noun → girl | dog verb-phrase → verb noun-phrase verb → sees | pets
sentence → noun-phrase verb-phrase → article noun verb-phrase → the noun verb-phrase → the girl verb-phrase → the girl verb noun-phrase → the girl pets noun-phrase → the girl pets article noun → the girl pets a noun → the girl pets a dog
<sentence> ::= <start-of-sentence> <noun-phrase> <verb-phrase> <start-of-sentence> <article> ::= The | A <start-of-sentence> ::= empty-stringare not (second rule violates it).
sentence | noun-phrase verb-phrase | | article noun verb noun-phrase | | | | the girl pets article noun | | a dog
program ::= stmt_list $$ stmt_list::= stmt stmt_list | `epsilon` stmt ::= id := expr | read id | write expr expr ::= term term_tail term_tail ::= add op term term_tail | `epsilon` term ::= factor factor_tail factor_tail ::= mult op factor factor_tail | `epsilon` factor ::= ( expr ) | id | number add op ::= + | - mult op ::= * | /
read A read B sum := A + B write sum write sum / 2 $$