Extend the grammar of core, describe how a parse tree would represent it, changi
ID: 3887478 • Letter: E
Question
Extend the grammar of core, describe how a parse tree would represent it, changing recursive-descent parsing of core, and more.
Consider the Core language defined in the lecture notes. Suppose we want to add to Core a state- ment with the following structure: case of 1e1 e2 es else en1 end ere ·z is some program variable of integer type. is a non-empty list of integer constants, separated by commas (could be a single constant) · ei (1Explanation / Answer
>>> groucho_grammar = nltk.CFG.fromstring(""" ... S -> NP VP ... PP -> P NP ... NP -> Det N | Det N PP | 'I' ... VP -> V NP | VP PP ... Det -> 'an' | 'my' ... N -> 'elephant' | 'pajamas' ... V -> 'shot' ... P -> 'in' ... """)
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.