|
home—lectures—recipe—exams—hws—D2L—breeze (snow day; distance)
conjugating verbs (background):In natural languages, verbs are often conjugated. For example, when using the verb run, one says I run, but she runs. In English, most verbs just add that s at the end of he/she/it cases (third person singular). But some verbs are irregular, like to be: One says have I am, but you are and she is.
In Spanish, it's similar: for the verb programar, one says yo programo (I program), but tù programas (you program) and nosotros programos (we program). Similarly, the Spanish verb ser (to be) is irregular: yo soy (I am) but tù eres (you are) and ella es (she is).
What follows is a simplistic grammar to capture conjugation of (a few) verbs, in Spanish. You don't need to know Spanish (or the notion of 'conjugating verbs') to understand/use the grammar, in the same way a computer can follow these grammar-instructions without actual understanding of Spanish.
ConjVerb ::= ConjVerbReg | ConjVerbIrreg rules 1a,1b ConjVerbReg ::= yo SPACE RegVerbStem o rule 2a | tú SPACE RegVerbStem as rule 2b | ThirdPersonSingular SPACE RegVerbStem as rule 2c | nosotros SPACE RegVerbStem amos rule 2d | vosotros SPACE RegVerbStem áis rule 2e | ThirdPersonPlural SPACE RegVerbStem an rule 2f RegVerbStem ::= program | aclar | practic | pregunt | purific rules 3a–3e ThirdPersonSingular ::= él | ella | usted rules 4a–c ThirdPersonPlural ::= ellos | ellas | ustedes rules 5a–5c ConjVerbIrreg ::= ConjEstar | ConjSaber rules 6a,6b ConjEstar ::= yo SPACE estoy rule 7a | tú SPACE estàs rule 7b | ThirdPersonSingular SPACE está rule 7c | nosotros SPACE estamos rule 7d | vosotros SPACE estáis rule 7e | ThirdPersonPlural SPACE están rule 7f ConjSaber ::= yo SPACE sé rule 8a | tú SPACE sabes rule 8b | ThirdPersonSingular SPACE sabe rule 8c | nosotros SPACE sabemos rule 8d | vosotros SPACE sabéis rule 8e | ThirdPersonPlural SPACE saben rule 8f SPACE ::= ␣ that is, a space-character rule 9This grammar is explicit about when a space-character is to be included (written “␣”), something we ignored in the lecture-examples.
Give a parse tree for the following strings, starting from the nonterminal ConjVerb. For one of them, also give a leftmost derivation, citing which rule you use in each step.
In lecture, we saw worked on a grammar for Java variable-declarations (simplified to omit privacy-modifiers), assuming we already have rules for the nonterminals IdJava, TypeJava, and ExprJava:
VarDeclJava ::= TypeJava IdJava; | TypeJava IdJava = ExprJava;
Using that grammar, give a parse tree and/or leftmost derivation for the following.
(You should have a tree containing “⋮”
to represent the nodes between (say)
Expr and the expression derived from that nonterminal,
since w/o further rules we don't know exactly how that gets filled in.)
Note that we're currently only handling
(Of course:
Make other non-terminals as needed,
and start with a couple of examples (as part (a) in previous problems),
and end with using your grammar to give parse-trees for your examples (as part (c) in previous problems).
If you feel these steps are hauntingly similar the design-recipe
— making examples of the data, and then running our code on the test-cases —
that is no coincidence; it's because the design-recipe is a general problem-solving
technique applicable to most problem-solving situations.)
1 Note that in real Spanish, “usted” is not a 3rd-person pronoun, but rather a 2nd-person pronoun (singular-formal) that conjugates just like the 3rd-person pronouns. Similarly with the plural “ustedes”. ↩
home—lectures—recipe—exams—hws—D2L—breeze (snow day; distance)
©2015, Ian Barland, Radford University Last modified 2016.Jun.15 (Wed) |
Please mail any suggestions (incl. typos, broken links) to ibarlandradford.edu |