]>
Commit | Line | Data |
---|---|---|
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__) | |
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 | */ | |
cfe780fb | 30 | void yyoutput(int); |
cfe780fb JS |
31 | |
32 | #if defined(__cplusplus) || defined(__STDC__) | |
33 | #if defined(__cplusplus) && defined(__EXTERN_C__) | |
34 | } | |
35 | #endif | |
36 | #endif | |
37 | %} | |
38 | ||
39 | %union { | |
40 | char *s; | |
41 | /* struct pexpr *expr; */ | |
42 | } | |
43 | ||
44 | ||
45 | %start commands | |
46 | ||
47 | %token <s> INTEGER 1 | |
48 | %token <s> WORD 2 | |
49 | %token <s> STRING 3 | |
50 | %token <s> PERIOD 13 | |
51 | %token OPEN 4 | |
52 | %token CLOSE 5 | |
53 | %token COMMA 6 | |
54 | %token NEWLINE 7 | |
55 | %token ERROR 8 | |
56 | %token OPEN_SQUARE 9 | |
57 | %token CLOSE_SQUARE 10 | |
58 | %token EQUALS 11 | |
59 | %token EXP 14 | |
60 | ||
61 | /* %type <expr> command expr arglist arg arg1 */ | |
62 | %type <s> command expr arglist arg arg1 | |
63 | ||
64 | %% | |
65 | ||
66 | commands : /* empty */ | |
67 | | commands command | |
68 | ; | |
69 | ||
70 | command : WORD PERIOD | |
5b077d48 | 71 | {process_command(proio_cons(wxmake_word($1), NULL)); free($1);} |
cfe780fb JS |
72 | | expr PERIOD |
73 | {process_command($1);} | |
74 | | error PERIOD | |
75 | {syntax_error("Unrecognized command.");} | |
76 | ; | |
77 | ||
78 | expr : WORD OPEN arglist CLOSE | |
5b077d48 | 79 | {$$ = proio_cons(wxmake_word($1), $3); free($1);} |
cfe780fb JS |
80 | | OPEN_SQUARE CLOSE_SQUARE |
81 | {$$ = proio_cons(NULL, NULL);} | |
82 | | OPEN_SQUARE arglist CLOSE_SQUARE | |
83 | {$$ = $2; } | |
84 | ; | |
85 | ||
86 | arglist : | |
87 | {$$ = NULL;} | |
88 | | arg | |
89 | {$$ = proio_cons($1, NULL);} | |
90 | | | |
91 | arg COMMA arglist | |
92 | {$$ = proio_cons($1, $3);} | |
93 | ; | |
94 | ||
95 | arg : WORD EQUALS arg1 | |
5b077d48 | 96 | {$$ = proio_cons(wxmake_word("="), proio_cons(wxmake_word($1), proio_cons($3, NULL))); |
cfe780fb JS |
97 | free($1); } |
98 | | arg1 | |
99 | {$$ = $1; } | |
100 | ||
101 | arg1 : WORD | |
5b077d48 | 102 | {$$ = wxmake_word($1); free($1);} |
cfe780fb | 103 | | STRING |
5b077d48 | 104 | {$$ = wxmake_string($1); free($1);} |
cfe780fb | 105 | | INTEGER |
5b077d48 | 106 | {$$ = wxmake_integer($1); free($1);} |
cfe780fb | 107 | | INTEGER PERIOD INTEGER |
5b077d48 | 108 | {$$ = wxmake_real($1, $3); free($1); free($3); } |
cfe780fb | 109 | | INTEGER EXP INTEGER |
5b077d48 | 110 | {$$ = wxmake_exp($1, $3); free($1); free($3); } |
cfe780fb JS |
111 | | |
112 | INTEGER PERIOD INTEGER EXP INTEGER | |
5b077d48 | 113 | {$$ = wxmake_exp2($1, $3, $5); free($1); free($3); |
cfe780fb JS |
114 | free($5); } |
115 | ||
116 | | expr | |
117 | {$$ = $1;} | |
118 | ; | |
119 | ||
120 | %% | |
121 | ||
5a92d200 | 122 | #if (defined(__WXGTK__) || defined(__WXWINE__) || defined(__WXMOTIF__)) && !defined(NO_CONFIGURE) |
6de97a3b RR |
123 | #include "lexer.c" |
124 | #else | |
469e1e5c SC |
125 | #if (defined(__MWERKS__)) |
126 | #include "../common/cwlex_yy.c" | |
127 | #else | |
cfe780fb | 128 | #include "../common/lex_yy.c" |
6de97a3b | 129 | #endif |
469e1e5c | 130 | #endif |
cfe780fb JS |
131 | |
132 | /* | |
133 | void yyerror(s) | |
134 | char *s; | |
135 | { | |
136 | syntax_error(s); | |
137 | } | |
138 | */ | |
139 | ||
140 | /* Ansi prototype. If this doesn't work for you... uncomment | |
141 | the above instead. | |
142 | */ | |
143 | ||
144 | void yyerror(char *s) | |
145 | { | |
146 | syntax_error(s); | |
147 | } | |
148 | ||
149 | /* | |
150 | * Unfortunately, my DOS version of FLEX | |
151 | * requires yywrap to be #def'ed, whereas | |
152 | * the UNIX flex expects a proper function. | |
153 | */ | |
154 | ||
155 | /* Not sure if __SC__ is the appropriate thing | |
156 | * to test | |
157 | */ | |
158 | ||
159 | #ifndef __SC__ | |
160 | #ifdef USE_DEFINE | |
161 | #ifndef yywrap | |
162 | #define yywrap() 1 | |
163 | #endif | |
7fe7d506 | 164 | #else if !defined(__alpha___) && !defined(__ultrix) |
cfe780fb JS |
165 | int yywrap() { return 1; } |
166 | #endif | |
167 | #endif |