--- /dev/null
+#ifndef GRAMMAR_H
+# define GRAMMAR_H
+
+# include "libft.h"
+
+// These strings should be regarded as constant
+// They are generated by xxd hence this type is forced
+
+extern unsigned char grammar[];
+extern unsigned int grammar_len;
+
+extern unsigned char parsing_table[];
+extern unsigned int parsing_table_len;
+
+typedef enum e_single_char_terminal
+{
+ RIGHT_SQUARE
+ LEFT_SQUARE
+ RIGHT_BRACKET
+ LEFT_BRACKET
+ RIGHT_CURLY
+ LEFT_CURLY
+ DIVIDE
+ TIMES
+ MINUS
+ PLUS
+ GREATER_THEN
+ LESS_THEN
+ OR
+ AND
+ Z
+ Y
+ X
+ N
+ U
+ BACKSLASH
+ EQUAL
+ COMMA
+ VERTICAL_BAR
+ SEMICOLON
+ DOT
+
+ single_char_terminal_count
+} t_single_char_terminal;
+
+typedef enum e_keyword
+{
+ EXP = single_char_terminal_count,
+ MIRROR
+ TRANSLATE
+ ROTATE
+ FROM
+ LOAD
+ IN
+
+ keyword_count
+} t_keyword;
+
+typedef enum e_other_terminals
+{
+ STRING = keyword_count,
+ INT,
+
+ terminal_count
+} t_other_terminals;
+
+t_parse_tree_node *parse(const char *file);
+
+#endif //GRAMMAR_H
--- /dev/null
+#include "grammar.h"
+#include <stdlib.h>
+#include <unistd.h>
+#include <fcntl.h>
+
+const char *g_keyword_strings[keyword_count] = {
+ [MINUS] = "-",
+ [DOT] = ".",
+ [COMMA] = ",",
+ [TIMES] = "*",
+ [PLUS] = "+",
+ [RIGHT_PARA] = ")",
+ [LEFT_PARA] = "(",
+ [EXP] = "e",
+ [FROM] = "FROM",
+ [ATOM] = "ATOM",
+ [N_OUT_OF_K] = "NOOK",
+ [SYSTEM] = "SYSTEM",
+ [INSTANTIATE] = "INST",
+};
+
+const char *g_token_strings[terminal_count] = {
+ [EXP] = "EXP",
+ [DOT] = "DOT",
+ [FROM] = "FROM",
+ [ATOM] = "ATOM",
+ [COMMA] = "COMMA",
+ [N_OUT_OF_K] = "N_OUT_OF_K",
+ [TIMES] = "TIMES",
+ [PLUS] = "PLUS",
+ [RIGHT_PARA] = "RIGHT_PARA",
+ [LEFT_PARA] = "LEFT_PARA",
+ [SYSTEM] = "SYSTEM",
+ [INSTANTIATE] = "INSTANTIATE",
+ [WORD] = "WORD",
+ [INT] = "INT",
+ [MINUS] = "MINUS",
+};
+
+static int is_single_char_terminal(char c)