CMSC 308
Fall 2015
Due:  Thursday, September 24

Assignment:    (25 points)

Consider the extended BNF grammar in problem 2 of the previous hw.    Your task is to write code that:
  • determines if a given string is valid <Expression>
  • determine a list of "tokens" in the string if it is valid expression.  In this context, tokens are:
    • (
    • )
    • '
    • anything that is a <symbol>
    • anything that is an <operator>
    • anything that is a <number>
More specifically, you should write the functions:

/*  This function returns true if the input is valid <Expression> as
determined by the previous Extended BNF.
bool validExpression(string input);

This function returns a list of the tokens in the input.  Tokens are
within the context of the BNF.
vector<string> splitIntoTokens(string input);

To help you with the structure, you are given the following files:

Commenting guidelines:

  • There should be a comment at the top of each program file with your name in it.  The comment should also contain a brief description of the program.
  • Please use descriptive names for functions/variables, etc.
  • Each function should have a comment describing it's purpose.  Be sure to include information on the parameters.
  • Any place where you take code or ideas from other people or sources, you should cite this in a comment.
  • Feel free to put additional comments in programs as you see fit.


Handin instructions TBA.