Suggest URLs for updated setup based on build architecture
[cygwin-setup.git] / iniparse.yy
blobca9b8a78fa0089d584ab62396d1c46bf94a92072
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  */
17 /* Parse the setup.ini files.  inilex.l provides the tokens for this. */
19 #include <string>
20 #include "win32.h"
21 #include "ini.h"
22 #include "iniparse.hh"
23 #include "PackageTrust.h"
25 extern int yyerror (const std::string& s);
26 int yylex ();
28 #include "IniDBBuilder.h"
30 #define YYERROR_VERBOSE 1
31 #define YYINITDEPTH 1000
32 /*#define YYDEBUG 1*/
34 IniDBBuilder *iniBuilder;
35 extern int yylineno;
38 %token STRING
39 %token SETUP_TIMESTAMP
40 %token SETUP_VERSION
41 %token SETUP_MINIMUM_VERSION
42 %token PACKAGEVERSION
43 %token INSTALL
44 %token SOURCE
45 %token SDESC
46 %token LDESC
47 %token REPLACE_VERSIONS
48 %token CATEGORY
49 %token DEPENDS
50 %token REQUIRES
51 %token PROVIDES
52 %token CONFLICTS
53 %token T_PREV T_CURR T_TEST T_OTHER
54 %token MD5 SHA512
55 %token SOURCEPACKAGE
56 %token PACKAGENAME
57 %token COMMA NL AT
58 %token OPENBRACE CLOSEBRACE EQUAL GT LT GTEQUAL LTEQUAL 
59 %token BUILDDEPENDS
60 %token OBSOLETES
61 %token MESSAGE
62 %token ARCH RELEASE
66 whole_file
67  : setup_headers packageseparator packages
68  ;
70 setup_headers: /* empty */
71  | setup_headers header
72  ;
74 header /* non-empty */
75  : SETUP_TIMESTAMP STRING       { iniBuilder->buildTimestamp ($2); } NL
76  | SETUP_VERSION STRING         { iniBuilder->buildVersion ($2); } NL
77  | RELEASE STRING               { iniBuilder->set_release ($2); } NL
78  | ARCH STRING                  { iniBuilder->set_arch ($2); } NL
79  | SETUP_MINIMUM_VERSION STRING { std::string e = iniBuilder->buildMinimumVersion ($2); if (!e.empty()) { yyerror(e); } } NL
80  ;
82 packages: /* empty */
83  | packages package packageseparator
84  ;
86 packageseparator: /* empty */
87  | packageseparator NL
88  ;
90 package /* non-empty */
91  : packagename NL packagedata 
92  ;
94 packagename /* non-empty */
95  : AT STRING            { iniBuilder->buildPackage ($2); }
96  | PACKAGENAME STRING   { iniBuilder->buildPackage ($2); }
97  ;
99 packagedata: /* empty */
100  | packagedata singleitem
103 singleitem /* non-empty */
104  : PACKAGEVERSION STRING NL     { iniBuilder->buildPackageVersion ($2); }
105  | SDESC STRING NL              { iniBuilder->buildPackageSDesc($2); }
106  | LDESC STRING NL              { iniBuilder->buildPackageLDesc($2); }
107  | T_PREV NL                    { iniBuilder->buildPackageTrust (TRUST_PREV); }
108  | T_CURR NL                    { iniBuilder->buildPackageTrust (TRUST_CURR); }
109  | T_TEST NL                    { iniBuilder->buildPackageTrust (TRUST_TEST); }
110  | T_OTHER NL                   { iniBuilder->buildPackageTrust (TRUST_OTHER); }
111  | SOURCEPACKAGE source NL
112  | CATEGORY categories NL
113  | INSTALL STRING STRING MD5 NL { iniBuilder->buildPackageInstall ($2, $3, $4, hashType::md5); }
114  | INSTALL STRING STRING SHA512 NL { iniBuilder->buildPackageInstall ($2, $3, $4, hashType::sha512); }
115  | SOURCE STRING STRING MD5 NL {iniBuilder->buildPackageSource ($2, $3, $4, hashType::md5); }
116  | SOURCE STRING STRING SHA512 NL {iniBuilder->buildPackageSource ($2, $3, $4, hashType::sha512); }
117  | DEPENDS { iniBuilder->buildBeginDepends(); } versionedpackagelist NL
118  | REQUIRES { iniBuilder->buildBeginDepends(); } versionedpackagelistsp NL
119  | BUILDDEPENDS { iniBuilder->buildBeginBuildDepends(); } versionedpackagelist NL
120  | OBSOLETES { iniBuilder->buildBeginObsoletes(); } versionedpackagelist NL
121  | PROVIDES { iniBuilder->buildBeginProvides(); } versionedpackagelist NL
122  | CONFLICTS { iniBuilder->buildBeginConflicts(); } versionedpackagelist NL
123  | REPLACE_VERSIONS versionlist NL
125  | MESSAGE STRING STRING NL     { iniBuilder->buildMessage ($2, $3); }
126  | error NL                     { yyerror (std::string("unrecognized line ")
127                                           + stringify(yylineno)
128                                           + " (do you have the latest setup?)");
129                                 }
132 categories: /* empty */
133  | categories STRING            { iniBuilder->buildPackageCategory ($2); }
136 source /* non-empty */
137  : STRING { iniBuilder->buildSourceName ($1); } versioninfo
140 versioninfo: /* empty */
141  | OPENBRACE STRING CLOSEBRACE { iniBuilder->buildSourceNameVersion ($2); }
144 versionedpackagelist: /* empty */
145  | versionedpackageentry
146  | versionedpackagelist listseparator versionedpackageentry
149 versionedpackagelistsp /* non-empty */
150  : versionedpackageentry
151  | versionedpackagelistsp versionedpackageentry
154 listseparator /* non-empty */
155  : COMMA
156  | COMMA NL
159 versionedpackageentry /* non-empty */
160  : STRING { iniBuilder->buildPackageListNode($1); } versioncriteria
163 versioncriteria: /* empty */
164  | OPENBRACE operator STRING CLOSEBRACE { iniBuilder->buildPackageListOperatorVersion ($3); }
167 operator /* non-empty */
168  : EQUAL { iniBuilder->buildPackageListOperator (PackageSpecification::Equals); }
169  | LT { iniBuilder->buildPackageListOperator (PackageSpecification::LessThan); }
170  | GT { iniBuilder->buildPackageListOperator (PackageSpecification::MoreThan); }
171  | LTEQUAL { iniBuilder->buildPackageListOperator (PackageSpecification::LessThanEquals); }
172  | GTEQUAL { iniBuilder->buildPackageListOperator (PackageSpecification::MoreThanEquals); }
175 versionlist: /* empty */
176  | versionlist STRING { iniBuilder->buildPackageReplaceVersionsList ($2); }