po: Update French translation.
[wine] / dlls / d3dcompiler_43 / hlsl.y
1 /*
2  * HLSL parser
3  *
4  * Copyright 2008 Stefan Dösinger
5  * Copyright 2012 Matteo Bruni for CodeWeavers
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20  */
21 %{
22 #include "config.h"
23 #include "wine/debug.h"
24
25 #include <stdio.h>
26
27 #include "d3dcompiler_private.h"
28
29 WINE_DEFAULT_DEBUG_CHANNEL(hlsl_parser);
30
31 int hlsl_lex(void);
32
33 struct hlsl_parse_ctx hlsl_ctx;
34
35 void hlsl_message(const char *fmt, ...)
36 {
37     va_list args;
38
39     va_start(args, fmt);
40     compilation_message(&hlsl_ctx.messages, fmt, args);
41     va_end(args);
42 }
43
44 static void hlsl_error(const char *s)
45 {
46     hlsl_message("Line %u: %s\n", hlsl_ctx.line_no, s);
47     set_parse_status(&hlsl_ctx.status, PARSE_ERR);
48 }
49
50 %}
51
52 %error-verbose
53
54 %union
55 {
56     char *name;
57     INT intval;
58 }
59
60 %token <intval> PRE_LINE
61
62 %token <name> STRING
63 %%
64
65 hlsl_prog:                /* empty */
66                             {
67                             }
68                         | hlsl_prog preproc_directive
69                             {
70                             }
71
72 preproc_directive:        PRE_LINE STRING
73                             {
74                                 TRACE("Updating line informations to file %s, line %u\n", debugstr_a($2), $1);
75                                 hlsl_ctx.line_no = $1 - 1;
76                                 d3dcompiler_free(hlsl_ctx.source_file);
77                                 hlsl_ctx.source_file = $2;
78                             }
79
80 %%
81
82 struct bwriter_shader *parse_hlsl(enum shader_type type, DWORD version, const char *entrypoint, char **messages)
83 {
84     hlsl_ctx.line_no = 1;
85     hlsl_ctx.source_file = d3dcompiler_strdup("");
86     hlsl_ctx.matrix_majority = HLSL_COLUMN_MAJOR;
87
88     hlsl_parse();
89
90     d3dcompiler_free(hlsl_ctx.source_file);
91
92     return NULL;
93 }