1 %{ 2 /*---------------------------------------------------------------------------* 3 Project: TwlSDK - 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 $Date:: 2008-09-18#$ 15 $Rev: 8573 $ 16 $Author: okubata_ryoma $ 17 *---------------------------------------------------------------------------*/ 18 #include <stdio.h> 19 #include <stdlib.h> 20 #include "makelcf.h" 21 22 %} 23 24 %token tSTATIC 25 %token tAUTOLOAD 26 %token tOVERLAY 27 %token tLTDAUTOLOAD 28 %token tLTDOVERLAY 29 %token tPROPERTY 30 %token tGROUP 31 %token tADDRESS 32 %token tAFTER 33 %token tOBJECT 34 %token tLIBRARY 35 %token tSEARCHSYMBOL 36 %token tSTACKSIZE 37 %token tOVERLAYDEFS 38 %token tOVERLAYTABLE 39 %token tLTDOVERLAYDEFS 40 %token tLTDOVERLAYTABLE 41 %token tSUFFIX 42 %token tFLXSUFFIX 43 %token tLTDSUFFIX 44 %token tBEGIN 45 %token tEND 46 %token tNL 47 48 %union 49 { 50 u32 integer; 51 char* string; 52 tObjectName object; 53 }; 54 55 %token <integer> tNUMBER 56 %token <string> tSECTIONNAME 57 %token <string> tSTRING_STAR 58 %token <string> tSTRING_GROUP 59 %token <string> tSTRING_FUNCTION 60 %token <string> tSTRING_ID 61 %token <string> tSTRING_QUATED 62 %token <string> tSTRING_NOSPACE 63 %type <string> gFILENAME 64 %type <object> gOBJECTNAME 65 %% 66 67 /*=========================================================================* 68 ConfigFile 69 *=========================================================================*/ 70 71 specFile : sections 72 ; 73 74 sections : /*NULL*/ 75 | sections section 76 ; 77 78 section : tNL 79 | sectionStatic 80 | sectionOverlay 81 | sectionAutoload 82 | sectionLtdoverlay 83 | sectionLtdautoload 84 | sectionProperty 85 ; 86 87 /*=========================================================================== 88 * STATIC staticname 89 * { 90 * ..... 91 * } 92 */ 93 sectionStatic : staticKeyword begin staticParams end 94 ; 95 96 staticKeyword : tSTATIC tSTRING_ID tNL 97 { 98 if ( !StaticSetName( $2 ) ) YYABORT; 99 } 100 ; 101 102 staticParams : /*NULL*/ 103 | staticParams staticParam 104 ; 105 106 staticParam : tNL 107 | staticAddress 108 | staticObjects 109 | staticLibraries 110 | staticSearchSymbols 111 | staticStackSize 112 ; 113 114 staticAddress : tADDRESS tNUMBER tNL 115 { 116 if ( !StaticSetAddress( $2 ) ) YYABORT; 117 } 118 ; 119 120 staticObjects : tOBJECT staticObjectList tNL 121 { 122 if ( !StaticSetObjectSection( "*" ) ) YYABORT; 123 } 124 | tOBJECT staticObjectList tSECTIONNAME tNL 125 { 126 if ( !StaticSetObjectSection( $3 ) ) YYABORT; 127 debug_printf( "$3=%s\n", $3 ); 128 free( $3 ); 129 } 130 ; 131 132 staticObjectList : /*NULL*/ 133 | staticObjectList gOBJECTNAME 134 { 135 if ( !StaticAddObject( $2.string, $2.type ) ) YYABORT; 136 } 137 ; 138 139 staticLibraries : tLIBRARY staticLibraryList tNL 140 { 141 if ( !StaticSetLibrarySection( "*" ) ) YYABORT; 142 } 143 | tLIBRARY staticLibraryList tSECTIONNAME tNL 144 { 145 if ( !StaticSetLibrarySection( $3 ) ) YYABORT; 146 debug_printf( "$3=%s\n", $3 ); 147 free( $3 ); 148 } 149 ; 150 151 staticLibraryList : /*NULL*/ 152 | staticLibraryList gOBJECTNAME 153 { 154 if ( !StaticAddLibrary( $2.string, $2.type ) ) YYABORT; 155 } 156 ; 157 158 staticSearchSymbols : tSEARCHSYMBOL staticSearchSymbolList tNL 159 ; 160 161 staticSearchSymbolList : /*NULL*/ 162 | staticSearchSymbolList tSTRING_ID 163 { 164 if ( !StaticAddSearchSymbol( $2 ) ) YYABORT; 165 } 166 ; 167 168 staticStackSize : tSTACKSIZE tNUMBER tNL 169 { 170 if ( !StaticSetStackSize( $2 ) ) YYABORT; 171 } 172 | tSTACKSIZE tNUMBER tNUMBER 173 { 174 if ( !StaticSetStackSize( $2 ) ) YYABORT; 175 if ( !StaticSetStackSizeIrq( $3 ) ) YYABORT; 176 } 177 ; 178 179 /*=========================================================================== 180 * OVERLAY overlayname 181 * { 182 * ..... 183 * } 184 */ 185 sectionOverlay : overlayKeyword begin overlayParams end 186 ; 187 188 overlayKeyword : tOVERLAY tSTRING_ID tNL 189 { 190 if ( !AddOverlay( $2 ) ) YYABORT; 191 } 192 ; 193 194 overlayParams : /*NULL*/ 195 | overlayParams overlayParam 196 ; 197 198 overlayParam : tNL 199 | overlayGroup 200 | overlayAddress 201 | overlayAfters 202 | overlayObjects 203 | overlaySearchSymbols 204 | overlayLibraries 205 ; 206 207 overlayGroup : tGROUP tSTRING_ID tNL 208 { 209 if ( !OverlaySetGroup( $2 ) ) YYABORT; 210 } 211 ; 212 213 overlayAddress : tADDRESS tNUMBER tNL 214 { 215 if ( !OverlaySetAddress( $2 ) ) YYABORT; 216 } 217 ; 218 219 overlayAfters : tAFTER overlayAfterList tNL 220 ; 221 222 overlayAfterList : /*NULL*/ 223 | overlayAfterList tSTRING_ID 224 { 225 if ( !OverlayAddAfter( $2 ) ) YYABORT; 226 } 227 ; 228 229 overlayObjects : tOBJECT overlayObjectList tNL 230 { 231 if ( !OverlaySetObjectSection( "*" ) ) YYABORT; 232 } 233 | tOBJECT overlayObjectList tSECTIONNAME tNL 234 { 235 if ( !OverlaySetObjectSection( $3 ) ) YYABORT; 236 free( $3 ); 237 } 238 ; 239 240 overlayObjectList : /*NULL*/ 241 | overlayObjectList gOBJECTNAME 242 { 243 if ( !OverlayAddObject( $2.string, $2.type ) ) YYABORT; 244 } 245 ; 246 247 overlayLibraries : tLIBRARY overlayLibraryList tNL 248 { 249 if ( !OverlaySetLibrarySection( "*" ) ) YYABORT; 250 } 251 | tLIBRARY overlayLibraryList tSECTIONNAME tNL 252 { 253 if ( !OverlaySetLibrarySection( $3 ) ) YYABORT; 254 free( $3 ); 255 } 256 ; 257 258 overlayLibraryList : /*NULL*/ 259 | overlayLibraryList gOBJECTNAME 260 { 261 if ( !OverlayAddLibrary( $2.string, $2.type ) ) YYABORT; 262 } 263 ; 264 265 overlaySearchSymbols : tSEARCHSYMBOL overlaySearchSymbolList tNL 266 ; 267 268 overlaySearchSymbolList : /*NULL*/ 269 | overlaySearchSymbolList tSTRING_ID 270 { 271 if ( !OverlayAddSearchSymbol( $2 ) ) YYABORT; 272 } 273 ; 274 275 /*=========================================================================== 276 * AUTOLOAD autoloadname 277 * { 278 * ..... 279 * } 280 */ 281 sectionAutoload : autoloadKeyword begin autoloadParams end 282 ; 283 284 autoloadKeyword : tAUTOLOAD tSTRING_ID tNL 285 { 286 if ( !AddAutoload( $2 ) ) YYABORT; 287 } 288 ; 289 290 autoloadParams : /*NULL*/ 291 | autoloadParams autoloadParam 292 ; 293 294 /* mostly same as overlayParam except no "group" */ 295 autoloadParam : tNL 296 | overlayAddress 297 | overlayAfters 298 | overlayObjects 299 | overlaySearchSymbols 300 | overlayLibraries 301 ; 302 303 /*=========================================================================== 304 * LTDOVERLAY ltdoverlayname 305 * { 306 * ..... 307 * } 308 */ 309 sectionLtdoverlay : ltdoverlayKeyword begin ltdoverlayParams end 310 ; 311 312 ltdoverlayKeyword : tLTDOVERLAY tSTRING_ID tNL 313 { 314 if ( !AddLtdoverlay( $2 ) ) YYABORT; 315 } 316 ; 317 318 ltdoverlayParams : /*NULL*/ 319 | ltdoverlayParams ltdoverlayParam 320 ; 321 322 ltdoverlayParam : tNL 323 | overlayGroup 324 | overlayAddress 325 | overlayAfters 326 | overlayObjects 327 | overlaySearchSymbols 328 | overlayLibraries 329 ; 330 331 /*=========================================================================== 332 * LTDAUTOLOAD ltdautoloadname 333 * { 334 * ..... 335 * } 336 */ 337 sectionLtdautoload : ltdautoloadKeyword begin ltdautoloadParams end 338 ; 339 340 ltdautoloadKeyword : tLTDAUTOLOAD tSTRING_ID tNL 341 { 342 if ( !AddLtdautoload( $2 ) ) YYABORT; 343 } 344 ; 345 346 ltdautoloadParams : /*NULL*/ 347 | ltdautoloadParams ltdautoloadParam 348 ; 349 350 /* mostly same as overlayParam except no "group" */ 351 ltdautoloadParam : tNL 352 | overlayAddress 353 | overlayAfters 354 | overlayObjects 355 | overlaySearchSymbols 356 | overlayLibraries 357 ; 358 359 /*=========================================================================== 360 * PROPERTY 361 * { 362 * ..... 363 * } 364 */ 365 sectionProperty : propertyKeyword begin propertyParams end 366 ; 367 368 propertyKeyword : tPROPERTY tNL 369 ; 370 371 propertyParams : /*NULL*/ 372 | propertyParams propertyParam 373 ; 374 375 propertyParam : tNL 376 | propertyName 377 | propertyOverlay 378 | propertyLtdname 379 | propertyLtdoverlay 380 | propertySuffix 381 | propertyFlxsuffix 382 | propertyLtdsuffix 383 ; 384 385 propertyName : tOVERLAYDEFS gFILENAME tNL 386 { 387 if ( !PropertySetOverlayDefs( $2 ) ) YYABORT; 388 } 389 ; 390 391 propertyOverlay : tOVERLAYTABLE gFILENAME tNL 392 { 393 if ( !PropertySetOverlayTable( $2 ) ) YYABORT; 394 } 395 ; 396 397 propertyLtdname : tLTDOVERLAYDEFS gFILENAME tNL 398 { 399 if ( !PropertySetLtdoverlayDefs( $2 ) ) YYABORT; 400 } 401 ; 402 403 propertyLtdoverlay : tLTDOVERLAYTABLE gFILENAME tNL 404 { 405 if ( !PropertySetLtdoverlayTable( $2 ) ) YYABORT; 406 } 407 ; 408 409 propertySuffix : tSUFFIX gFILENAME tNL 410 { 411 if ( !PropertySetSuffix( $2 ) ) YYABORT; 412 } 413 ; 414 415 propertyFlxsuffix : tFLXSUFFIX gFILENAME tNL 416 { 417 if ( !PropertySetFlxsuffix( $2 ) ) YYABORT; 418 } 419 ; 420 421 propertyLtdsuffix : tLTDSUFFIX gFILENAME tNL 422 { 423 if ( !PropertySetLtdsuffix( $2 ) ) YYABORT; 424 } 425 ; 426 427 /*=========================================================================== 428 * MISC 429 */ 430 431 begin : tBEGIN tNL 432 ; 433 434 end : tEND tNL 435 ; 436 437 gFILENAME : tSTRING_ID 438 | tSTRING_QUATED 439 | tSTRING_NOSPACE 440 ; 441 442 gOBJECTNAME : gFILENAME 443 { 444 $$.string = $1; 445 $$.type = OBJTYPE_FILE; 446 } 447 | tSTRING_STAR 448 { 449 $$.string = $1; 450 $$.type = OBJTYPE_STAR; 451 } 452 | tSTRING_GROUP 453 { 454 $$.string = $1; 455 $$.type = OBJTYPE_GROUP; 456 } 457 | tSTRING_FUNCTION 458 { 459 $$.string = $1; 460 $$.type = OBJTYPE_OBJECT; 461 } 462 ; 463 %% 464