]> git.saurik.com Git - wxWidgets.git/blame - src/common/parser.y
compilation fix
[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
5a92d200 123#if (defined(__WXGTK__) || defined(__WXWINE__) || defined(__WXMOTIF__)) && !defined(NO_CONFIGURE)
6de97a3b
RR
124#include "lexer.c"
125#else
469e1e5c
SC
126#if (defined(__MWERKS__))
127#include "../common/cwlex_yy.c"
128#else
cfe780fb 129#include "../common/lex_yy.c"
6de97a3b 130#endif
469e1e5c 131#endif
cfe780fb
JS
132
133/*
134void yyerror(s)
135char *s;
136{
137 syntax_error(s);
138}
139*/
140
141/* Ansi prototype. If this doesn't work for you... uncomment
142 the above instead.
143 */
144
145void yyerror(char *s)
146{
147 syntax_error(s);
148}
149
150/*
151 * Unfortunately, my DOS version of FLEX
152 * requires yywrap to be #def'ed, whereas
153 * the UNIX flex expects a proper function.
154 */
155
156/* Not sure if __SC__ is the appropriate thing
157 * to test
158 */
159
d427503c 160#if !defined(__SC__) && !defined(__GNUWIN32__)
cfe780fb
JS
161#ifdef USE_DEFINE
162#ifndef yywrap
163#define yywrap() 1
164#endif
7fe7d506 165#else if !defined(__alpha___) && !defined(__ultrix)
cfe780fb
JS
166int yywrap() { return 1; }
167#endif
168#endif