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