aboutsummaryrefslogtreecommitdiff
path: root/src/lexer/token.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lexer/token.c')
-rw-r--r--src/lexer/token.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/lexer/token.c b/src/lexer/token.c
new file mode 100644
index 0000000..bf534a4
--- /dev/null
+++ b/src/lexer/token.c
@@ -0,0 +1,29 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* token.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/06/09 13:38:08 by charles #+# #+# */
+/* Updated: 2020/06/09 13:39:27 by charles ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include "lexer.h"
+
+t_token *token_new(enum e_token_tag tag, char *content)
+{
+ t_token *token;
+
+ if (content == NULL
+ || (token = malloc(sizeof(t_token))) == NULL)
+ return (NULL);
+ if ((token->content = ft_strdup(content)) == NULL)
+ {
+ free(token);
+ return (NULL);
+ }
+ token->tag = tag;
+ return token;
+}