SE250:lab-9:hals016

From Marks Wiki
Jump to navigation Jump to search

Upon the lab finishing at 12pm I decided to write up the report in which case my choice of Option2 changed to Option 1 (with no real difference to the progress made).

Option 1

I wrote the code for eqToken (I fixed the errors for it so hopefully its right, although all the other functions had errors :D).

bool eqToken( Token a, Token b ) {
  token_t aType = a.type;
  token_t bType = b.type;
  bool one =(aType == T_SYMBOL && a.val.symval == b.val.symval);
  bool two = (aType == T_INTEGER && a.val.intval == b.val.intval);
  bool three = (aType == T_STRING && a.val.strval == b.val.strval);
  bool four = (aType == T_FLOAT && a.val.fltval == b.val.fltval);
  bool five = (aType == T_END || aType == T_NOTHING);
  bool six = (aType == T_IDENT && a.val.strval == b.val.strval);
  if (aType!=bType)
    return false;
  else if (one || two || three || four || five || six)
    return true;
  else
    return false;
}