Problem 0 - Good Morning

This problem is a slightly more advanced variance of the demo project HelloWorld, and the greeting to be generated here has some simple structure inside. The project is set up with a text based I/O. The expected output is shown in the figure below (the exact content does not have to match because of potential difference in using RNG).

Instructions:

    • "good_morning.xc" should be the only file that needs to be edited. Do not modify other files, and do not change the names or relative locations of the files and directories.

    • The item type (i.e. the type name for declaring with "gigltype" keyword) should be named as "Greeting".

    • The source files should define a function with signature "Greeting* GenerateGreeting()" as the interface to other source files.

    • The greeting contains two parts. The first part is chosen from "Good morning" and "Good afternoon", with 0.7 and 0.3 probabilities respectively. The second part is chosen from "World" and "Mom" with equal probabilities.

    • The item type should involve a function attribute "Print()", returning a string (it is string, not char*), printing out the greeting text (the two parts of the greeting should be connected by a comma and a space, see the figure above for formatting).

    • Please refer to [Here] for general instructions about exercises.

Hints/Notes:

    • When there is only one rule expanded from the same nonterminal type, in the generator configuration, the probability field (the "@ {...}" part) of that rule can be omitted (note this is different from omitting the rule as a whole, which means the rule has 0 chance to be selected).