> 1.I don't really see a big difference beteween canBeEmpty and valid functions(ex1). They both > check whether Repeat is present or not in the string.What is the difference then? Function canBeEmpty takes a regular expression e1 and checks whether an empty string can match e1; Function valid takes a regular expression e2 and checks whether e2 is free of any pattern like "Repeat e3" and if yes it will further check whether the subexpression e3 can match an empty string. For example, regular expression a* can be empty, but still valid; whares regular expression a** can be empty but is not valid. That is the difference. If you consider the difference is not big, it is fine. > 2. could you give more examples of what prematch function should be doing? > The instructions say it "returns a list of suffixes, one for each prematched prefix" > and there is only one example that doesn't give a very good description(ex2) That example is good. Let me explain it in a bit more detail Our regular expression is a* , and our string is aab. Let's use # to represent an empty string. Then the regular expression a* can generate strings: #, a, aa, aaa, ... The string aab contains prefixes: #, a, aa, aab, and the corresponding suffixes: aab, ab, b, # Prematch tries to match all prefixes of a string against a regular expression. If match, then return the corresponding suffix. As # matches #, aab is returned; as a matches a, ab is returned; as aa matches aa, b is returned; as aaa does not match aab, nothing is returned and prematch stops. Therefore, algother prematch returns a list of suffixes [aab, ab, b]. Recall that we preprocess a string to a list of chars, so in our representation prematch returns [ [a,a,b], [a,b], [b]] Note: For simplicity I did not use SML syntax to represent a char. Please refer to the homework for correct syntax. > 3.What does it mean when you say "concatenation and alternation are right associative" > and "left recursion free"? Could you give an example?(ex3) Associativity is about the order in grouping multiple operators of the same precedence. For example, 1-2-3 can be interpreted as (1-2)-3 (* this is left associative, or associate from left to right *) or 1-(2-3) (* this is right associative, or associate from right to left*) Left recursion says that the first symbol on the right-hand side of a production rule in a context-free grammar is the same as the symbol on the left-hand side. For example, the rule for concatenation in the grammar of problem 3 in homework 1 ::= '#' | char ::= is left recursive. To get rid of left recursion you have to introduce new non-terminal(s). For example, ::= '#' | char ::= | Li