]> git.saurik.com Git - wxWidgets.git/blob - src/common/parser.y
Fixed wxCheckBox on wxGTK (SetLabel called before widget creation),
[wxWidgets.git] / src / common / parser.y
1 %{
2 #include <string.h>
3 #ifdef _MSC_VER
4 #include <io.h>
5 #endif
6
7 #include "wx/expr.h"
8
9 #ifndef __EXTERN_C__
10 #define __EXTERN_C__ 1
11 #endif
12
13 #if defined(__cplusplus) || defined(__STDC__)
14 #if defined(__cplusplus) && defined(__EXTERN_C__)
15 extern "C" {
16 #endif
17 #endif
18 int yylex(void);
19 int yylook(void);
20 int yywrap(void);
21 int yyback(int *, int);
22 void yyerror(char *);
23
24 /* You may need to put /DLEX_SCANNER in your makefile
25 * if you're using LEX!
26 */
27 #ifdef LEX_SCANNER
28 /* int yyoutput(int); */
29 void yyoutput(int);
30 #else
31 void yyoutput(int);
32 #endif
33
34 #if defined(__cplusplus) || defined(__STDC__)
35 #if defined(__cplusplus) && defined(__EXTERN_C__)
36 }
37 #endif
38 #endif
39 %}
40
41 %union {
42 char *s;
43 /* struct pexpr *expr; */
44 }
45
46
47 %start commands
48
49 %token <s> INTEGER 1
50 %token <s> WORD 2
51 %token <s> STRING 3
52 %token <s> PERIOD 13
53 %token OPEN 4
54 %token CLOSE 5
55 %token COMMA 6
56 %token NEWLINE 7
57 %token ERROR 8
58 %token OPEN_SQUARE 9
59 %token CLOSE_SQUARE 10
60 %token EQUALS 11
61 %token EXP 14
62
63 /* %type <expr> command expr arglist arg arg1 */
64 %type <s> command expr arglist arg arg1
65
66 %%
67
68 commands : /* empty */
69 | commands command
70 ;
71
72 command : WORD PERIOD
73 {process_command(proio_cons(make_word($1), NULL)); free($1);}
74 | expr PERIOD
75 {process_command($1);}
76 | error PERIOD
77 {syntax_error("Unrecognized command.");}
78 ;
79
80 expr : WORD OPEN arglist CLOSE
81 {$$ = proio_cons(make_word($1), $3); free($1);}
82 | OPEN_SQUARE CLOSE_SQUARE
83 {$$ = proio_cons(NULL, NULL);}
84 | OPEN_SQUARE arglist CLOSE_SQUARE
85 {$$ = $2; }
86 ;
87
88 arglist :
89 {$$ = NULL;}
90 | arg
91 {$$ = proio_cons($1, NULL);}
92 |
93 arg COMMA arglist
94 {$$ = proio_cons($1, $3);}
95 ;
96
97 arg : WORD EQUALS arg1
98 {$$ = proio_cons(make_word("="), proio_cons(make_word($1), proio_cons($3, NULL)));
99 free($1); }
100 | arg1
101 {$$ = $1; }
102
103 arg1 : WORD
104 {$$ = make_word($1); free($1);}
105 | STRING
106 {$$ = make_string($1); free($1);}
107 | INTEGER
108 {$$ = make_integer($1); free($1);}
109 | INTEGER PERIOD INTEGER
110 {$$ = make_real($1, $3); free($1); free($3); }
111 | INTEGER EXP INTEGER
112 {$$ = make_exp($1, $3); free($1); free($3); }
113 |
114 INTEGER PERIOD INTEGER EXP INTEGER
115 {$$ = make_exp2($1, $3, $5); free($1); free($3);
116 free($5); }
117
118 | expr
119 {$$ = $1;}
120 ;
121
122 %%
123
124 #ifdef __WXGTK__
125 #include "lexer.c"
126 #else
127 #include "../common/lex_yy.c"
128 #endif
129
130 /*
131 void yyerror(s)
132 char *s;
133 {
134 syntax_error(s);
135 }
136 */
137
138 /* Ansi prototype. If this doesn't work for you... uncomment
139 the above instead.
140 */
141
142 void yyerror(char *s)
143 {
144 syntax_error(s);
145 }
146
147 /*
148 * Unfortunately, my DOS version of FLEX
149 * requires yywrap to be #def'ed, whereas
150 * the UNIX flex expects a proper function.
151 */
152
153 /* Not sure if __SC__ is the appropriate thing
154 * to test
155 */
156
157 #ifndef __SC__
158 #ifdef USE_DEFINE
159 #ifndef yywrap
160 #define yywrap() 1
161 #endif
162 #else if !defined(__alpha) && !defined(__ultrix)
163 int yywrap() { return 1; }
164 #endif
165 #endif