Steps to adding ELSIF to your grammar:

  1. Implement if/else using matched/unmatched. Test.

  2. Incorporate while in the matched/unmatched productions. This means creating both a matched and an unmatched version of while. Test.

  3. Incorporate loop in the matched/unmatched productions. This means creating both a matched and an unmatched version of loop. Test.

  4. Now link in the elsif stuff by adding to the list of possible matched statements:

                 | IF simpleExp THEN matched matchedelsifs
    

    and to the unmatched statements something like:

     IF simpleExp THEN matched unmatchedelsifs
    

    This will connect to two new nonterminals matchedelsifs and unmatchedelsifs.

  5. For matchedelsifs create productions that add one or more ELSIFs. They need things that look like:

    ELSIF simpleExp THEN matched ELSIF simpleExp THEN matched ELSIF simpleExp THEN matched ...
    

    This list of elsifs must end in an: ELSE matched to match the elsif.

  6. Similarly add productions for unmatchedelsifs which is again a list of ELSIFs like above but can end in one of two ways that are unmatched. See what were unmatched things in the unmatched code you already wrote for a hint.