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