1 // SPDX-License-Identifier: GPL-2.0-or-later << 2 /* 1 /* 3 * (C) Copyright David Gibson <dwg@au1.ibm.com> 2 * (C) Copyright David Gibson <dwg@au1.ibm.com>, IBM Corporation. 2005. >> 3 * >> 4 * >> 5 * This program is free software; you can redistribute it and/or >> 6 * modify it under the terms of the GNU General Public License as >> 7 * published by the Free Software Foundation; either version 2 of the >> 8 * License, or (at your option) any later version. >> 9 * >> 10 * This program is distributed in the hope that it will be useful, >> 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of >> 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU >> 13 * General Public License for more details. >> 14 * >> 15 * You should have received a copy of the GNU General Public License >> 16 * along with this program; if not, write to the Free Software >> 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 >> 18 * USA 4 */ 19 */ 5 %locations << 6 << 7 %{ 20 %{ 8 #include <stdio.h> 21 #include <stdio.h> 9 #include <inttypes.h> << 10 22 11 #include "dtc.h" 23 #include "dtc.h" 12 #include "srcpos.h" 24 #include "srcpos.h" 13 25 14 extern int yylex(void); 26 extern int yylex(void); 15 extern void yyerror(char const *s); 27 extern void yyerror(char const *s); 16 #define ERROR(loc, ...) \ 28 #define ERROR(loc, ...) \ 17 do { \ 29 do { \ 18 srcpos_error((loc), "Error", _ 30 srcpos_error((loc), "Error", __VA_ARGS__); \ 19 treesource_error = true; \ 31 treesource_error = true; \ 20 } while (0) 32 } while (0) 21 33 22 #define YYERROR_CALL(msg) yyerror(msg) !! 34 extern struct boot_info *the_boot_info; 23 << 24 extern struct dt_info *parser_output; << 25 extern bool treesource_error; 35 extern bool treesource_error; 26 << 27 static bool is_ref_relative(const char *ref) << 28 { << 29 return ref[0] != '/' && strchr(&ref[1] << 30 } << 31 << 32 %} 36 %} 33 37 34 %union { 38 %union { 35 char *propnodename; 39 char *propnodename; 36 char *labelref; 40 char *labelref; 37 uint8_t byte; 41 uint8_t byte; 38 struct data data; 42 struct data data; 39 43 40 struct { 44 struct { 41 struct data data; 45 struct data data; 42 int bits; 46 int bits; 43 } array; 47 } array; 44 48 45 struct property *prop; 49 struct property *prop; 46 struct property *proplist; 50 struct property *proplist; 47 struct node *node; 51 struct node *node; 48 struct node *nodelist; 52 struct node *nodelist; 49 struct reserve_info *re; 53 struct reserve_info *re; 50 uint64_t integer; 54 uint64_t integer; 51 unsigned int flags; << 52 } 55 } 53 56 54 %token DT_V1 57 %token DT_V1 55 %token DT_PLUGIN << 56 %token DT_MEMRESERVE 58 %token DT_MEMRESERVE 57 %token DT_LSHIFT DT_RSHIFT DT_LE DT_GE DT_EQ D 59 %token DT_LSHIFT DT_RSHIFT DT_LE DT_GE DT_EQ DT_NE DT_AND DT_OR 58 %token DT_BITS 60 %token DT_BITS 59 %token DT_DEL_PROP 61 %token DT_DEL_PROP 60 %token DT_DEL_NODE 62 %token DT_DEL_NODE 61 %token DT_OMIT_NO_REF << 62 %token <propnodename> DT_PROPNODENAME 63 %token <propnodename> DT_PROPNODENAME 63 %token <integer> DT_LITERAL 64 %token <integer> DT_LITERAL 64 %token <integer> DT_CHAR_LITERAL 65 %token <integer> DT_CHAR_LITERAL 65 %token <byte> DT_BYTE 66 %token <byte> DT_BYTE 66 %token <data> DT_STRING 67 %token <data> DT_STRING 67 %token <labelref> DT_LABEL 68 %token <labelref> DT_LABEL 68 %token <labelref> DT_LABEL_REF !! 69 %token <labelref> DT_REF 69 %token <labelref> DT_PATH_REF << 70 %token DT_INCBIN 70 %token DT_INCBIN 71 71 72 %type <data> propdata 72 %type <data> propdata 73 %type <data> propdataprefix 73 %type <data> propdataprefix 74 %type <flags> header << 75 %type <flags> headers << 76 %type <re> memreserve 74 %type <re> memreserve 77 %type <re> memreserves 75 %type <re> memreserves 78 %type <array> arrayprefix 76 %type <array> arrayprefix 79 %type <data> bytestring 77 %type <data> bytestring 80 %type <prop> propdef 78 %type <prop> propdef 81 %type <proplist> proplist 79 %type <proplist> proplist 82 %type <labelref> dt_ref << 83 80 84 %type <node> devicetree 81 %type <node> devicetree 85 %type <node> nodedef 82 %type <node> nodedef 86 %type <node> subnode 83 %type <node> subnode 87 %type <nodelist> subnodes 84 %type <nodelist> subnodes 88 85 89 %type <integer> integer_prim 86 %type <integer> integer_prim 90 %type <integer> integer_unary 87 %type <integer> integer_unary 91 %type <integer> integer_mul 88 %type <integer> integer_mul 92 %type <integer> integer_add 89 %type <integer> integer_add 93 %type <integer> integer_shift 90 %type <integer> integer_shift 94 %type <integer> integer_rela 91 %type <integer> integer_rela 95 %type <integer> integer_eq 92 %type <integer> integer_eq 96 %type <integer> integer_bitand 93 %type <integer> integer_bitand 97 %type <integer> integer_bitxor 94 %type <integer> integer_bitxor 98 %type <integer> integer_bitor 95 %type <integer> integer_bitor 99 %type <integer> integer_and 96 %type <integer> integer_and 100 %type <integer> integer_or 97 %type <integer> integer_or 101 %type <integer> integer_trinary 98 %type <integer> integer_trinary 102 %type <integer> integer_expr 99 %type <integer> integer_expr 103 100 104 %% 101 %% 105 102 106 sourcefile: 103 sourcefile: 107 headers memreserves devicetree !! 104 DT_V1 ';' memreserves devicetree 108 { << 109 parser_output = build_ << 110 << 111 } << 112 ; << 113 << 114 header: << 115 DT_V1 ';' << 116 { << 117 $$ = DTSF_V1; << 118 } << 119 | DT_V1 ';' DT_PLUGIN ';' << 120 { << 121 $$ = DTSF_V1 | DTSF_PL << 122 } << 123 ; << 124 << 125 headers: << 126 header << 127 | header headers << 128 { 105 { 129 if ($2 != $1) !! 106 the_boot_info = build_boot_info($3, $4, 130 ERROR(&@2, "He !! 107 guess_boot_cpuid($4)); 131 $$ = $1; << 132 } 108 } 133 ; 109 ; 134 110 135 memreserves: 111 memreserves: 136 /* empty */ 112 /* empty */ 137 { 113 { 138 $$ = NULL; 114 $$ = NULL; 139 } 115 } 140 | memreserve memreserves 116 | memreserve memreserves 141 { 117 { 142 $$ = chain_reserve_ent 118 $$ = chain_reserve_entry($1, $2); 143 } 119 } 144 ; 120 ; 145 121 146 memreserve: 122 memreserve: 147 DT_MEMRESERVE integer_prim integer_p 123 DT_MEMRESERVE integer_prim integer_prim ';' 148 { 124 { 149 $$ = build_reserve_ent 125 $$ = build_reserve_entry($2, $3); 150 } 126 } 151 | DT_LABEL memreserve 127 | DT_LABEL memreserve 152 { 128 { 153 add_label(&$2->labels, 129 add_label(&$2->labels, $1); 154 $$ = $2; 130 $$ = $2; 155 } 131 } 156 ; 132 ; 157 133 158 dt_ref: DT_LABEL_REF | DT_PATH_REF; << 159 << 160 devicetree: 134 devicetree: 161 '/' nodedef 135 '/' nodedef 162 { 136 { 163 $$ = name_node($2, "") 137 $$ = name_node($2, ""); 164 } 138 } 165 | devicetree '/' nodedef 139 | devicetree '/' nodedef 166 { 140 { 167 $$ = merge_nodes($1, $ 141 $$ = merge_nodes($1, $3); 168 } 142 } 169 | dt_ref nodedef !! 143 170 { !! 144 | devicetree DT_LABEL DT_REF nodedef 171 /* << 172 * We rely on the rule << 173 * versioninfo plugi << 174 * so $-1 is what we w << 175 */ << 176 if (!($<flags>-1 & DTS << 177 ERROR(&@2, "La << 178 else if (is_ref_relati << 179 ERROR(&@2, "La << 180 $$ = add_orphan_node( << 181 name_n << 182 << 183 $2, $1 << 184 } << 185 | devicetree DT_LABEL dt_ref nodedef << 186 { 145 { 187 struct node *target = 146 struct node *target = get_node_by_ref($1, $3); 188 147 189 if (($<flags>-1 & DTSF !! 148 add_label(&target->labels, $2); 190 ERROR(&@2, "La !! 149 if (target) 191 << 192 if (target) { << 193 add_label(&tar << 194 merge_nodes(ta 150 merge_nodes(target, $4); 195 } else !! 151 else 196 ERROR(&@3, "La 152 ERROR(&@3, "Label or path %s not found", $3); 197 $$ = $1; 153 $$ = $1; 198 } 154 } 199 | devicetree DT_PATH_REF nodedef !! 155 | devicetree DT_REF nodedef 200 { << 201 /* << 202 * We rely on the rule << 203 * versioninfo plugi << 204 * so $-1 is what we w << 205 */ << 206 if ($<flags>-1 & DTSF_ << 207 if (is_ref_rel << 208 ERROR( << 209 add_orphan_nod << 210 } else { << 211 struct node *t << 212 << 213 if (target) << 214 merge_ << 215 else << 216 ERROR( << 217 } << 218 $$ = $1; << 219 } << 220 | devicetree DT_LABEL_REF nodedef << 221 { 156 { 222 struct node *target = 157 struct node *target = get_node_by_ref($1, $2); 223 158 224 if (target) { << 225 merge_nodes(ta << 226 } else { << 227 /* << 228 * We rely on << 229 * versionin << 230 * so $-1 is w << 231 */ << 232 if ($<flags>-1 << 233 add_or << 234 else << 235 ERROR( << 236 } << 237 $$ = $1; << 238 } << 239 | devicetree DT_DEL_NODE dt_ref ';' << 240 { << 241 struct node *target = << 242 << 243 if (target) 159 if (target) 244 delete_node(ta !! 160 merge_nodes(target, $3); 245 else 161 else 246 ERROR(&@3, "La !! 162 ERROR(&@2, "Label or path %s not found", $2); 247 << 248 << 249 $$ = $1; 163 $$ = $1; 250 } 164 } 251 | devicetree DT_OMIT_NO_REF dt_ref ';' !! 165 | devicetree DT_DEL_NODE DT_REF ';' 252 { 166 { 253 struct node *target = 167 struct node *target = get_node_by_ref($1, $3); 254 168 255 if (target) 169 if (target) 256 omit_node_if_u !! 170 delete_node(target); 257 else 171 else 258 ERROR(&@3, "La 172 ERROR(&@3, "Label or path %s not found", $3); 259 173 260 174 261 $$ = $1; 175 $$ = $1; 262 } 176 } 263 ; 177 ; 264 178 265 nodedef: 179 nodedef: 266 '{' proplist subnodes '}' ';' 180 '{' proplist subnodes '}' ';' 267 { 181 { 268 $$ = build_node($2, $3 !! 182 $$ = build_node($2, $3); 269 } 183 } 270 ; 184 ; 271 185 272 proplist: 186 proplist: 273 /* empty */ 187 /* empty */ 274 { 188 { 275 $$ = NULL; 189 $$ = NULL; 276 } 190 } 277 | proplist propdef 191 | proplist propdef 278 { 192 { 279 $$ = chain_property($2 193 $$ = chain_property($2, $1); 280 } 194 } 281 ; 195 ; 282 196 283 propdef: 197 propdef: 284 DT_PROPNODENAME '=' propdata ';' 198 DT_PROPNODENAME '=' propdata ';' 285 { 199 { 286 $$ = build_property($1 !! 200 $$ = build_property($1, $3); 287 free($1); << 288 } 201 } 289 | DT_PROPNODENAME ';' 202 | DT_PROPNODENAME ';' 290 { 203 { 291 $$ = build_property($1 !! 204 $$ = build_property($1, empty_data); 292 free($1); << 293 } 205 } 294 | DT_DEL_PROP DT_PROPNODENAME ';' 206 | DT_DEL_PROP DT_PROPNODENAME ';' 295 { 207 { 296 $$ = build_property_de 208 $$ = build_property_delete($2); 297 free($2); << 298 } 209 } 299 | DT_LABEL propdef 210 | DT_LABEL propdef 300 { 211 { 301 add_label(&$2->labels, 212 add_label(&$2->labels, $1); 302 $$ = $2; 213 $$ = $2; 303 } 214 } 304 ; 215 ; 305 216 306 propdata: 217 propdata: 307 propdataprefix DT_STRING 218 propdataprefix DT_STRING 308 { 219 { 309 $$ = data_merge($1, $2 220 $$ = data_merge($1, $2); 310 } 221 } 311 | propdataprefix arrayprefix '>' 222 | propdataprefix arrayprefix '>' 312 { 223 { 313 $$ = data_merge($1, $2 224 $$ = data_merge($1, $2.data); 314 } 225 } 315 | propdataprefix '[' bytestring ']' 226 | propdataprefix '[' bytestring ']' 316 { 227 { 317 $$ = data_merge($1, $3 228 $$ = data_merge($1, $3); 318 } 229 } 319 | propdataprefix dt_ref !! 230 | propdataprefix DT_REF 320 { 231 { 321 $1 = data_add_marker($ << 322 $$ = data_add_marker($ 232 $$ = data_add_marker($1, REF_PATH, $2); 323 } 233 } 324 | propdataprefix DT_INCBIN '(' DT_STRI 234 | propdataprefix DT_INCBIN '(' DT_STRING ',' integer_prim ',' integer_prim ')' 325 { 235 { 326 FILE *f = srcfile_rela 236 FILE *f = srcfile_relative_open($4.val, NULL); 327 struct data d; 237 struct data d; 328 238 329 if ($6 != 0) 239 if ($6 != 0) 330 if (fseek(f, $ 240 if (fseek(f, $6, SEEK_SET) != 0) 331 die("C 241 die("Couldn't seek to offset %llu in \"%s\": %s", 332 (u 242 (unsigned long long)$6, $4.val, 333 st 243 strerror(errno)); 334 244 335 d = data_copy_file(f, 245 d = data_copy_file(f, $8); 336 246 337 $$ = data_merge($1, d) 247 $$ = data_merge($1, d); 338 fclose(f); 248 fclose(f); 339 } 249 } 340 | propdataprefix DT_INCBIN '(' DT_STRI 250 | propdataprefix DT_INCBIN '(' DT_STRING ')' 341 { 251 { 342 FILE *f = srcfile_rela 252 FILE *f = srcfile_relative_open($4.val, NULL); 343 struct data d = empty_ 253 struct data d = empty_data; 344 254 345 d = data_copy_file(f, 255 d = data_copy_file(f, -1); 346 256 347 $$ = data_merge($1, d) 257 $$ = data_merge($1, d); 348 fclose(f); 258 fclose(f); 349 } 259 } 350 | propdata DT_LABEL 260 | propdata DT_LABEL 351 { 261 { 352 $$ = data_add_marker($ 262 $$ = data_add_marker($1, LABEL, $2); 353 } 263 } 354 ; 264 ; 355 265 356 propdataprefix: 266 propdataprefix: 357 /* empty */ 267 /* empty */ 358 { 268 { 359 $$ = empty_data; 269 $$ = empty_data; 360 } 270 } 361 | propdata ',' 271 | propdata ',' 362 { 272 { 363 $$ = $1; 273 $$ = $1; 364 } 274 } 365 | propdataprefix DT_LABEL 275 | propdataprefix DT_LABEL 366 { 276 { 367 $$ = data_add_marker($ 277 $$ = data_add_marker($1, LABEL, $2); 368 } 278 } 369 ; 279 ; 370 280 371 arrayprefix: 281 arrayprefix: 372 DT_BITS DT_LITERAL '<' 282 DT_BITS DT_LITERAL '<' 373 { 283 { 374 unsigned long long bit 284 unsigned long long bits; 375 enum markertype type = << 376 285 377 bits = $2; 286 bits = $2; 378 287 379 switch (bits) { !! 288 if ((bits != 8) && (bits != 16) && 380 case 8: type = TYPE_UI !! 289 (bits != 32) && (bits != 64)) { 381 case 16: type = TYPE_U << 382 case 32: type = TYPE_U << 383 case 64: type = TYPE_U << 384 default: << 385 ERROR(&@2, "Ar 290 ERROR(&@2, "Array elements must be" 386 " 8, 16, 291 " 8, 16, 32 or 64-bits"); 387 bits = 32; 292 bits = 32; 388 } 293 } 389 294 390 $$.data = data_add_mar !! 295 $$.data = empty_data; 391 $$.bits = bits; 296 $$.bits = bits; 392 } 297 } 393 | '<' 298 | '<' 394 { 299 { 395 $$.data = data_add_mar !! 300 $$.data = empty_data; 396 $$.bits = 32; 301 $$.bits = 32; 397 } 302 } 398 | arrayprefix integer_prim 303 | arrayprefix integer_prim 399 { 304 { 400 if ($1.bits < 64) { 305 if ($1.bits < 64) { 401 uint64_t mask 306 uint64_t mask = (1ULL << $1.bits) - 1; 402 /* 307 /* 403 * Bits above 308 * Bits above mask must either be all zero 404 * (positive w 309 * (positive within range of mask) or all one 405 * (negative a 310 * (negative and sign-extended). The second 406 * condition i 311 * condition is true if when we set all bits 407 * within the 312 * within the mask to one (i.e. | in the 408 * mask), all 313 * mask), all bits are one. 409 */ 314 */ 410 if (($2 > mask !! 315 if (($2 > mask) && (($2 | mask) != -1ULL)) 411 char * !! 316 ERROR(&@2, "Value out of range for" 412 fprint !! 317 " %d-bit array element", $1.bits); 413 << 414 << 415 << 416 free(l << 417 } << 418 } 318 } 419 319 420 $$.data = data_append_ 320 $$.data = data_append_integer($1.data, $2, $1.bits); 421 } 321 } 422 | arrayprefix dt_ref !! 322 | arrayprefix DT_REF 423 { 323 { 424 uint64_t val = ~0ULL > 324 uint64_t val = ~0ULL >> (64 - $1.bits); 425 325 426 if ($1.bits == 32) 326 if ($1.bits == 32) 427 $1.data = data 327 $1.data = data_add_marker($1.data, 428 328 REF_PHANDLE, 429 329 $2); 430 else 330 else 431 ERROR(&@2, "Re 331 ERROR(&@2, "References are only allowed in " 432 "a 332 "arrays with 32-bit elements."); 433 333 434 $$.data = data_append_ 334 $$.data = data_append_integer($1.data, val, $1.bits); 435 } 335 } 436 | arrayprefix DT_LABEL 336 | arrayprefix DT_LABEL 437 { 337 { 438 $$.data = data_add_mar 338 $$.data = data_add_marker($1.data, LABEL, $2); 439 } 339 } 440 ; 340 ; 441 341 442 integer_prim: 342 integer_prim: 443 DT_LITERAL 343 DT_LITERAL 444 | DT_CHAR_LITERAL 344 | DT_CHAR_LITERAL 445 | '(' integer_expr ')' 345 | '(' integer_expr ')' 446 { 346 { 447 $$ = $2; 347 $$ = $2; 448 } 348 } 449 ; 349 ; 450 350 451 integer_expr: 351 integer_expr: 452 integer_trinary 352 integer_trinary 453 ; 353 ; 454 354 455 integer_trinary: 355 integer_trinary: 456 integer_or 356 integer_or 457 | integer_or '?' integer_expr ':' inte 357 | integer_or '?' integer_expr ':' integer_trinary { $$ = $1 ? $3 : $5; } 458 ; 358 ; 459 359 460 integer_or: 360 integer_or: 461 integer_and 361 integer_and 462 | integer_or DT_OR integer_and { $$ = 362 | integer_or DT_OR integer_and { $$ = $1 || $3; } 463 ; 363 ; 464 364 465 integer_and: 365 integer_and: 466 integer_bitor 366 integer_bitor 467 | integer_and DT_AND integer_bitor { $ 367 | integer_and DT_AND integer_bitor { $$ = $1 && $3; } 468 ; 368 ; 469 369 470 integer_bitor: 370 integer_bitor: 471 integer_bitxor 371 integer_bitxor 472 | integer_bitor '|' integer_bitxor { $ 372 | integer_bitor '|' integer_bitxor { $$ = $1 | $3; } 473 ; 373 ; 474 374 475 integer_bitxor: 375 integer_bitxor: 476 integer_bitand 376 integer_bitand 477 | integer_bitxor '^' integer_bitand { 377 | integer_bitxor '^' integer_bitand { $$ = $1 ^ $3; } 478 ; 378 ; 479 379 480 integer_bitand: 380 integer_bitand: 481 integer_eq 381 integer_eq 482 | integer_bitand '&' integer_eq { $$ = 382 | integer_bitand '&' integer_eq { $$ = $1 & $3; } 483 ; 383 ; 484 384 485 integer_eq: 385 integer_eq: 486 integer_rela 386 integer_rela 487 | integer_eq DT_EQ integer_rela { $$ = 387 | integer_eq DT_EQ integer_rela { $$ = $1 == $3; } 488 | integer_eq DT_NE integer_rela { $$ = 388 | integer_eq DT_NE integer_rela { $$ = $1 != $3; } 489 ; 389 ; 490 390 491 integer_rela: 391 integer_rela: 492 integer_shift 392 integer_shift 493 | integer_rela '<' integer_shift { $$ 393 | integer_rela '<' integer_shift { $$ = $1 < $3; } 494 | integer_rela '>' integer_shift { $$ 394 | integer_rela '>' integer_shift { $$ = $1 > $3; } 495 | integer_rela DT_LE integer_shift { $ 395 | integer_rela DT_LE integer_shift { $$ = $1 <= $3; } 496 | integer_rela DT_GE integer_shift { $ 396 | integer_rela DT_GE integer_shift { $$ = $1 >= $3; } 497 ; 397 ; 498 398 499 integer_shift: 399 integer_shift: 500 integer_shift DT_LSHIFT integer_add !! 400 integer_shift DT_LSHIFT integer_add { $$ = $1 << $3; } 501 | integer_shift DT_RSHIFT integer_add !! 401 | integer_shift DT_RSHIFT integer_add { $$ = $1 >> $3; } 502 | integer_add 402 | integer_add 503 ; 403 ; 504 404 505 integer_add: 405 integer_add: 506 integer_add '+' integer_mul { $$ = $ 406 integer_add '+' integer_mul { $$ = $1 + $3; } 507 | integer_add '-' integer_mul { $$ = $ 407 | integer_add '-' integer_mul { $$ = $1 - $3; } 508 | integer_mul 408 | integer_mul 509 ; 409 ; 510 410 511 integer_mul: 411 integer_mul: 512 integer_mul '*' integer_unary { $$ = 412 integer_mul '*' integer_unary { $$ = $1 * $3; } 513 | integer_mul '/' integer_unary 413 | integer_mul '/' integer_unary 514 { 414 { 515 if ($3 != 0) { 415 if ($3 != 0) { 516 $$ = $1 / $3; 416 $$ = $1 / $3; 517 } else { 417 } else { 518 ERROR(&@$, "Di 418 ERROR(&@$, "Division by zero"); 519 $$ = 0; 419 $$ = 0; 520 } 420 } 521 } 421 } 522 | integer_mul '%' integer_unary 422 | integer_mul '%' integer_unary 523 { 423 { 524 if ($3 != 0) { 424 if ($3 != 0) { 525 $$ = $1 % $3; 425 $$ = $1 % $3; 526 } else { 426 } else { 527 ERROR(&@$, "Di 427 ERROR(&@$, "Division by zero"); 528 $$ = 0; 428 $$ = 0; 529 } 429 } 530 } 430 } 531 | integer_unary 431 | integer_unary 532 ; 432 ; 533 433 534 integer_unary: 434 integer_unary: 535 integer_prim 435 integer_prim 536 | '-' integer_unary { $$ = -$2; } 436 | '-' integer_unary { $$ = -$2; } 537 | '~' integer_unary { $$ = ~$2; } 437 | '~' integer_unary { $$ = ~$2; } 538 | '!' integer_unary { $$ = !$2; } 438 | '!' integer_unary { $$ = !$2; } 539 ; 439 ; 540 440 541 bytestring: 441 bytestring: 542 /* empty */ 442 /* empty */ 543 { 443 { 544 $$ = data_add_marker(e !! 444 $$ = empty_data; 545 } 445 } 546 | bytestring DT_BYTE 446 | bytestring DT_BYTE 547 { 447 { 548 $$ = data_append_byte( 448 $$ = data_append_byte($1, $2); 549 } 449 } 550 | bytestring DT_LABEL 450 | bytestring DT_LABEL 551 { 451 { 552 $$ = data_add_marker($ 452 $$ = data_add_marker($1, LABEL, $2); 553 } 453 } 554 ; 454 ; 555 455 556 subnodes: 456 subnodes: 557 /* empty */ 457 /* empty */ 558 { 458 { 559 $$ = NULL; 459 $$ = NULL; 560 } 460 } 561 | subnode subnodes 461 | subnode subnodes 562 { 462 { 563 $$ = chain_node($1, $2 463 $$ = chain_node($1, $2); 564 } 464 } 565 | subnode propdef 465 | subnode propdef 566 { 466 { 567 ERROR(&@2, "Properties 467 ERROR(&@2, "Properties must precede subnodes"); 568 YYERROR; 468 YYERROR; 569 } 469 } 570 ; 470 ; 571 471 572 subnode: 472 subnode: 573 DT_PROPNODENAME nodedef 473 DT_PROPNODENAME nodedef 574 { 474 { 575 $$ = name_node($2, $1) 475 $$ = name_node($2, $1); 576 free($1); << 577 } 476 } 578 | DT_DEL_NODE DT_PROPNODENAME ';' 477 | DT_DEL_NODE DT_PROPNODENAME ';' 579 { 478 { 580 $$ = name_node(build_n !! 479 $$ = name_node(build_node_delete(), $2); 581 free($2); << 582 } << 583 | DT_OMIT_NO_REF subnode << 584 { << 585 $$ = omit_node_if_unus << 586 } 480 } 587 | DT_LABEL subnode 481 | DT_LABEL subnode 588 { 482 { 589 add_label(&$2->labels, 483 add_label(&$2->labels, $1); 590 $$ = $2; 484 $$ = $2; 591 } 485 } 592 ; 486 ; 593 487 594 %% 488 %% 595 489 596 void yyerror(char const *s) 490 void yyerror(char const *s) 597 { 491 { 598 ERROR(&yylloc, "%s", s); 492 ERROR(&yylloc, "%s", s); 599 } 493 }
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.