1 %{ 2 /* pl-parser.y: Grammar for reading property list files 3 4 This file is part of Omega, 5 which is based on the web2c distribution of TeX, 6 7 Copyright (c) 1994--2001 John Plaice and Yannis Haralambous 8 9 Omega is free software; you can redistribute it and/or modify 10 it under the terms of the GNU General Public License as published by 11 the Free Software Foundation; either version 2 of the License, or 12 (at your option) any later version. 13 14 Omega is distributed in the hope that it will be useful, 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 GNU General Public License for more details. 18 19 You should have received a copy of the GNU General Public License 20 along with Omega; if not, write to the Free Software Foundation, Inc., 21 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 22 23 */ 24 25 #include "cpascal.h" 26 #include "parser.h" 27 #include "pl-parser.h" 28 #include "manifests.h" 29 #include "list_routines.h" 30 #include "error_routines.h" 31 #include "out_routines.h" 32 #include "char_routines.h" 33 #include "header_routines.h" 34 #include "param_routines.h" 35 #include "dimen_routines.h" 36 #include "ligkern_routines.h" 37 #include "print_routines.h" 38 #include "font_routines.h" 39 #include "extra_routines.h" 40 41 %} 42 43 /* Basic tokens */ 44 45 %token LEFT 46 %token RIGHT 47 %token NUMBER 48 %token FIX 49 %token COMMENT 50 51 /* Tokens found in PL, OPL, VF and OVF files */ 52 53 %token CHECKSUM 54 %token DESIGNSIZE 55 %token DESIGNUNITS 56 %token CODINGSCHEME /* implicit string */ 57 %token FAMILY /* implicit string */ 58 %token FACE 59 %token SEVENBITSAFEFLAG /* implicit 0 (FALSE) or 1 (TRUE) */ 60 %token HEADER 61 %token FONTDIMEN 62 %token LIGTABLE 63 %token BOUNDARYCHAR 64 %token CHARACTER 65 66 %token NAMEDPARAMETER /* implicit integer */ 67 %token PARAMETER 68 69 %token CHARMEASURE /* implicit integer */ 70 %token NEXTLARGER 71 %token VARCHAR 72 %token EXTEN /* implicit integer */ 73 74 %token LABEL 75 %token LIG /* implicit integer */ 76 %token KRN 77 %token STOP 78 %token SKIP 79 80 /* Tokens found only in VF and OVF files */ 81 82 %token VTITLE 83 84 %token MAPFONT 85 %token FONTNAME 86 %token FONTAREA 87 %token FONTCHECKSUM 88 %token FONTAT 89 %token FONTDSIZE 90 91 %token MAP 92 %token SELECTFONT 93 %token SETCHAR 94 %token SETRULE 95 %token MOVE 96 %token PUSH 97 %token POP 98 %token SPECIAL 99 %token SPECIALHEX 100 101 /* Tokens found only in OPL and OVF files */ 102 103 %token CHARREPEAT 104 %token FONTIVALUE 105 %token FONTFVALUE 106 %token FONTMVALUE 107 %token FONTPENALTY 108 %token FONTRULE 109 %token FONTGLUE 110 111 %token CLABEL 112 %token CKRN 113 %token CGLUE 114 %token CPENALTY 115 %token CPENGLUE 116 117 %token CHARIVALUE 118 %token CHARFVALUE 119 %token CHARMVALUE 120 %token CHARPENALTY 121 %token CHARRULE 122 %token CHARGLUE 123 124 %token IVALUE 125 %token IVALUEVAL 126 127 %token MVALUE 128 %token MVALUEVAL 129 130 %token FVALUE 131 %token FVALUEVAL 132 133 %token PENALTY 134 %token PENALTYVAL 135 136 %token RULE 137 %token RULEMEASURE 138 139 %token GLUE 140 %token GLUEWD 141 %token GLUETYPE 142 %token GLUEKIND /* Implicit integer */ 143 %token GLUERULE 144 %token GLUECHAR 145 %token GLUESHRINKSTRETCH 146 %token GLUEORDER /* Implicit integer */ 147 148 149 %token OFMLEVEL 150 %token FONTDIR 151 %token ACCENT 152 153 %% 154 155 File: 156 Entries 157 ; 158 159 Entries : 160 /* */ 161 | Entries 162 LEFT OneEntry RIGHT 163 ; 164 165 OneEntry : 166 167 /* The following entries are found in PL, OPL, VP and OVP files */ 168 169 CHECKSUM NUMBER 170 { set_check_sum($2.yint); } 171 | DESIGNSIZE FIX 172 { set_design_size($2.yfix); } 173 | DESIGNUNITS FIX 174 { set_design_units($2.yfix); } 175 | CODINGSCHEME 176 { set_coding_scheme($1.ystring); } 177 | FAMILY 178 { set_family($1.ystring); } 179 | FACE NUMBER 180 { set_face($2.yint); } 181 | SEVENBITSAFEFLAG 182 { set_seven_bit_safe_flag($1.yint); } 183 | HEADER NUMBER NUMBER 184 { set_header_word($2.yint, $3.yint); } 185 | FONTDIMEN 186 { init_parameters(); } 187 FontParameters 188 | LIGTABLE 189 { init_ligkern(); } 190 LigKernEntries 191 | BOUNDARYCHAR NUMBER 192 { set_boundary_character($2.yint); } 193 | CHARACTER NUMBER 194 { init_character($2.yint, NULL); } 195 CharacterEntries 196 | COMMENT 197 198 /* The following entries are found only in VP and OVP files */ 199 200 | VTITLE 201 { set_vtitle($1.ystring); } 202 | MAPFONT NUMBER 203 { init_map_font($2.yint); } 204 MapFontEntries 205 206 /* The following entries are found only in OPL and OVP files */ 207 208 | OFMLEVEL NUMBER 209 { set_ofm_level($2.yint); } 210 | FONTDIR 211 { set_font_dir($1.yint); } 212 | CHARREPEAT NUMBER NUMBER 213 { init_character($2.yint,NULL); } 214 CharacterEntries 215 { copy_characters($2.yint,$3.yint); } 216 | FONTIVALUE NUMBER 217 {init_font_ivalue($2.yint);} 218 FontIvalueEntries 219 | FONTMVALUE NUMBER 220 { init_font_mvalue($2.yint);} 221 FontMvalueEntries 222 | FONTFVALUE NUMBER 223 { init_font_fvalue($2.yint);} 224 FontFvalueEntries 225 | FONTPENALTY NUMBER 226 { init_font_penalty($2.yint);} 227 FontPenaltyEntries 228 | FONTRULE NUMBER 229 { init_font_rule($2.yint);} 230 FontRuleEntries 231 | FONTGLUE NUMBER 232 { init_font_glue($2.yint);} 233 FontGlueEntries 234 ; 235 236 FontParameters : 237 /* */ 238 | FontParameters 239 LEFT OneFontParameter RIGHT 240 ; 241 242 OneFontParameter : 243 NAMEDPARAMETER FIX 244 { set_param_word($1.yint, $2.yfix); } 245 | PARAMETER NUMBER FIX 246 { set_param_word($2.yint, $3.yfix); } 247 | COMMENT 248 ; 249 250 LigKernEntries : 251 /* */ 252 | LigKernEntries 253 LEFT OneLigKernEntry RIGHT 254 ; 255 256 OneLigKernEntry : 257 LABEL NUMBER 258 { set_label_command($2.yint); } 259 | LABEL BOUNDARYCHAR 260 { set_label_command(CHAR_BOUNDARY); } 261 | LIG NUMBER NUMBER 262 { set_ligature_command($1.yint, $2.yint, $3.yint); } 263 | KRN NUMBER FIX 264 { set_kerning_command($2.yint, $3.yfix); } 265 | STOP 266 { set_stop_command(); } 267 | SKIP NUMBER 268 { set_skip_command($2.yint); } 269 | COMMENT 270 271 /* The following entries are found only in OPL and OVP files */ 272 273 | CLABEL NUMBER 274 { set_c_label_command($2.yint); } 275 | CKRN NUMBER FIX 276 { set_c_kerning_command($2.yint, $3.yfix); } 277 | CGLUE NUMBER NUMBER 278 { set_c_glue_command($2.yint, $3.yint); } 279 | CPENALTY NUMBER NUMBER 280 { set_c_penalty_command($2.yint, $3.yint); } 281 | CPENGLUE NUMBER NUMBER NUMBER 282 { set_c_penglue_command($2.yint, $3.yint, $4.yint); } 283 ; 284 285 CharacterEntries : 286 /* */ 287 | CharacterEntries 288 LEFT OneCharacterEntry RIGHT 289 ; 290 291 OneCharacterEntry : 292 CHARMEASURE FIX 293 { set_character_measure($1.yint, $2.yfix); } 294 | NEXTLARGER NUMBER 295 { set_next_larger($2.yint); } 296 | VARCHAR 297 { init_var_character(); } 298 VarCharParameters 299 | COMMENT 300 301 /* The following character entries are found only in VP and OVP files */ 302 303 | MAP 304 { init_map(); } 305 MapEntries 306 { end_map(); } 307 308 /* The following entries are found only in OPL and OVP files */ 309 310 | ACCENT 311 { set_accent($1.yint); } 312 | CHARIVALUE NUMBER NUMBER 313 { set_character_ivalue($2.yint, $3.yint); } 314 | CHARMVALUE NUMBER NUMBER 315 { set_character_mvalue($2.yint, $3.yint); } 316 | CHARFVALUE NUMBER NUMBER 317 { set_character_fvalue($2.yint, $3.yint); } 318 | CHARPENALTY NUMBER NUMBER 319 { set_character_penalty($2.yint, $3.yint); } 320 | CHARRULE NUMBER NUMBER 321 { set_character_rule($2.yint, $3.yint); } 322 | CHARGLUE NUMBER NUMBER 323 { set_character_glue($2.yint, $3.yint); } 324 325 ; 326 327 VarCharParameters : 328 /* */ 329 | VarCharParameters 330 LEFT OneVarCharParameter RIGHT 331 ; 332 333 OneVarCharParameter : 334 EXTEN NUMBER 335 { set_extensible_piece($1.yint, $2.yint); } 336 | COMMENT 337 ; 338 339 340 /* The following four nonterminals are found only in VP and OVP files */ 341 342 MapFontEntries : 343 /* */ 344 | MapFontEntries 345 LEFT OneMapFontEntry RIGHT 346 ; 347 348 OneMapFontEntry : 349 FONTNAME 350 { set_font_name($1.ystring); } 351 | FONTAREA 352 { set_font_area($1.ystring); } 353 | FONTCHECKSUM NUMBER 354 { set_font_check_sum($2.yint); } 355 | FONTAT FIX 356 { set_font_at($2.yfix); } 357 | FONTDSIZE FIX 358 { set_font_design_size($2.yfix); } 359 | COMMENT 360 ; 361 362 MapEntries : 363 /* */ 364 | MapEntries 365 LEFT OneMapEntry RIGHT 366 ; 367 368 OneMapEntry : 369 SELECTFONT NUMBER 370 { set_select_font($2.yint); } 371 | SETCHAR NUMBER 372 { set_set_char($2.yint); } 373 | SETRULE FIX FIX 374 { set_set_rule($2.yfix, $3.yfix); } 375 | MOVE FIX 376 { set_move($1.yint, $2.yfix); } 377 | PUSH 378 { set_push(); } 379 | POP 380 { set_pop(); } 381 | SPECIAL 382 { set_special($1.ystring); } 383 | SPECIALHEX 384 { set_special_hex($1.ystring); } 385 ; 386 387 /* The remaining nonterminals are found only in OPL and OVP files */ 388 389 FontIvalueEntries : 390 /* */ 391 | FontIvalueEntries 392 LEFT OneFontIvalueEntry RIGHT 393 ; 394 395 OneFontIvalueEntry : 396 IVALUE NUMBER 397 { init_font_ivalue_entry($2.yint); } 398 IvalueDefinition 399 | COMMENT 400 ; 401 402 IvalueDefinition : 403 /* */ 404 | IvalueDefinition 405 LEFT OneIvalueDefinition RIGHT 406 ; 407 408 OneIvalueDefinition : 409 IVALUEVAL NUMBER 410 { set_font_ivalue_definition($2.yint); } 411 | COMMENT 412 ; 413 414 FontMvalueEntries : 415 /* */ 416 | FontMvalueEntries 417 LEFT OneFontMvalueEntry RIGHT 418 ; 419 420 OneFontMvalueEntry : 421 MVALUE NUMBER 422 { init_font_mvalue_entry($2.yint); } 423 MvalueDefinition 424 | COMMENT 425 ; 426 427 MvalueDefinition : 428 /* */ 429 | MvalueDefinition 430 LEFT OneMvalueDefinition RIGHT 431 ; 432 433 OneMvalueDefinition : 434 MVALUEVAL FIX 435 { set_font_mvalue_definition($2.yfix); } 436 | COMMENT 437 ; 438 439 FontFvalueEntries : 440 /* */ 441 | FontFvalueEntries 442 LEFT OneFontFvalueEntry RIGHT 443 ; 444 445 OneFontFvalueEntry : 446 FVALUE NUMBER 447 { init_font_fvalue_entry($2.yint); } 448 FvalueDefinition 449 | COMMENT 450 ; 451 452 FvalueDefinition : 453 /* */ 454 | FvalueDefinition 455 LEFT OneFvalueDefinition RIGHT 456 ; 457 458 OneFvalueDefinition : 459 FVALUEVAL FIX 460 { set_font_fvalue_definition($2.yfix); } 461 | COMMENT 462 ; 463 464 FontPenaltyEntries : 465 /* */ 466 | FontPenaltyEntries 467 LEFT OneFontPenaltyEntry RIGHT 468 ; 469 470 OneFontPenaltyEntry : 471 PENALTY NUMBER 472 { init_font_penalty_entry($2.yint); } 473 PenaltyDefinition 474 | COMMENT 475 ; 476 477 PenaltyDefinition : 478 /* */ 479 | PenaltyDefinition 480 LEFT OnePenaltyDefinition RIGHT 481 ; 482 483 OnePenaltyDefinition : 484 PENALTYVAL NUMBER 485 { set_font_penalty_definition($2.yint); } 486 | COMMENT 487 ; 488 489 FontRuleEntries : 490 /* */ 491 | FontRuleEntries 492 LEFT OneFontRuleEntry RIGHT 493 ; 494 495 OneFontRuleEntry : 496 RULE NUMBER 497 { init_font_rule_entry($2.yint); } 498 RuleDefinition 499 | COMMENT 500 ; 501 502 RuleDefinition : 503 /* */ 504 | RuleDefinition 505 LEFT OneRuleDefinition RIGHT 506 ; 507 508 OneRuleDefinition : 509 RULEMEASURE FIX 510 { set_font_rule_measure($1.yint, $2.yfix); } 511 | COMMENT 512 ; 513 514 FontGlueEntries : 515 /* */ 516 | FontGlueEntries 517 LEFT OneFontGlueEntry RIGHT 518 ; 519 520 OneFontGlueEntry : 521 GLUE NUMBER 522 { init_font_glue_entry($2.yint); } 523 GlueDefinition 524 | COMMENT 525 ; 526 527 GlueDefinition : 528 /* */ 529 | GlueDefinition 530 LEFT OneGlueDefinition RIGHT 531 ; 532 533 OneGlueDefinition : 534 GLUETYPE GLUEKIND 535 { set_font_glue_type($2.yint); } 536 | GLUEWD FIX 537 { set_font_glue_width($2.yfix); } 538 | GLUECHAR NUMBER 539 { set_font_glue_character($2.yint); } 540 | GLUERULE NUMBER NUMBER 541 { set_font_glue_rule($2.yint, $3.yint); } 542 | GLUESHRINKSTRETCH FIX GLUEORDER 543 { set_font_glue_shrink_stretch($1.yint, $2.yfix, $3.yint); } 544 | COMMENT 545 ; 546