Soln of 2.1:

Have one SCORE line for each location, e.g.,

LOCATION pitfall
NAME "Dark abyss"
DESCRIPTION "You have fallen in a pit."
SCORE -5
north cave
south cave
east deathval

Soln of 4.1:

The only trick is in writing the regular expression for a string. So far we have defined a string as a list of any characters enclosed within a pair of double quotes. Actually, hat is not entirely correct. The double quote character cannot occur inside the body of the string. (We shall not allow escaping the double quote by putting a backslash before it, as in C.) So the regular expression for a string is

"\""[^"]+"\""

The complete flex input file is in adv3.lex.

Soln of 6.1:

No, it recognises inputs like
[ [ [ 1 ] 2 ] 3 ]

Soln of 6.2:

Here we have two altwrnative row endings: semicolon or newline. Accordingly we need the rules

rowEnd : SEMICOLON
rowEnd : NL

Now we can write

matrix : LBRACKET rowList RBRACKET
rowList : row
rowList : rowList rowEnd row

And we already know how to define row, which is just a list of NUMs:

row : NUM
row : row NUM

Soln of 6.3:

Change
row : NUM
in the last solution to
row : 

Soln of 6.4:

  1. No, otherwise we would not need the semicolon after the last statement in a group.
  2. Yes.
  3. 
    stmt1 : stmt SEMICOLON
    Cgroup : stmt1
    Cgroup : Cgroup stmt1
    
    
  4. 
    PascGroup : stmt
    PascGroup : PascGroup SEMICOLON  stmt
    
  5. It depends on how stmt is defined. If stmt can be empty, then typing a semicolon at the end will not cause any problem. Otherwise, it would be a syntax error.