]> git.saurik.com Git - wxWidgets.git/blame - src/common/parser.y
fix for assert when setting tooltip for a readonly combo
[wxWidgets.git] / src / common / parser.y
CommitLineData
cfe780fb 1 %{
d427503c 2#include "wx/setup.h"
cfe780fb 3#include <string.h>
b8c631bb
JS
4#ifdef _MSC_VER
5#include <io.h>
6#endif
57c208c5 7#if defined(__GNUWIN32__) && !defined(__TWIN32__)
27529614
JS
8#include <sys/unistd.h>
9#endif
b8c631bb 10
cfe780fb
JS
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__)
19extern "C" {
20#endif
21#endif
22int yylex(void);
23int yylook(void);
24int yywrap(void);
25int yyback(int *, int);
26void yyerror(char *);
27
28/* You may need to put /DLEX_SCANNER in your makefile
29 * if you're using LEX!
30 */
cfe780fb 31void yyoutput(int);
cfe780fb
JS
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
67commands : /* empty */
68 | commands command
69 ;
70
71command : WORD PERIOD
5b077d48 72 {process_command(proio_cons(wxmake_word($1), NULL)); free($1);}
cfe780fb
JS
73 | expr PERIOD
74 {process_command($1);}
75 | error PERIOD
76 {syntax_error("Unrecognized command.");}
77 ;
78
79expr : WORD OPEN arglist CLOSE
5b077d48 80 {$$ = proio_cons(wxmake_word($1), $3); free($1);}
cfe780fb
JS
81 | OPEN_SQUARE CLOSE_SQUARE
82 {$$ = proio_cons(NULL, NULL);}
83 | OPEN_SQUARE arglist CLOSE_SQUARE
84 {$$ = $2; }
85 ;
86
87arglist :
88 {$$ = NULL;}
89 | arg
90 {$$ = proio_cons($1, NULL);}
91 |
92 arg COMMA arglist
93 {$$ = proio_cons($1, $3);}
94 ;
95
96arg : WORD EQUALS arg1
5b077d48 97 {$$ = proio_cons(wxmake_word("="), proio_cons(wxmake_word($1), proio_cons($3, NULL)));
cfe780fb
JS
98 free($1); }
99 | arg1
100 {$$ = $1; }
101
102arg1 : 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
RR
127#include "lexer.c"
128#else
469e1e5c
SC
129#if (defined(__MWERKS__))
130#include "../common/cwlex_yy.c"
131#else
cfe780fb 132#include "../common/lex_yy.c"
6de97a3b 133#endif
469e1e5c 134#endif
cfe780fb
JS
135
136/*
137void yyerror(s)
138char *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
148void 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
f6bcfd97
BP
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
08998996
HH
165/* HH: Added test for __WX_SETUP_H__ for gnuwin builds
166 * using configure */
167#if !defined(__SC__) && !defined(__GNUWIN32__)
cfe780fb
JS
168#ifdef USE_DEFINE
169#ifndef yywrap
170#define yywrap() 1
171#endif
742ff1e1 172#elif !defined(__ultrix)
cfe780fb 173int yywrap() { return 1; }
59f03363
JJ
174#elif defined(__VMS__)
175int yywrap() { return 1; }
cfe780fb 176#endif
08998996
HH
177#elif defined(__WX_SETUP_H__)
178int yywrap() { return 1; }
cfe780fb 179#endif
f6bcfd97
BP
180#endif
181