~ubuntu-branches/ubuntu/quantal/mesa/quantal

« back to all changes in this revision

Viewing changes to src/mesa/shader/slang/library/gc_to_bin.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2007-02-21 12:44:07 UTC
  • mfrom: (1.2.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 22.
  • Revision ID: james.westby@ubuntu.com-20070221124407-rgcacs32mycrtadl
ImportĀ upstreamĀ versionĀ 6.5.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#include "../../grammar/grammar_crt.h"
2
2
#include "../../grammar/grammar_crt.c"
 
3
#include <stdlib.h>
3
4
#include <stdio.h>
4
5
 
5
6
static const char *slang_shader_syn =
6
7
#include "slang_shader_syn.h"
7
8
;
8
9
 
9
 
static void gc_to_bin (grammar id, const char *in, const char *out)
 
10
static int gc_to_bin (grammar id, const char *in, const char *out)
10
11
{
11
12
        FILE *f;
12
13
        byte *source, *prod;
16
17
 
17
18
        f = fopen (in, "r");
18
19
        if (f == NULL)
19
 
                return;
 
20
                return 1;
20
21
        fseek (f, 0, SEEK_END);
21
22
        size = ftell (f);
22
23
        fseek (f, 0, SEEK_SET);
27
28
        if (!grammar_fast_check (id, source, &prod, &size, 65536))
28
29
        {
29
30
                grammar_alloc_free (source);
30
 
                return;
 
31
                return 1;
31
32
        }
32
33
 
33
34
        f = fopen (out, "w");
59
60
        fprintf (f, "\n");
60
61
        fclose (f);
61
62
        grammar_alloc_free (prod);
 
63
   return 0;
62
64
}
63
65
 
64
 
int main ()
 
66
int main (int argc, char *argv[])
65
67
{
66
 
        grammar id;
67
 
 
68
 
        id = grammar_load_from_text ((const byte *) slang_shader_syn);
69
 
        if (id == 0)
70
 
                return 1;
71
 
 
72
 
        grammar_set_reg8 (id, (const byte *) "parsing_builtin", 1);
73
 
 
74
 
        grammar_set_reg8 (id, (const byte *) "shader_type", 1);
75
 
        gc_to_bin (id, "slang_core.gc", "slang_core_gc.h");
76
 
        gc_to_bin (id, "slang_common_builtin.gc", "slang_common_builtin_gc.h");
77
 
        gc_to_bin (id, "slang_fragment_builtin.gc", "slang_fragment_builtin_gc.h");
78
 
   gc_to_bin (id, "slang_builtin_vec4.gc", "slang_builtin_vec4_gc.h");
79
 
 
80
 
        grammar_set_reg8 (id, (const byte *) "shader_type", 2);
81
 
        gc_to_bin (id, "slang_vertex_builtin.gc", "slang_vertex_builtin_gc.h");
82
 
 
83
 
        grammar_destroy (id);
84
 
 
85
 
        return 0;
 
68
   grammar id;
 
69
 
 
70
   id = grammar_load_from_text ((const byte *) slang_shader_syn);
 
71
   if (id == 0)
 
72
      return 1;
 
73
   grammar_set_reg8 (id, (const byte *) "parsing_builtin", 1);
 
74
   grammar_set_reg8 (id, (const byte *) "shader_type", atoi (argv[1]));
 
75
   if (gc_to_bin (id, argv[2], argv[3])) {
 
76
      grammar_destroy (id);
 
77
      return 1;
 
78
   }
 
79
   grammar_destroy (id);
 
80
   return 0;
86
81
}
87
82