]> git.saurik.com Git - wxWidgets.git/blob - src/common/parser.y
wxNativeFontInfo changes
[wxWidgets.git] / src / common / parser.y
1 %{
2 #include "wx/setup.h"
3 #include <string.h>
4 #ifdef _MSC_VER
5 #include <io.h>
6 #endif
7 #if defined(__GNUWIN32__) && !defined(__TWIN32__)
8 #include <sys/unistd.h>
9 #endif
10
11 #include "wx/expr.h"
12
13 #ifndef __EXTERN_C__
14 #define __EXTERN_C__ 1
15 #endif
16
17 #if defined(__cplusplus) || defined(__STDC__)
18 #if defined(__cplusplus) && defined(__EXTERN_C__)
19 extern "C" {
20 #endif
21 #endif
22 int yylex(void);
23 int yylook(void);
24 int yywrap(void);
25 int yyback(int *, int);
26 void yyerror(char *);
27
28 /* You may need to put /DLEX_SCANNER in your makefile
29 * if you're using LEX!
30 */
31 void yyoutput(int);
32
33 #if defined(__cplusplus) || defined(__STDC__)
34 #if defined(__cplusplus) && defined(__EXTERN_C__)
35 }
36 #endif
37 #endif
38 %}
39
40 %union {
41 char *s;
42 /* struct pexpr *expr; */
43 }
44
45
46 %start commands
47
48 %token <s> INTEGER 1
49 %token <s> WORD 2
50 %token <s> STRING 3
51 %token <s> PERIOD 13
52 %token OPEN 4
53 %token CLOSE 5
54 %token COMMA 6
55 %token NEWLINE 7
56 %token ERROR 8
57 %token OPEN_SQUARE 9
58 %token CLOSE_SQUARE 10
59 %token EQUALS 11
60 %token EXP 14
61
62 /* %type <expr> command expr arglist arg arg1 */
63 %type <s> command expr arglist arg arg1
64
65 %%
66
67 commands : /* empty */
68 | commands command
69 ;
70
71 command : WORD PERIOD
72 {process_command(proio_cons(wxmake_word($1), NULL)); free($1);}
73 | expr PERIOD
74 {process_command($1);}
75 | error PERIOD
76 {syntax_error("Unrecognized command.");}
77 ;
78
79 expr : WORD OPEN arglist CLOSE
80 {$$ = proio_cons(wxmake_word($1), $3); free($1);}
81 | OPEN_SQUARE CLOSE_SQUARE
82 {$$ = proio_cons(NULL, NULL);}
83 | OPEN_SQUARE arglist CLOSE_SQUARE
84 {$$ = $2; }
85 ;
86
87 arglist :
88 {$$ = NULL;}
89 | arg
90 {$$ = proio_cons($1, NULL);}
91 |
92 arg COMMA arglist
93 {$$ = proio_cons($1, $3);}
94 ;
95
96 arg : WORD EQUALS arg1
97 {$$ = proio_cons(wxmake_word("="), proio_cons(wxmake_word($1), proio_cons($3, NULL)));
98 free($1); }
99 | arg1
100 {$$ = $1; }
101
102 arg1 : WORD
103 {$$ = wxmake_word($1); free($1);}
104 | STRING
105 {$$ = wxmake_string($1); free($1);}
106 | INTEGER
107 {$$ = wxmake_integer($1); free($1);}
108 | INTEGER PERIOD INTEGER
109 {$$ = wxmake_real($1, $3); free($1); free($3); }
110 | INTEGER EXP INTEGER
111 {$$ = wxmake_exp($1, $3); free($1); free($3); }
112 |
113 INTEGER PERIOD INTEGER EXP INTEGER
114 {$$ = wxmake_exp2($1, $3, $5); free($1); free($3);
115 free($5); }
116
117 | expr
118 {$$ = $1;}
119 ;
120
121 %%
122
123 /* We include lexer.c if we are building for gtk, wine or motif
124 * and also whenever we are using configure (marked by __WX_SETUP_H__) for,
125 * for example, cross compilation. */
126 #if (defined(__WXGTK__) || defined(__WXWINE__) || defined(__WXMOTIF__)) || defined(__WX_SETUP_H__) && !defined(NO_CONFIGURE)
127 #include "lexer.c"
128 #else
129 #if (defined(__MWERKS__))
130 #include "../common/cwlex_yy.c"
131 #else
132 #include "../common/lex_yy.c"
133 #endif
134 #endif
135
136 /*
137 void yyerror(s)
138 char *s;
139 {
140 syntax_error(s);
141 }
142 */
143
144 /* Ansi prototype. If this doesn't work for you... uncomment
145 the above instead.
146 */
147
148 void yyerror(char *s)
149 {
150 syntax_error(s);
151 }
152
153 /*
154 * Unfortunately, my DOS version of FLEX
155 * requires yywrap to be #def'ed, whereas
156 * the UNIX flex expects a proper function.
157 */
158
159 /* At least on alphaev6-dec-osf4.0e yywrap() must be #define'd */
160 #if defined( __ALPHA__ ) && !defined( __VMS__ )
161 #ifndef yywrap
162 #define yywrap() 1
163 #endif
164 #else
165 /* HH: Added test for __WX_SETUP_H__ for gnuwin builds
166 * using configure */
167 #if !defined(__SC__) && !defined(__GNUWIN32__)
168 #ifdef USE_DEFINE
169 #ifndef yywrap
170 #define yywrap() 1
171 #endif
172 #elif !defined(__ultrix)
173 int yywrap() { return 1; }
174 #elif defined(__VMS__)
175 int yywrap() { return 1; }
176 #endif
177 #elif defined(__WX_SETUP_H__)
178 int yywrap() { return 1; }
179 #endif
180 #endif
181