Add some missing files to repo. Refined interface to compiler.
[panda.git] / tests / test-parser.c
blob533a78a6f415d29256b672086b73a551f4a95aa9
3 #include <st-compiler.h>
4 #include <st-lexer.h>
5 #include <st-node.h>
6 #include <st-universe.h>
8 #include <glib.h>
9 #include <stdio.h>
10 #include <stdlib.h>
11 #include <stdbool.h>
14 #define BUF_SIZE 10000
16 int
17 main (int argc, char *argv[])
19 /* read input from stdin */
20 char buffer[BUF_SIZE];
21 char c;
22 int i = 0;
23 while ((c = getchar ()) != EOF && i < (BUF_SIZE - 1))
24 buffer[i++] = c;
25 buffer[i] = '\0';
27 /* the big bang */
28 st_bootstrap_universe ();
30 STLexer *lexer = st_lexer_new (buffer);
32 GError *error = NULL;
34 STNode *node = st_parser_parse (lexer, &error);
35 if (!node) {
36 fprintf (stderr, "error: %s\n", error->message);
37 g_error_free (error);
38 exit (1);
41 printf ("-------------------\n");
43 st_print_method_node (node);
45 st_node_destroy (node);
47 return 0;