void testAsserEqualOperatorToken(const char* str,OperatorToken* actual,int lineNo) { UNITY_TEST_ASSERT_NOT_NULL(actual,lineNo,"The token should not be NULL!"); if( TOKEN_OPERATOR_TYPE != actual->type) { CUSTOM_TEST_FAIL(lineNo,"Expected %s was %s. The token type is not the same.", \ getTokenTypeName(TOKEN_OPERATOR_TYPE),getTokenTypeName(actual->type)); } UNITY_TEST_ASSERT_EQUAL_INT(strlen(str),actual->length,lineNo,"The length is not the same."); UNITY_TEST_ASSERT_EQUAL_STRING(str,actual->symbol,lineNo,"The operator is not the same"); }
/** pushes a token with content */ void pushInitializedToken(Lexer *self, int type, char *content) { Token *tok = createToken(self->lineNumber, self->charNumber, self->fileName); tok->type = type; tok->content = content; verboseModeMessage("Lexed token: %-15s, type %s", tok->content, getTokenTypeName(tok->type)); pushBackItem(self->tokenStream, tok); }
/** pushes a token with no content */ void pushToken(Lexer *self, int type) { Token *tok = createToken(self->lineNumber, self->charNumber, self->fileName); tok->type = type; tok->content = extractToken(self, self->startPos, self->pos - self->startPos); verboseModeMessage("Lexed token: %-15s, type %s", tok->content, getTokenTypeName(tok->type)); pushBackItem(self->tokenStream, tok); }
/** pushes a token with content */ void pushInitializedToken(Lexer *self, int type, char *content) { int tokenLength = self->pos - self->startPos; // The length (in characters) of this token Token *tok = createToken(self->lineNumber, self->startPos, self->charNumber - tokenLength, self->charNumber, self->fileName); tok->type = type; tok->content = content; verboseModeMessage("Lexed token: %-15s, type %s", tok->content, getTokenTypeName(tok->type)); pushBackItem(self->tokenStream, tok); }