1 #include "../../grammar/grammar_crt.h"
2 #include "../../grammar/grammar_crt.c"
6 static const char *slang_shader_syn
=
7 #include "slang_shader_syn.h"
10 static int gc_to_bin (grammar id
, const char *in
, const char *out
)
14 unsigned int size
, i
, line
= 0;
16 printf ("Precompiling %s\n", in
);
21 fseek (f
, 0, SEEK_END
);
23 fseek (f
, 0, SEEK_SET
);
24 source
= (byte
*) grammar_alloc_malloc (size
+ 1);
25 source
[fread (source
, 1, size
, f
)] = '\0';
28 if (!grammar_fast_check (id
, source
, &prod
, &size
, 65536))
30 grammar_alloc_free (source
);
36 fprintf (f
, "/* DO NOT EDIT - THIS FILE IS AUTOMATICALLY GENERATED FROM THE FOLLOWING FILE: */\n");
37 fprintf (f
, "/* %s */\n", in
);
39 for (i
= 0; i
< size
; i
++)
44 else if (prod
[i
] < 100)
56 fprintf (f
, "%d", prod
[i
]);
62 grammar_alloc_free (prod
);
66 int main (int argc
, char *argv
[])
70 id
= grammar_load_from_text ((const byte
*) slang_shader_syn
);
72 fprintf(stderr
, "Error loading grammar from text\n");
75 grammar_set_reg8 (id
, (const byte
*) "parsing_builtin", 1);
76 grammar_set_reg8 (id
, (const byte
*) "shader_type", atoi (argv
[1]));
77 if (gc_to_bin (id
, argv
[2], argv
[3])) {
78 fprintf(stderr
, "Error in gc_to_bin %s %s\n", argv
[2], argv
[3]);