C Program to Adds literal to list of literals

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.

  1. /**
  2.  *
  3.  * Adds literal to list of literals.
  4.  *
  5.  * \param token Token which contains literal value.
  6.  *
  7.  * \return Pointer to the list of literals on current literal.
  8.  *
  9.  */
  10. static void* add_literal(token_t* token) {
  11.  
  12.         void* literal;
  13.  
  14.         if (token -> lexeme == T_DOUBLE)
  15.                 literal = get_literal_double(literals, token -> value -> double_value);
  16.  
  17.         else if (token -> lexeme == T_INT)
  18.                 literal = get_literal_int(literals, token -> value -> int_value);
  19.  
  20.         else if (token -> lexeme == T_STRING)
  21.                 literal = get_literal_string(literals, &token -> value -> string_value);
  22.  
  23.         else
  24.                 return NULL;
  25.  
  26. }


Learn More :