]>
Commit | Line | Data |
---|---|---|
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__) | |
18 | extern "C" { | |
19 | #endif | |
20 | #endif | |
21 | int yylex(void); | |
22 | int yylook(void); | |
23 | int yywrap(void); | |
24 | int yyback(int *, int); | |
25 | void 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); */ | |
32 | void yyoutput(int); | |
33 | #else | |
34 | void 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 | ||
71 | commands : /* empty */ | |
72 | | commands command | |
73 | ; | |
74 | ||
75 | command : 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 | ||
83 | expr : 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 | ||
91 | arglist : | |
92 | {$$ = NULL;} | |
93 | | arg | |
94 | {$$ = proio_cons($1, NULL);} | |
95 | | | |
96 | arg COMMA arglist | |
97 | {$$ = proio_cons($1, $3);} | |
98 | ; | |
99 | ||
100 | arg : 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 | ||
106 | arg1 : 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 | ||
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 | /* | |
138 | void yyerror(s) | |
139 | char *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 | ||
149 | void 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 |
170 | int yywrap() { return 1; } |
171 | #endif | |
172 | #endif |