]> cygwin.com Git - cygwin-apps/setup.git/blob - iniparse.y
2007-02-17 Brian Dessent <brian@dessent.net>
[cygwin-apps/setup.git] / iniparse.y
1 %{
2 /*
3 * Copyright (c) 2000, Red Hat, Inc.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * A copy of the GNU General Public License can be found at
11 * http://www.gnu.org/
12 *
13 * Written by DJ Delorie <dj@cygnus.com>
14 *
15 */
16
17 /* Parse the setup.ini files. inilex.l provides the tokens for this. */
18
19 #include <string>
20 #include "win32.h"
21 #include "ini.h"
22 #include "iniparse.h"
23 #include "PackageTrust.h"
24
25 extern int yyerror (const std::string& s);
26 int yylex ();
27
28 #include "IniDBBuilder.h"
29
30 #define YYERROR_VERBOSE 1
31 #define YYINITDEPTH 1000
32 /*#define YYDEBUG 1*/
33
34 IniDBBuilder *iniBuilder;
35 extern int yylineno;
36
37 void add_correct_version();
38 %}
39
40 %token STRING
41 %token SETUP_TIMESTAMP SETUP_VERSION PACKAGEVERSION INSTALL SOURCE SDESC LDESC
42 %token CATEGORY DEPENDS REQUIRES
43 %token APATH PPATH INCLUDE_SETUP EXCLUDE_PACKAGE DOWNLOAD_URL
44 %token T_PREV T_CURR T_TEST
45 %token MD5 INSTALLEDSIZE MAINTAINER PRIORITY
46 %token DESCTAG DESCRIPTION FILESIZE ARCHITECTURE SOURCEPACKAGE MD5LINE
47 %token RECOMMENDS PREDEPENDS
48 %token SUGGESTS CONFLICTS REPLACES PROVIDES PACKAGENAME STRTOEOL PARAGRAPH
49 %token EMAIL COMMA OR NL AT
50 %token OPENBRACE CLOSEBRACE EQUAL GT LT GTEQUAL LTEQUAL
51 %token OPENSQUARE CLOSESQUARE
52 %token BINARYPACKAGE BUILDDEPENDS STANDARDSVERSION FORMAT DIRECTORY FILES
53
54 %%
55
56 whole_file
57 : setup_headers packageseparator packages
58 ;
59
60 setup_headers: /* empty */
61 | setup_headers header
62 ;
63
64 header /* non-empty */
65 : SETUP_TIMESTAMP STRING { iniBuilder->buildTimestamp ($2); } NL
66 | SETUP_VERSION STRING { iniBuilder->buildVersion ($2); } NL
67 ;
68
69 packages: /* empty */
70 | packages package packageseparator
71 ;
72
73 packageseparator: /* empty */
74 | packageseparator NL
75 ;
76
77 package /* non-empty */
78 : packagename NL packagedata
79 ;
80
81 packagename /* non-empty */
82 : AT STRING { iniBuilder->buildPackage ($2); }
83 | PACKAGENAME STRING { iniBuilder->buildPackage ($2); }
84 ;
85
86 packagedata: /* empty */
87 | packagedata singleitem
88 ;
89
90 singleitem /* non-empty */
91 : PACKAGEVERSION STRING NL { iniBuilder->buildPackageVersion ($2); }
92 | SDESC STRING NL { iniBuilder->buildPackageSDesc($2); }
93 | LDESC STRING NL { iniBuilder->buildPackageLDesc($2); }
94 | T_PREV NL { iniBuilder->buildPackageTrust (TRUST_PREV); }
95 | T_CURR NL { iniBuilder->buildPackageTrust (TRUST_CURR); }
96 | T_TEST NL { iniBuilder->buildPackageTrust (TRUST_TEST); }
97 | PRIORITY STRING NL { iniBuilder->buildPriority ($2); }
98 | INSTALLEDSIZE STRING NL { iniBuilder->buildInstalledSize ($2); }
99 | MAINTAINER STRING NL { iniBuilder->buildMaintainer ($2); }
100 | ARCHITECTURE packagearchspec NL { iniBuilder->buildArchitecture ($2); }
101 | FILESIZE STRING NL { iniBuilder->buildInstallSize($2); }
102 | FORMAT STRING NL { /* TODO */ }
103 | DIRECTORY STRING NL { /* TODO */ }
104 | STANDARDSVERSION STRING NL { /* TODO */ }
105 | MD5LINE MD5 NL { iniBuilder->buildInstallMD5 ((unsigned char *)$2); }
106 | SOURCEPACKAGE source NL
107 | CATEGORY categories NL
108 | INSTALL STRING { iniBuilder->buildPackageInstall ($2); } installmeta NL
109 | SOURCE STRING STRING sourceMD5 NL {iniBuilder->buildPackageSource ($2, $3);}
110 | PROVIDES { iniBuilder->buildBeginProvides(); } packagelist NL
111 | BINARYPACKAGE { iniBuilder->buildBeginBinary (); } packagelist NL
112 | CONFLICTS { iniBuilder->buildBeginConflicts(); } versionedpackagelist NL
113 | DEPENDS { iniBuilder->buildBeginDepends(); } versionedpackagelist NL
114 | REQUIRES { iniBuilder->buildBeginDepends(); }versionedpackagelistsp NL
115 | PREDEPENDS { iniBuilder->buildBeginPreDepends(); } versionedpackagelist NL
116 | RECOMMENDS { iniBuilder->buildBeginRecommends(); } versionedpackagelist NL
117 | SUGGESTS { iniBuilder->buildBeginSuggests(); } versionedpackagelist NL
118 | REPLACES { iniBuilder->buildBeginReplaces(); } versionedpackagelist NL
119 | BUILDDEPENDS { iniBuilder->buildBeginBuildDepends(); } versionedpackagelist NL
120 | FILES NL SourceFilesList
121 | DESCTAG mlinedesc
122 | error { yyerror (std::string("unrecognized line ")
123 + stringify(yylineno)
124 + " (do you have the latest setup?)");
125 }
126 ;
127
128 packagearchspec: /* empty */
129 | packagearchspec STRING { iniBuilder->buildArchitecture ($2); }
130 ;
131
132 categories: /* empty */
133 | categories STRING { iniBuilder->buildPackageCategory ($2); }
134 ;
135
136 installmeta: /* empty */
137 | STRING installMD5 { iniBuilder->buildInstallSize($1); }
138 ;
139
140 installMD5: /* empty */
141 | MD5 { iniBuilder->buildInstallMD5 ((unsigned char *)$1);}
142 ;
143
144 sourceMD5: /* empty */
145 | MD5 { iniBuilder->buildSourceMD5 ((unsigned char *)$1); }
146 ;
147
148 source /* non-empty */
149 : STRING { iniBuilder->buildSourceName ($1); } versioninfo
150 ;
151
152 versioninfo: /* empty */
153 | OPENBRACE STRING CLOSEBRACE { iniBuilder->buildSourceNameVersion ($2); }
154 ;
155
156 mlinedesc: /* empty */
157 | mlinedesc STRTOEOL NL { iniBuilder->buildDescription ($2); }
158 | mlinedesc STRTOEOL PARAGRAPH { iniBuilder->buildDescription ($2); }
159 ;
160
161 packagelist /* non-empty */
162 : packagelist COMMA { iniBuilder->buildPackageListAndNode(); } packageentry
163 | { iniBuilder->buildPackageListAndNode(); } packageentry
164 ;
165
166 packageentry /* empty not allowed */
167 : STRING { iniBuilder->buildPackageListOrNode($1); }
168 | packageentry OR STRING { iniBuilder->buildPackageListOrNode($3); }
169 ;
170
171 versionedpackagelist /* non-empty */
172 : { iniBuilder->buildPackageListAndNode(); } versionedpackageentry
173 | versionedpackagelist listseparator { iniBuilder->buildPackageListAndNode(); } versionedpackageentry
174 ;
175
176 versionedpackagelistsp /* non-empty */
177 : { iniBuilder->buildPackageListAndNode(); } versionedpackageentry
178 | versionedpackagelistsp { iniBuilder->buildPackageListAndNode(); } versionedpackageentry
179 ;
180
181
182 listseparator: /* empty */
183 | COMMA
184 | COMMA NL
185 ;
186
187 versionedpackageentry /* empty not allowed */
188 : STRING { iniBuilder->buildPackageListOrNode($1); } versioncriteria architecture
189 | versionedpackageentry OR STRING { iniBuilder->buildPackageListOrNode($3); } versioncriteria architecture
190 ;
191
192 versioncriteria: /* empty */
193 | OPENBRACE operator STRING CLOSEBRACE { iniBuilder->buildPackageListOperatorVersion ($3); }
194 ;
195
196 operator /* non-empty */
197 : EQUAL { iniBuilder->buildPackageListOperator (PackageSpecification::Equals); }
198 | LT { iniBuilder->buildPackageListOperator (PackageSpecification::LessThan); }
199 | GT { iniBuilder->buildPackageListOperator (PackageSpecification::MoreThan); }
200 | LTEQUAL { iniBuilder->buildPackageListOperator (PackageSpecification::LessThanEquals); }
201 | GTEQUAL { iniBuilder->buildPackageListOperator (PackageSpecification::MoreThanEquals); }
202 ;
203
204 architecture: /* empty */
205 | OPENSQUARE architecturelist CLOSESQUARE
206 ;
207
208 architecturelist: /* empty */
209 | architecturelist STRING
210 ;
211
212
213 SourceFilesList: /* empty */
214 | SourceFilesList MD5 STRING STRING { iniBuilder->buildSourceFile ((unsigned char *)$2, $3, $4); } NL
215 ;
216
217 %%
This page took 0.044382 seconds and 5 git commands to generate.