--- /dev/null
+#include "../../grammar/grammar_crt.h"\r
+#include "../../grammar/grammar_crt.c"\r
+#include <stdio.h>\r
+\r
+static const char *slang_shader_syn =\r
+#include "slang_shader_syn.h"\r
+;\r
+\r
+static void gc_to_bin (grammar id, const char *in, const char *out)\r
+{\r
+ FILE *f;\r
+ byte *source, *prod;\r
+ unsigned int size, i, line = 0;\r
+\r
+ f = fopen (in, "r");\r
+ if (f == NULL)\r
+ return;\r
+ fseek (f, 0, SEEK_END);\r
+ size = ftell (f);\r
+ fseek (f, 0, SEEK_SET);\r
+ source = (byte *) grammar_alloc_malloc (size + 1);\r
+ source[fread (source, 1, size, f)] = '\0';\r
+ fclose (f);\r
+\r
+ if (!grammar_fast_check (id, source, &prod, &size, 65536))\r
+ {\r
+ grammar_alloc_free (source);\r
+ return;\r
+ }\r
+\r
+ f = fopen (out, "w");\r
+ for (i = 0; i < size; i++)\r
+ {\r
+ unsigned int a;\r
+ if (prod[i] < 10)\r
+ a = 1;\r
+ else if (prod[i] < 100)\r
+ a = 2;\r
+ else\r
+ a = 3;\r
+ if (i < size - 1)\r
+ a++;\r
+ if (line + a > 100)\r
+ {\r
+ fprintf (f, "\n");\r
+ line = 0;\r
+ }\r
+ line += a;\r
+ fprintf (f, "%d", prod[i]);\r
+ if (i < size - 1)\r
+ fprintf (f, ",");\r
+ }\r
+ fclose (f);\r
+ grammar_alloc_free (prod);\r
+}\r
+\r
+int main ()\r
+{\r
+ grammar id;\r
+\r
+ id = grammar_load_from_text ((const byte *) slang_shader_syn);\r
+ if (id == 0)\r
+ return 1;\r
+\r
+ grammar_set_reg8 (id, (const byte *) "parsing_builtin", 1);\r
+\r
+ grammar_set_reg8 (id, (const byte *) "shader_type", 1);\r
+ gc_to_bin (id, "slang_core.gc", "slang_core_gc_bin.h");\r
+ gc_to_bin (id, "slang_common_builtin.gc", "slang_common_builtin_gc_bin.h");\r
+ gc_to_bin (id, "slang_fragment_builtin.gc", "slang_fragment_builtin_gc_bin.h");\r
+\r
+ grammar_set_reg8 (id, (const byte *) "shader_type", 2);\r
+ gc_to_bin (id, "slang_vertex_builtin.gc", "slang_vertex_builtin_gc_bin.h");\r
+\r
+ grammar_destroy (id);\r
+\r
+ return 0;\r
+}\r
+\r