summaryrefslogtreecommitdiff
path: root/src/mesa/shader/slang/library/gc_to_bin.c
diff options
context:
space:
mode:
authorMichal Krol <mjkrol@gmail.org>2006-09-26 11:43:30 +0000
committerMichal Krol <mjkrol@gmail.org>2006-09-26 11:43:30 +0000
commit16647b739baf9701e3d037fc7030f45e7bde5c7e (patch)
tree0fad25d1ae7e83d26c8bb638d73e367aafb6e08a /src/mesa/shader/slang/library/gc_to_bin.c
parenta50b7dbc3ba1db8c92b4bbb4f7f06de8d6c039c4 (diff)
Add syntax files for expression and directive preprocessor.
Fix syntax errors in builtin library 1.2 sources. All derivative files (*_gc.h and *_syn.h) are generated by Makefile.
Diffstat (limited to 'src/mesa/shader/slang/library/gc_to_bin.c')
-rwxr-xr-xsrc/mesa/shader/slang/library/gc_to_bin.c41
1 files changed, 18 insertions, 23 deletions
diff --git a/src/mesa/shader/slang/library/gc_to_bin.c b/src/mesa/shader/slang/library/gc_to_bin.c
index 69895d84bf..ce9a6541ac 100755
--- a/src/mesa/shader/slang/library/gc_to_bin.c
+++ b/src/mesa/shader/slang/library/gc_to_bin.c
@@ -1,12 +1,13 @@
#include "../../grammar/grammar_crt.h"
#include "../../grammar/grammar_crt.c"
+#include <stdlib.h>
#include <stdio.h>
static const char *slang_shader_syn =
#include "slang_shader_syn.h"
;
-static void gc_to_bin (grammar id, const char *in, const char *out)
+static int gc_to_bin (grammar id, const char *in, const char *out)
{
FILE *f;
byte *source, *prod;
@@ -16,7 +17,7 @@ static void gc_to_bin (grammar id, const char *in, const char *out)
f = fopen (in, "r");
if (f == NULL)
- return;
+ return 1;
fseek (f, 0, SEEK_END);
size = ftell (f);
fseek (f, 0, SEEK_SET);
@@ -27,7 +28,7 @@ static void gc_to_bin (grammar id, const char *in, const char *out)
if (!grammar_fast_check (id, source, &prod, &size, 65536))
{
grammar_alloc_free (source);
- return;
+ return 1;
}
f = fopen (out, "w");
@@ -59,29 +60,23 @@ static void gc_to_bin (grammar id, const char *in, const char *out)
fprintf (f, "\n");
fclose (f);
grammar_alloc_free (prod);
+ return 0;
}
-int main ()
+int main (int argc, char *argv[])
{
- grammar id;
-
- id = grammar_load_from_text ((const byte *) slang_shader_syn);
- if (id == 0)
- return 1;
-
- grammar_set_reg8 (id, (const byte *) "parsing_builtin", 1);
-
- grammar_set_reg8 (id, (const byte *) "shader_type", 1);
- gc_to_bin (id, "slang_core.gc", "slang_core_gc.h");
- gc_to_bin (id, "slang_common_builtin.gc", "slang_common_builtin_gc.h");
- gc_to_bin (id, "slang_fragment_builtin.gc", "slang_fragment_builtin_gc.h");
- gc_to_bin (id, "slang_builtin_vec4.gc", "slang_builtin_vec4_gc.h");
-
- grammar_set_reg8 (id, (const byte *) "shader_type", 2);
- gc_to_bin (id, "slang_vertex_builtin.gc", "slang_vertex_builtin_gc.h");
-
- grammar_destroy (id);
+ grammar id;
- return 0;
+ id = grammar_load_from_text ((const byte *) slang_shader_syn);
+ if (id == 0)
+ return 1;
+ grammar_set_reg8 (id, (const byte *) "parsing_builtin", 1);
+ grammar_set_reg8 (id, (const byte *) "shader_type", atoi (argv[1]));
+ if (gc_to_bin (id, argv[2], argv[3])) {
+ grammar_destroy (id);
+ return 1;
+ }
+ grammar_destroy (id);
+ return 0;
}