SE250:lab-9:twon069

From Marks Wiki
Jump to navigation Jump to search

PROBLEMS!

  • Took quite a while reading through the pdf, and very confused afterward.
  • After choosing option 1, very confused as what I'm suppose to do, so I looked at the toy_tokeniser and decided, this could be it! (copy & paste = win!)

Approach

  • After reading through toy_tokeniser and tokenise.h, and came to a great realization of what to do! Flesh out all functions in toy_tokeniser! and rewrite them to a PROPER tokeniser.
  • Started with eqToken() function, and below is what I've came up according to the constraint:
bool eqToken( Token a, Token b ) {
	if (a.type != b.type) {
		return false;
	}
	if (a.type == T_INTEGER) {
		return a.val.intval == b.val.intval;
	} else if (a.type == T_FLOAT) {
		return a.val.fltval == b.val.fltval;
	} else if (a.type == T_IDENT || a.type == T_SYMBOL) {
		return a.val.symval == b.val.symval;
	} else if (a.type == T_STRING) {
		return a.val.strval == b.val.strval;
	}

	//T_END and T_NOTHING are treated equal
	return true;
}
  • Rest of the function beside, void init_predefined_tokens( ), seen correct to me... confused again due to the lengthy lab notes and it's this easy?
  • So continue onto void init_predefined_tokens( )...
  • After reading through the pdf nth time, with no mentioning of init_predefiened_tokens is suppose to do, I logged off.

CONCLUSION SO FAR

Very confusing lab, very confusing indeed....

TO BE CONTINUE....