]> git.corax.cc Git - ccc/commitdiff
parser: Add code to test primary-expression parsing
authorMatthias Kruk <m@m10k.eu>
Tue, 7 Jul 2020 13:07:20 +0000 (22:07 +0900)
committerMatthias Kruk <m@m10k.eu>
Tue, 7 Jul 2020 13:07:20 +0000 (22:07 +0900)
src/main.c

index 3b2f0d69c2c6a34414c58a90cc2556ca8fdd0ac7..9dfda3e327f9978ad67884e14a90aec377b106df 100644 (file)
@@ -1,15 +1,45 @@
 #include <stdio.h>
 #include "lex.h"
+#include "parser.h"
 #include "str.h"
 
 int main(int argc, char *argv[])
 {
+       struct constant *c;
+       struct string *s;
        struct token *tok;
+       struct primary_expression *pexpr;
+       int pos;
+
+       pos = lex_getpos();
 
        while((tok = lex_gettoken())) {
                printf("Token at %4d:%3d: \"%s\" %d\n", tok->line, tok->column,
                       str_value(tok->value), tok->type);
-               token_free(tok);
+       }
+
+       lex_setpos(pos);
+
+#if 0
+       c = parse_constant();
+
+       if(c) {
+               constant_debug(c);
+       }
+
+       s = parse_string();
+
+       if(s) {
+               string_debug(s);
+       }
+#endif
+
+       pexpr = parse_primary_expression();
+
+       printf("pexpr = %p\n", pexpr);
+
+       if(pexpr) {
+               primary_expression_debug(pexpr);
        }
 
        return(0);