1 %{ 2 /*---------------------------------------------------------------------------* 3 Project: NitroSDK - tools - makelcf 4 File: spec.y 5 6 Copyright 2003-2008 Nintendo. All rights reserved. 7 8 These coded instructions, statements, and computer programs contain 9 proprietary information of Nintendo of America Inc. and/or Nintendo 10 Company Ltd., and are protected by Federal copyright law. They may 11 not be disclosed to third parties or copied or duplicated in any form, 12 in whole or in part, without the prior written consent of Nintendo. 13 14 $Log: spec.y,v $ 15 Revision 1.15 2006/05/10 02:06:00 yasu 16 Added support for CodeWarrior 2.x 17 18 Revision 1.14 2005/09/01 04:30:52 yasu 19 Support for Overlay Group 20 21 Revision 1.13 2005/06/22 00:50:06 yasu 22 Updated copyright year 23 24 Revision 1.12 2005/06/20 12:21:48 yasu 25 Changed Surffix to Suffix 26 27 Revision 1.11 2004/07/10 04:06:17 yasu 28 Added support for command 'Library' 29 Support for modifier ':x' in template 30 Fixed line continue '\' issue 31 32 Revision 1.10 2004/07/08 02:58:53 yasu 33 Support section name for multi-objects as 'Objects' parameters 34 35 Revision 1.9 2004/07/02 07:34:53 yasu 36 Added support for OBJECT( ) 37 38 Revision 1.8 2004/06/24 07:18:54 yasu 39 Support for keyword "Autoload" 40 41 Revision 1.7 2004/06/14 11:28:45 yasu 42 Support for section filter "FOREACH.STATIC.OBJECTS=.sectionName" 43 44 Revision 1.6 2004/02/13 07:13:03 yasu 45 Support for SDK_IRQ_STACKSIZE 46 47 Revision 1.5 2004/02/05 07:09:03 yasu 48 Changed SDK prefix from iris to nitro 49 50 Revision 1.4 2004/01/15 10:47:56 yasu 51 Implementation of a static StackSize 52 53 Revision 1.3 2004/01/14 12:38:08 yasu 54 Changed OverlayName to OverlayDefs 55 56 Revision 1.2 2004/01/07 13:10:17 yasu 57 Fixed all warnings at compile -Wall 58 59 Revision 1.1 2004/01/05 02:32:59 yasu 60 Initial version 61 62 $NoKeywords: $ 63 *---------------------------------------------------------------------------*/ 64 #include <stdio.h> 65 #include <stdlib.h> 66 #include "makelcf.h" 67 68 %} 69 70 %token tSTATIC 71 %token tAUTOLOAD 72 %token tOVERLAY 73 %token tPROPERTY 74 %token tGROUP 75 %token tADDRESS 76 %token tAFTER 77 %token tOBJECT 78 %token tLIBRARY 79 %token tSEARCHSYMBOL 80 %token tSTACKSIZE 81 %token tOVERLAYDEFS 82 %token tOVERLAYTABLE 83 %token tSUFFIX 84 %token tBEGIN 85 %token tEND 86 %token tNL 87 88 %union 89 { 90 u32 integer; 91 char* string; 92 tObjectName object; 93 }; 94 95 %token <integer> tNUMBER 96 %token <string> tSECTIONNAME 97 %token <string> tSTRING_STAR 98 %token <string> tSTRING_GROUP 99 %token <string> tSTRING_FUNCTION 100 %token <string> tSTRING_ID 101 %token <string> tSTRING_QUATED 102 %token <string> tSTRING_NOSPACE 103 %type <string> gFILENAME 104 %type <object> gOBJECTNAME 105 %% 106 107 /*=========================================================================* 108 ConfigFile 109 *=========================================================================*/ 110 111 specFile : sections 112 ; 113 114 sections : /*NULL*/ 115 | sections section 116 ; 117 118 section : tNL 119 | sectionStatic 120 | sectionOverlay 121 | sectionAutoload 122 | sectionProperty 123 ; 124 125 /*=========================================================================== 126 * STATIC staticname 127 * { 128 * ..... 129 * } 130 */ 131 sectionStatic : staticKeyword begin staticParams end 132 ; 133 134 staticKeyword : tSTATIC tSTRING_ID tNL 135 { 136 if ( !StaticSetName( $2 ) ) YYABORT; 137 } 138 ; 139 140 staticParams : /*NULL*/ 141 | staticParams staticParam 142 ; 143 144 staticParam : tNL 145 | staticAddress 146 | staticObjects 147 | staticLibraries 148 | staticSearchSymbols 149 | staticStackSize 150 ; 151 152 staticAddress : tADDRESS tNUMBER tNL 153 { 154 if ( !StaticSetAddress( $2 ) ) YYABORT; 155 } 156 ; 157 158 staticObjects : tOBJECT staticObjectList tNL 159 { 160 if ( !StaticSetObjectSection( "*" ) ) YYABORT; 161 } 162 | tOBJECT staticObjectList tSECTIONNAME tNL 163 { 164 if ( !StaticSetObjectSection( $3 ) ) YYABORT; 165 debug_printf( "$3=%s\n", $3 ); 166 free( $3 ); 167 } 168 ; 169 170 staticObjectList : /*NULL*/ 171 | staticObjectList gOBJECTNAME 172 { 173 if ( !StaticAddObject( $2.string, $2.type ) ) YYABORT; 174 } 175 ; 176 177 staticLibraries : tLIBRARY staticLibraryList tNL 178 { 179 if ( !StaticSetLibrarySection( "*" ) ) YYABORT; 180 } 181 | tLIBRARY staticLibraryList tSECTIONNAME tNL 182 { 183 if ( !StaticSetLibrarySection( $3 ) ) YYABORT; 184 debug_printf( "$3=%s\n", $3 ); 185 free( $3 ); 186 } 187 ; 188 189 staticLibraryList : /*NULL*/ 190 | staticLibraryList gOBJECTNAME 191 { 192 if ( !StaticAddLibrary( $2.string, $2.type ) ) YYABORT; 193 } 194 ; 195 196 staticSearchSymbols : tSEARCHSYMBOL staticSearchSymbolList tNL 197 ; 198 199 staticSearchSymbolList : /*NULL*/ 200 | staticSearchSymbolList tSTRING_ID 201 { 202 if ( !StaticAddSearchSymbol( $2 ) ) YYABORT; 203 } 204 ; 205 206 staticStackSize : tSTACKSIZE tNUMBER tNL 207 { 208 if ( !StaticSetStackSize( $2 ) ) YYABORT; 209 } 210 | tSTACKSIZE tNUMBER tNUMBER 211 { 212 if ( !StaticSetStackSize( $2 ) ) YYABORT; 213 if ( !StaticSetStackSizeIrq( $3 ) ) YYABORT; 214 } 215 ; 216 217 /*=========================================================================== 218 * OVERLAY overlayname 219 * { 220 * ..... 221 * } 222 */ 223 sectionOverlay : overlayKeyword begin overlayParams end 224 ; 225 226 overlayKeyword : tOVERLAY tSTRING_ID tNL 227 { 228 if ( !AddOverlay( $2 ) ) YYABORT; 229 } 230 ; 231 232 overlayParams : /*NULL*/ 233 | overlayParams overlayParam 234 ; 235 236 overlayParam : tNL 237 | overlayGroup 238 | overlayAddress 239 | overlayAfters 240 | overlayObjects 241 | overlaySearchSymbols 242 | overlayLibraries 243 ; 244 245 overlayGroup : tGROUP tSTRING_ID tNL 246 { 247 if ( !OverlaySetGroup( $2 ) ) YYABORT; 248 } 249 ; 250 251 overlayAddress : tADDRESS tNUMBER tNL 252 { 253 if ( !OverlaySetAddress( $2 ) ) YYABORT; 254 } 255 ; 256 257 overlayAfters : tAFTER overlayAfterList tNL 258 ; 259 260 overlayAfterList : /*NULL*/ 261 | overlayAfterList tSTRING_ID 262 { 263 if ( !OverlayAddAfter( $2 ) ) YYABORT; 264 } 265 ; 266 267 overlayObjects : tOBJECT overlayObjectList tNL 268 { 269 if ( !OverlaySetObjectSection( "*" ) ) YYABORT; 270 } 271 | tOBJECT overlayObjectList tSECTIONNAME tNL 272 { 273 if ( !OverlaySetObjectSection( $3 ) ) YYABORT; 274 free( $3 ); 275 } 276 ; 277 278 overlayObjectList : /*NULL*/ 279 | overlayObjectList gOBJECTNAME 280 { 281 if ( !OverlayAddObject( $2.string, $2.type ) ) YYABORT; 282 } 283 ; 284 285 overlayLibraries : tLIBRARY overlayLibraryList tNL 286 { 287 if ( !OverlaySetLibrarySection( "*" ) ) YYABORT; 288 } 289 | tLIBRARY overlayLibraryList tSECTIONNAME tNL 290 { 291 if ( !OverlaySetLibrarySection( $3 ) ) YYABORT; 292 free( $3 ); 293 } 294 ; 295 296 overlayLibraryList : /*NULL*/ 297 | overlayLibraryList gOBJECTNAME 298 { 299 if ( !OverlayAddLibrary( $2.string, $2.type ) ) YYABORT; 300 } 301 ; 302 303 overlaySearchSymbols : tSEARCHSYMBOL overlaySearchSymbolList tNL 304 ; 305 306 overlaySearchSymbolList : /*NULL*/ 307 | overlaySearchSymbolList tSTRING_ID 308 { 309 if ( !OverlayAddSearchSymbol( $2 ) ) YYABORT; 310 } 311 ; 312 313 /*=========================================================================== 314 * AUTOLOAD autoloadname 315 * { 316 * ..... 317 * } 318 */ 319 sectionAutoload : autoloadKeyword begin autoloadParams end 320 ; 321 322 autoloadKeyword : tAUTOLOAD tSTRING_ID tNL 323 { 324 if ( !AddAutoload( $2 ) ) YYABORT; 325 } 326 ; 327 328 autoloadParams : /*NULL*/ 329 | autoloadParams autoloadParam 330 ; 331 332 /* mostly same as overlayParam except no "group" */ 333 autoloadParam : tNL 334 | overlayAddress 335 | overlayAfters 336 | overlayObjects 337 | overlaySearchSymbols 338 | overlayLibraries 339 ; 340 341 /*=========================================================================== 342 * PROPERTY 343 * { 344 * ..... 345 * } 346 */ 347 sectionProperty : propertyKeyword begin propertyParams end 348 ; 349 350 propertyKeyword : tPROPERTY tNL 351 ; 352 353 propertyParams : /*NULL*/ 354 | propertyParams propertyParam 355 ; 356 357 propertyParam : tNL 358 | propertyName 359 | propertyOverlay 360 | propertySuffix 361 ; 362 363 propertyName : tOVERLAYDEFS gFILENAME tNL 364 { 365 if ( !PropertySetOverlayDefs( $2 ) ) YYABORT; 366 } 367 ; 368 369 propertyOverlay : tOVERLAYTABLE gFILENAME tNL 370 { 371 if ( !PropertySetOverlayTable( $2 ) ) YYABORT; 372 } 373 ; 374 375 propertySuffix : tSUFFIX gFILENAME tNL 376 { 377 if ( !PropertySetSuffix( $2 ) ) YYABORT; 378 } 379 ; 380 381 /*=========================================================================== 382 * MISC 383 */ 384 385 begin : tBEGIN tNL 386 ; 387 388 end : tEND tNL 389 ; 390 391 gFILENAME : tSTRING_ID 392 | tSTRING_QUATED 393 | tSTRING_NOSPACE 394 ; 395 396 gOBJECTNAME : gFILENAME 397 { 398 $$.string = $1; 399 $$.type = OBJTYPE_FILE; 400 } 401 | tSTRING_STAR 402 { 403 $$.string = $1; 404 $$.type = OBJTYPE_STAR; 405 } 406 | tSTRING_GROUP 407 { 408 $$.string = $1; 409 $$.type = OBJTYPE_GROUP; 410 } 411 | tSTRING_FUNCTION 412 { 413 $$.string = $1; 414 $$.type = OBJTYPE_OBJECT; 415 } 416 ; 417 %% 418