]>
Commit | Line | Data |
---|---|---|
8e19f54e | 1 | /* Version: $Id$ */ |
cfe780fb | 2 | %{ |
d427503c | 3 | #include "wx/setup.h" |
cfe780fb | 4 | #include <string.h> |
b8c631bb JS |
5 | #ifdef _MSC_VER |
6 | #include <io.h> | |
7 | #endif | |
57c208c5 | 8 | #if defined(__GNUWIN32__) && !defined(__TWIN32__) |
27529614 JS |
9 | #include <sys/unistd.h> |
10 | #endif | |
b8c631bb | 11 | |
cfe780fb JS |
12 | #include "wx/expr.h" |
13 | ||
14 | #ifndef __EXTERN_C__ | |
15 | #define __EXTERN_C__ 1 | |
16 | #endif | |
17 | ||
18 | #if defined(__cplusplus) || defined(__STDC__) | |
19 | #if defined(__cplusplus) && defined(__EXTERN_C__) | |
20 | extern "C" { | |
21 | #endif | |
22 | #endif | |
23 | int yylex(void); | |
24 | int yylook(void); | |
25 | int yywrap(void); | |
26 | int yyback(int *, int); | |
27 | void yyerror(char *); | |
28 | ||
29 | /* You may need to put /DLEX_SCANNER in your makefile | |
30 | * if you're using LEX! | |
31 | */ | |
cfe780fb | 32 | void yyoutput(int); |
cfe780fb JS |
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 | |
5b077d48 | 73 | {process_command(proio_cons(wxmake_word($1), NULL)); free($1);} |
cfe780fb JS |
74 | | expr PERIOD |
75 | {process_command($1);} | |
76 | | error PERIOD | |
77 | {syntax_error("Unrecognized command.");} | |
78 | ; | |
79 | ||
80 | expr : WORD OPEN arglist CLOSE | |
5b077d48 | 81 | {$$ = proio_cons(wxmake_word($1), $3); free($1);} |
cfe780fb JS |
82 | | OPEN_SQUARE arglist CLOSE_SQUARE |
83 | {$$ = $2; } | |
84 | ; | |
85 | ||
86 | arglist : | |
cb73d83f | 87 | {$$ = proio_cons(NULL, NULL);} |
cfe780fb JS |
88 | | arg |
89 | {$$ = proio_cons($1, NULL);} | |
90 | | | |
91 | arg COMMA arglist | |
92 | {$$ = proio_cons($1, $3);} | |
93 | ; | |
94 | ||
95 | arg : WORD EQUALS arg1 | |
5b077d48 | 96 | {$$ = proio_cons(wxmake_word("="), proio_cons(wxmake_word($1), proio_cons($3, NULL))); |
cfe780fb JS |
97 | free($1); } |
98 | | arg1 | |
99 | {$$ = $1; } | |
566d84a7 | 100 | ; |
cfe780fb JS |
101 | |
102 | arg1 : WORD | |
5b077d48 | 103 | {$$ = wxmake_word($1); free($1);} |
cfe780fb | 104 | | STRING |
5b077d48 | 105 | {$$ = wxmake_string($1); free($1);} |
cfe780fb | 106 | | INTEGER |
5b077d48 | 107 | {$$ = wxmake_integer($1); free($1);} |
cfe780fb | 108 | | INTEGER PERIOD INTEGER |
5b077d48 | 109 | {$$ = wxmake_real($1, $3); free($1); free($3); } |
cfe780fb | 110 | | INTEGER EXP INTEGER |
5b077d48 | 111 | {$$ = wxmake_exp($1, $3); free($1); free($3); } |
cfe780fb JS |
112 | | |
113 | INTEGER PERIOD INTEGER EXP INTEGER | |
5b077d48 | 114 | {$$ = wxmake_exp2($1, $3, $5); free($1); free($3); |
cfe780fb JS |
115 | free($5); } |
116 | ||
117 | | expr | |
118 | {$$ = $1;} | |
119 | ; | |
120 | ||
121 | %% | |
122 | ||
80d895cd HH |
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) | |
6de97a3b | 127 | #include "lexer.c" |
0d4d0e8d GD |
128 | #elif defined(__WXMAC__) && defined(__APPLE__) |
129 | #include "lexer.c" | |
130 | #elif defined(__MWERKS__) | |
469e1e5c SC |
131 | #include "../common/cwlex_yy.c" |
132 | #else | |
cfe780fb | 133 | #include "../common/lex_yy.c" |
6de97a3b | 134 | #endif |
cfe780fb JS |
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 | ||
c81f40e0 RL |
159 | /* At least on alphaev6-dec-osf4.0e yywrap() must be #define'd. |
160 | * RL: ... but on Debian/Alpha(linux) it must not, so hopefully | |
161 | * testing for __OSF__ here is what we really want. | |
162 | */ | |
163 | #ifdef __OSF__ | |
f6bcfd97 BP |
164 | #ifndef yywrap |
165 | #define yywrap() 1 | |
166 | #endif | |
167 | #else | |
08998996 HH |
168 | /* HH: Added test for __WX_SETUP_H__ for gnuwin builds |
169 | * using configure */ | |
170 | #if !defined(__SC__) && !defined(__GNUWIN32__) | |
cfe780fb JS |
171 | #ifdef USE_DEFINE |
172 | #ifndef yywrap | |
173 | #define yywrap() 1 | |
174 | #endif | |
742ff1e1 | 175 | #elif !defined(__ultrix) |
cfe780fb | 176 | int yywrap() { return 1; } |
59f03363 JJ |
177 | #elif defined(__VMS__) |
178 | int yywrap() { return 1; } | |
cfe780fb | 179 | #endif |
08998996 HH |
180 | #elif defined(__WX_SETUP_H__) |
181 | int yywrap() { return 1; } | |
cfe780fb | 182 | #endif |
f6bcfd97 BP |
183 | #endif |
184 |