Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: THEend8_
CIS2380: Coursework 2, 2021 Question 1 - 50% This question tests you on the theory side of the module - the creation of a grammar, a shift-reduce parsing table and how to use it to parse strings in a target language. The specification of your target language (MyL) is as follows: The alphabet is five symbols:
(1) first letter of your first name (2) the last letter of your first name (3) the first letter of your last name
(4) the last letter of your last name (5) the character $. For example, assuming a name like “thomas leo mccluskey” so, in this case, the alphabet for MyL is (t,s,m,y,$).
Clearly the alphabet for your language is likely to be different1. Strings of your language must satisfy the following constraints.
The first is that there is exactly one $ in any correct string, and this is always the last symbol in the string.
The string before the $, which must be non-empty, we call a correct expression, defined as follows. Every correct expression is
• a sequence of one or more of the letters (2) and/or (3) in any order, bracketed by the first (1) and last letter (4), OR
• a correct expression bracketed by the first (1) and last letter (4), OR • a sequence of correct expressions. No other strings are allowed. Hence,
the first (1) and last (4) letters act like brackets - for every let- ter (1) in the string, there must be a unique cor- responding matching last letter (4).
So for the abovementioned language MyL, examples of cor- rect strings in the language are (separated by semi colons): tmssy$; tttsmsyyy$; ttmmsmyttmyytmsyy$; ttmmmytssyy$; tmytmsy$; tttsyttmsmyyyy$ Strings of the alphabet which are NOT in the lan- guage include: ttmyyty$ (no “m” or “s inside the last “ty”); ttmmy$ (missing “y”); tttmyyyyttmmy$ (the fourth “y” does not have a corresponding starting “t”). 1If your name is like “nina nolan” and does not give 4 distinct letters, then choose alternative letter(s) in your name, so if you were named as in the example you could use (n,o,a,l,$) as your alphabet. ASSIGNMENT: You are required to (i) create an unambiguous context-free grammar which gener- ates exactly the language described above using your name; (ii) use your grammar to generate (a) a derivation sequence and (b) the syntax tree of a chosen string in your language which uses all 5 let- ters of the alphabet; (iii) generate an SR finite state machine and then parsing table from the grammar; (iv) apply your parsing table to show how it cor- rectly parses the chosen string used in part (ii). Note that your grammar should be small, consist- ing of only about 6 – 8 production rules. Question 2 - 50% INTRODUCTION: JavaCup is a parser-generator