aboutsummaryrefslogtreecommitdiffstats
path: root/print.c
diff options
context:
space:
mode:
authorAdam Branes <adam@adam>2021-05-02 17:46:29 +0300
committerGalin Simeonov <gts@volconst.com>2021-07-15 18:00:07 +0300
commit679cbe58c4e53f0163588a7731154f3afe2d25aa (patch)
treea2dbc2317a3f107899d60f5e68c8d6cf8d27e146 /print.c
parenta3e36c1918e63761dfc4d2221cca3636b98e93aa (diff)
downloadMEGATRON-679cbe58c4e53f0163588a7731154f3afe2d25aa.tar.gz
lexer formed
Diffstat (limited to 'print.c')
-rw-r--r--print.c77
1 files changed, 77 insertions, 0 deletions
diff --git a/print.c b/print.c
new file mode 100644
index 0000000..a9ec939
--- /dev/null
+++ b/print.c
@@ -0,0 +1,77 @@
+#ifndef PRINT_C
+#define PRINT_C PRINT_C
+#include<print.h>
+
+void print_keyword_enum(enum Keyword code)
+{
+ switch(code)
+ {
+ case KW_MACHINE:
+ printf("KW_MACHINE");
+ break;
+ case KW_STATE:
+ printf("KW_STATE");
+ break;
+ case KW_FROM:
+ printf("KW_FROM");
+ break;
+ case KW_TO:
+ printf("KW_TO");
+ break;
+ case KW_ON:
+ printf("KW_ON");
+ break;
+ case KW_ID:
+ printf("KW_ID");
+ break;
+ case KW_STRING:
+ printf("KW_STRING");
+ break;
+ case KW_NOP:
+ printf("KW_NOP");
+ break;
+ case KW_EOF:
+ printf("KW_EOF");
+ break;
+ case KW_OPEN_SQUARE:
+ printf("KW_OPEN_SQUARE");
+ break;
+ case KW_CLOSE_SQUARE:
+ printf("KW_CLOSE_SQUARE");
+ break;
+ case KW_PIPE:
+ printf("KW_PIPE");
+ break;
+ case KW_SEMI_COLUMN:
+ printf("KW_SEMI_COLUMN");
+ break;
+ case KW_STARTING:
+ printf("KW_STARTING");
+ break;
+ default:
+ printf("LEXERROR");
+ }
+}
+void print_token(struct token *token)
+{
+ size_t i;
+
+ printf("[ ");
+ print_keyword_enum(token->type);
+ printf(" ");
+ for(i=0;i<token->size;++i)
+ printf("%c",token->data[i]);
+ printf(" ] ");
+
+}
+void print_tokens(struct Queue *tokens)
+{
+ struct Queue_Node *it;
+ for(it=tokens->first;it!=NULL;it=it->prev)
+ {
+ print_token( (struct token*)(it->data));
+ printf(" ");
+ }
+}
+
+#endif