summaryrefslogtreecommitdiff
path: root/21sh/ll-expr/src/lexer/token.h
diff options
context:
space:
mode:
Diffstat (limited to '21sh/ll-expr/src/lexer/token.h')
-rw-r--r--21sh/ll-expr/src/lexer/token.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/21sh/ll-expr/src/lexer/token.h b/21sh/ll-expr/src/lexer/token.h
new file mode 100644
index 0000000..b0866fc
--- /dev/null
+++ b/21sh/ll-expr/src/lexer/token.h
@@ -0,0 +1,25 @@
+#ifndef TOKEN_H
+#define TOKEN_H
+
+#include <unistd.h>
+
+enum token_type
+{
+ TOKEN_PLUS, // '+'
+ TOKEN_MINUS, // '-'
+ TOKEN_MUL, // '*'
+ TOKEN_DIV, // '/'
+ TOKEN_NUMBER, // "[0-9]+"
+ TOKEN_LEFT_PAR, // '('
+ TOKEN_RIGHT_PAR, // ')'
+ TOKEN_EOF, // end of input marker
+ TOKEN_ERROR // it is not a real token, it is returned in case of invalid
+ // input
+};
+
+struct token
+{
+ enum token_type type; // The kind of token
+ ssize_t value; // If the token is a number, its value
+};
+#endif /* !TOKEN_H */