How to write a C Program to Adds literal to list of literals in C Programming Language ?
Adds literal to list of literals.
Param token Token which contains literal value.
Return Pointer to the list of literals on current literal.
- /**
- *
- * Adds literal to list of literals.
- *
- * \param token Token which contains literal value.
- *
- * \return Pointer to the list of literals on current literal.
- *
- */
- static void* add_literal(token_t* token) {
- void* literal;
- if (token -> lexeme == T_DOUBLE)
- literal = get_literal_double(literals, token -> value -> double_value);
- else if (token -> lexeme == T_INT)
- literal = get_literal_int(literals, token -> value -> int_value);
- else if (token -> lexeme == T_STRING)
- literal = get_literal_string(literals, &token -> value -> string_value);
- else
- return NULL;
- }