]> git.saurik.com Git - wxWidgets.git/blame - src/common/parser.y
fix for private access for wxTimerProc
[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
27529614
JS
6#ifdef __GNUWIN32__
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
76 {process_command(proio_cons(make_word($1), NULL)); free($1);}
77 | expr PERIOD
78 {process_command($1);}
79 | error PERIOD
80 {syntax_error("Unrecognized command.");}
81 ;
82
83expr : WORD OPEN arglist CLOSE
84 {$$ = proio_cons(make_word($1), $3); free($1);}
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
101 {$$ = proio_cons(make_word("="), proio_cons(make_word($1), proio_cons($3, NULL)));
102 free($1); }
103 | arg1
104 {$$ = $1; }
105
106arg1 : WORD
107 {$$ = make_word($1); free($1);}
108 | STRING
109 {$$ = make_string($1); free($1);}
110 | INTEGER
111 {$$ = make_integer($1); free($1);}
112 | INTEGER PERIOD INTEGER
113 {$$ = make_real($1, $3); free($1); free($3); }
114 | INTEGER EXP INTEGER
115 {$$ = make_exp($1, $3); free($1); free($3); }
116 |
117 INTEGER PERIOD INTEGER EXP INTEGER
118 {$$ = make_exp2($1, $3, $5); free($1); free($3);
119 free($5); }
120
121 | expr
122 {$$ = $1;}
123 ;
124
125%%
126
6de97a3b
RR
127#ifdef __WXGTK__
128#include "lexer.c"
129#else
cfe780fb 130#include "../common/lex_yy.c"
6de97a3b 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
160#ifndef __SC__
161#ifdef USE_DEFINE
162#ifndef yywrap
163#define yywrap() 1
164#endif
165#else if !defined(__alpha) && !defined(__ultrix)
166int yywrap() { return 1; }
167#endif
168#endif