]> git.saurik.com Git - wxWidgets.git/blame - contrib/src/deprecated/parser.y
Aliases for [G|S]etCaretLineBack
[wxWidgets.git] / contrib / src / deprecated / parser.y
CommitLineData
4a3bdee6 1/* Version: $Id$ */
99d80019
JS
2/* Copyright: (c) Julian Smart */
3/* Licence: wxWindows Licence */
4a3bdee6
JS
4 %{
5#include "wx/setup.h"
6#include <string.h>
7#ifdef _MSC_VER
8#include <io.h>
9#endif
10#if defined(__GNUWIN32__) && !defined(__TWIN32__)
11#include <sys/unistd.h>
12#endif
13
14#include "wx/deprecated/expr.h"
15
16#ifndef __EXTERN_C__
17#define __EXTERN_C__ 1
18#endif
19
20#if defined(__cplusplus) || defined(__STDC__)
21#if defined(__cplusplus) && defined(__EXTERN_C__)
22extern "C" {
23#endif
24#endif
25int yylex(void);
26int yylook(void);
27int yywrap(void);
28int yyback(int *, int);
29void yyerror(char *);
30
31/* You may need to put /DLEX_SCANNER in your makefile
32 * if you're using LEX!
33 */
34void yyoutput(int);
35
36#if defined(__cplusplus) || defined(__STDC__)
37#if defined(__cplusplus) && defined(__EXTERN_C__)
38}
39#endif
40#endif
41%}
42
43%union {
44 char *s;
45/* struct pexpr *expr; */
46}
47
48
49%start commands
50
51%token <s> INTEGER 1
52%token <s> WORD 2
53%token <s> STRING 3
54%token <s> PERIOD 13
55%token OPEN 4
56%token CLOSE 5
57%token COMMA 6
58%token NEWLINE 7
59%token ERROR 8
60%token OPEN_SQUARE 9
61%token CLOSE_SQUARE 10
62%token EQUALS 11
63%token EXP 14
64
65/* %type <expr> command expr arglist arg arg1 */
66%type <s> command expr arglist arg arg1
67
68%%
69
70commands : /* empty */
71 | commands command
72 ;
73
74command : WORD PERIOD
75 {process_command(proio_cons(wxmake_word($1), NULL)); free($1);}
76 | expr PERIOD
77 {process_command($1);}
78 | error PERIOD
79 {syntax_error("Unrecognized command.");}
80 ;
81
82expr : WORD OPEN arglist CLOSE
83 {$$ = proio_cons(wxmake_word($1), $3); free($1);}
84 | OPEN_SQUARE arglist CLOSE_SQUARE
85 {$$ = $2; }
86 ;
87
88arglist :
89 {$$ = proio_cons(NULL, NULL);}
90 | arg
91 {$$ = proio_cons($1, NULL);}
92 |
93 arg COMMA arglist
94 {$$ = proio_cons($1, $3);}
95 ;
96
97arg : WORD EQUALS arg1
98 {$$ = proio_cons(wxmake_word("="), proio_cons(wxmake_word($1), proio_cons($3, NULL)));
99 free($1); }
100 | arg1
101 {$$ = $1; }
102 ;
103
104arg1 : WORD
105 {$$ = wxmake_word($1); free($1);}
106 | STRING
107 {$$ = wxmake_string($1); free($1);}
108 | INTEGER
109 {$$ = wxmake_integer($1); free($1);}
110 | INTEGER PERIOD INTEGER
111 {$$ = wxmake_real($1, $3); free($1); free($3); }
112 | INTEGER EXP INTEGER
113 {$$ = wxmake_exp($1, $3); free($1); free($3); }
114 |
115 INTEGER PERIOD INTEGER EXP INTEGER
116 {$$ = wxmake_exp2($1, $3, $5); free($1); free($3);
117 free($5); }
118
119 | expr
120 {$$ = $1;}
121 ;
122
123%%
124
125/* We include lexer.c if we are building for gtk, wine or motif
126 * and also whenever we are using configure (marked by __WX_SETUP_H__) for,
127 * for example, cross compilation. */
128#if (defined(__WXGTK__) || defined(__WXWINE__) || defined(__WXMOTIF__)) || defined(__WX_SETUP_H__) && !defined(NO_CONFIGURE)
129#include "lexer.c"
130#elif defined(__WXMAC__) && defined(__APPLE__)
131#include "lexer.c"
132#elif defined(__MWERKS__)
c6dafd93 133#include "cwlex_yy.c"
4a3bdee6 134#else
c6dafd93 135#include "lex_yy.c"
4a3bdee6
JS
136#endif
137
138/*
139void yyerror(s)
140char *s;
141{
142 syntax_error(s);
143}
144*/
145
146/* Ansi prototype. If this doesn't work for you... uncomment
147 the above instead.
148 */
149
150void yyerror(char *s)
151{
152 syntax_error(s);
153}
154
155/*
156 * Unfortunately, my DOS version of FLEX
157 * requires yywrap to be #def'ed, whereas
158 * the UNIX flex expects a proper function.
159 */
160
161/* At least on alphaev6-dec-osf4.0e yywrap() must be #define'd.
162 * RL: ... but on Debian/Alpha(linux) it must not, so hopefully
163 * testing for __OSF__ here is what we really want.
164 */
165#ifdef __OSF__
166#ifndef yywrap
167#define yywrap() 1
168#endif
169#else
170/* HH: Added test for __WX_SETUP_H__ for gnuwin builds
171 * using configure */
172#if !defined(__SC__) && !defined(__GNUWIN32__)
173#ifdef USE_DEFINE
174#ifndef yywrap
175#define yywrap() 1
176#endif
177#elif !defined(__ultrix)
178int yywrap() { return 1; }
179#elif defined(__VMS__)
180int yywrap() { return 1; }
181#endif
182#elif defined(__WX_SETUP_H__)
183int yywrap() { return 1; }
184#endif
185#endif
186