| 1 |
%{ |
| 2 |
/* |
| 3 |
* Gregorio is a program that translates gabc files to GregorioTeX |
| 4 |
* This file implements the score parser. |
| 5 |
* |
| 6 |
* Gregorio score determination from gabc. |
| 7 |
* Copyright (C) 2006-2025 The Gregorio Project (see CONTRIBUTORS.md) |
| 8 |
* |
| 9 |
* This file is part of Gregorio. |
| 10 |
* |
| 11 |
* This program is free software: you can redistribute it and/or modify it |
| 12 |
* under the terms of the GNU General Public License as published by the Free |
| 13 |
* Software Foundation, either version 3 of the License, or (at your option) |
| 14 |
* any later version. |
| 15 |
* |
| 16 |
* This program is distributed in the hope that it will be useful, but WITHOUT |
| 17 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 18 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 19 |
* more details. |
| 20 |
* |
| 21 |
* You should have received a copy of the GNU General Public License along with |
| 22 |
* this program. If not, see <http://www.gnu.org/licenses/>. |
| 23 |
*/ |
| 24 |
|
| 25 |
/* |
| 26 |
* |
| 27 |
* This file is certainly not the most easy to understand, it is a bison file. |
| 28 |
* See the bison manual on gnu.org for further details. |
| 29 |
* |
| 30 |
*/ |
| 31 |
|
| 32 |
#include "config.h" |
| 33 |
#include <stdio.h> |
| 34 |
#include <stdlib.h> |
| 35 |
#include <assert.h> |
| 36 |
#include "bool.h" |
| 37 |
#include "struct.h" |
| 38 |
#include "unicode.h" |
| 39 |
#include "messages.h" |
| 40 |
#include "characters.h" |
| 41 |
#include "support.h" |
| 42 |
#include "sha1.h" |
| 43 |
#include "plugins.h" |
| 44 |
#include "gabc.h" |
| 45 |
|
| 46 |
#define YYLLOC_DEFAULT(Current, Rhs, N) \ |
| 47 |
if (N) { \ |
| 48 |
(Current).first_line = YYRHSLOC(Rhs, 1).first_line; \ |
| 49 |
(Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ |
| 50 |
(Current).first_offset = YYRHSLOC (Rhs, 1).first_offset; \ |
| 51 |
(Current).last_line = YYRHSLOC (Rhs, N).last_line; \ |
| 52 |
(Current).last_column = YYRHSLOC (Rhs, N).last_column; \ |
| 53 |
(Current).last_offset = YYRHSLOC (Rhs, N).last_offset; \ |
| 54 |
(Current).generate_point_and_click = YYRHSLOC (Rhs, 1).generate_point_and_click; \ |
| 55 |
} else { \ |
| 56 |
(Current).first_line = (Current).last_line = YYRHSLOC (Rhs, 0).last_line; \ |
| 57 |
(Current).first_column = (Current).last_column = YYRHSLOC (Rhs, 0).last_column; \ |
| 58 |
(Current).first_offset = (Current).last_offset = YYRHSLOC (Rhs, 0).last_offset; \ |
| 59 |
(Current).first_offset = (Current).last_offset = YYRHSLOC (Rhs, 0).last_offset; \ |
| 60 |
(Current).generate_point_and_click = YYRHSLOC (Rhs, 0).generate_point_and_click; \ |
| 61 |
} |
| 62 |
|
| 63 |
#include "gabc-score-determination.h" |
| 64 |
#include "gabc-score-determination-l.h" |
| 65 |
|
| 66 |
/* SB_IGNORE used to ignore a style that don't stay open between syllables */ |
| 67 |
#define GABC_STYLE_BITS(A,E,X,L) \ |
| 68 |
A(SB_IGNORE, 0x00) \ |
| 69 |
A(SB_ITALIC, 0x01) \ |
| 70 |
A(SB_BOLD, 0x02) \ |
| 71 |
A(SB_TT, 0x04) \ |
| 72 |
A(SB_SMALL_CAPS, 0x08) \ |
| 73 |
A(SB_UNDERLINED, 0x10) \ |
| 74 |
A(SB_COLORED, 0x20) \ |
| 75 |
X(SB_ELISION, 0x40) |
| 76 |
ENUM(gabc_style_bits, GABC_STYLE_BITS); |
| 77 |
|
| 78 |
ENUM_TO_STRING(gabc_style_bits, GABC_STYLE_BITS) |
| 79 |
|
| 80 |
/* forward declaration of the flex/bison process function */ |
| 81 |
static int gabc_score_determination_parse(void); |
| 82 |
|
| 83 |
/* uncomment it if you want to have an interactive shell to understand the |
| 84 |
* details on how bison works for a certain input */ |
| 85 |
/* int gabc_score_determination_debug=1; */ |
| 86 |
|
| 87 |
/* |
| 88 |
* |
| 89 |
* We will need some variables and functions through the entire file, we |
| 90 |
* declare them there: |
| 91 |
* |
| 92 |
*/ |
| 93 |
|
| 94 |
/* the score that we will determine and return */ |
| 95 |
static gregorio_score *score; |
| 96 |
/* an array of elements that we will use for each syllable */ |
| 97 |
static gregorio_element **elements; |
| 98 |
gregorio_element *current_element; |
| 99 |
/* a table containing the macros to use in gabc file */ |
| 100 |
static char *macros[10]; |
| 101 |
/* other variables that we will have to use */ |
| 102 |
static gregorio_character *current_character; |
| 103 |
static gregorio_character *suspended_character; |
| 104 |
static gregorio_character *first_text_character; |
| 105 |
static gregorio_character *first_translation_character; |
| 106 |
static gregorio_tr_centering translation_type; |
| 107 |
static gregorio_nlba no_linebreak_area; |
| 108 |
static gregorio_euouae euouae; |
| 109 |
static gregorio_voice_info *current_voice_info; |
| 110 |
static int number_of_voices; |
| 111 |
static int voice; |
| 112 |
/* see comments on text to understand this */ |
| 113 |
static gregorio_center_determination center_is_determined; |
| 114 |
/* current_key is... the current key... updated by each notes determination |
| 115 |
* (for key changes) */ |
| 116 |
static int current_key; |
| 117 |
static bool got_language; |
| 118 |
static bool got_staff_lines; |
| 119 |
static bool started_first_word; |
| 120 |
static struct sha1_ctx digester; |
| 121 |
/* used to track styles that stay open across syllables */ |
| 122 |
static gabc_style_bits styles; |
| 123 |
static bool generate_point_and_click; |
| 124 |
static bool clear_syllable_text; |
| 125 |
static bool has_protrusion; |
| 126 |
|
| 127 |
/* punctum_inclinatum_orientation maintains the running punctum inclinatum |
| 128 |
* orientation in order to decide if the glyph needs to be cut when a punctum |
| 129 |
* inclinatum with forced orientation is encountered. This should be set to |
| 130 |
* the shape of a non-liquescent punctum inclinatum with forced orientation |
| 131 |
* when one is encountered, be left alone when a non-liquescent punctum |
| 132 |
* inclinatum with undetermined orientation is encountered, or be reset to |
| 133 |
* S_PUNCTUM_INCLINATUM_UNDETERMINED otherwise (because such ends any previous |
| 134 |
* run of punctum inclinatum notes). Based on the assumption that a punctum |
| 135 |
* inclinatum with forced orientation changes all the punctum inclinatum shapes |
| 136 |
* with undetermined orientation in the same run of notes before and after it |
| 137 |
* unless influenced by an earlier punctum inclinatum with forced orientation, |
| 138 |
* the value of punctum_inclinatum_orientation can be used to determine if a |
| 139 |
* punctum inclinatum with a forced orientation will have a different |
| 140 |
* orientation than the punctum inclinatum immediately before it, which would |
| 141 |
* require a cut of the glyph. */ |
| 142 |
static gregorio_shape punctum_inclinatum_orientation; |
| 143 |
|
| 144 |
static __inline void check_multiple(const char *name, bool exists) { |
| 145 |
if (exists) { |
| 146 |
gregorio_messagef("det_score", VERBOSITY_WARNING, 0, |
| 147 |
_("several %s definitions found, only the last will be taken " |
| 148 |
"into consideration"), name); |
| 149 |
} |
| 150 |
} |
| 151 |
|
| 152 |
static void gabc_score_determination_error(const char *error_str) |
| 153 |
{ |
| 154 |
gregorio_message(error_str, (const char *) "gabc_score_determination_parse", |
| 155 |
VERBOSITY_ERROR, 0); |
| 156 |
} |
| 157 |
|
| 158 |
/* |
| 159 |
* The function that will initialize the variables. |
| 160 |
*/ |
| 161 |
|
| 162 |
static void initialize_variables(bool point_and_click) |
| 163 |
{ |
| 164 |
int i; |
| 165 |
/* build a brand new empty score */ |
| 166 |
score = gregorio_new_score(); |
| 167 |
/* initialization of the first voice info to an empty voice info */ |
| 168 |
current_voice_info = NULL; |
| 169 |
gregorio_add_voice_info(¤t_voice_info); |
| 170 |
score->first_voice_info = current_voice_info; |
| 171 |
/* other initializations */ |
| 172 |
number_of_voices = 1; |
| 173 |
voice = 0; /* first (and only) voice */ |
| 174 |
current_character = NULL; |
| 175 |
suspended_character = NULL; |
| 176 |
first_translation_character = NULL; |
| 177 |
first_text_character = NULL; |
| 178 |
translation_type = TR_NORMAL; |
| 179 |
no_linebreak_area = NLBA_NORMAL; |
| 180 |
euouae = EUOUAE_NORMAL; |
| 181 |
center_is_determined = CENTER_NOT_DETERMINED; |
| 182 |
current_key = gregorio_calculate_new_key(gregorio_default_clef); |
| 183 |
for (i = 0; i < 10; i++) { |
| 184 |
macros[i] = NULL; |
| 185 |
} |
| 186 |
got_language = false; |
| 187 |
got_staff_lines = false; |
| 188 |
started_first_word = false; |
| 189 |
styles = 0; |
| 190 |
punctum_inclinatum_orientation = S_PUNCTUM_INCLINATUM_UNDETERMINED; |
| 191 |
generate_point_and_click = point_and_click; |
| 192 |
clear_syllable_text = false; |
| 193 |
has_protrusion = false; |
| 194 |
} |
| 195 |
|
| 196 |
/* |
| 197 |
* function that frees the variables that need it, for when we have finished to |
| 198 |
* determine the score |
| 199 |
*/ |
| 200 |
|
| 201 |
static void free_variables(void) |
| 202 |
{ |
| 203 |
int i; |
| 204 |
free(elements); |
| 205 |
for (i = 0; i < 10; i++) { |
| 206 |
free(macros[i]); |
| 207 |
} |
| 208 |
} |
| 209 |
|
| 210 |
/* |
| 211 |
* Function called when we have reached the end of the definitions, it tries to |
| 212 |
* make the voice_infos coherent. |
| 213 |
*/ |
| 214 |
static void end_definitions(void) |
| 215 |
{ |
| 216 |
int i; |
| 217 |
|
| 218 |
gregorio_assert_only(gabc_check_infos_integrity(score), end_definitions, |
| 219 |
"can't determine valid infos on the score"); |
| 220 |
|
| 221 |
elements = (gregorio_element **) gregorio_malloc(number_of_voices * |
| 222 |
sizeof(gregorio_element *)); |
| 223 |
for (i = 0; i < number_of_voices; i++) { |
| 224 |
elements[i] = NULL; |
| 225 |
} |
| 226 |
|
| 227 |
if (!got_language) { |
| 228 |
static char latin[] = "Latin"; |
| 229 |
gregorio_set_centering_language(latin); |
| 230 |
} |
| 231 |
} |
| 232 |
|
| 233 |
/* |
| 234 |
* Here starts the code for the determinations of the notes. The notes are not |
| 235 |
* precisely determined here, we separate the text describing the notes of each |
| 236 |
* voice, and we call determine_elements_from_string to really determine them. |
| 237 |
*/ |
| 238 |
static char position = WORD_BEGINNING; |
| 239 |
static gregorio_syllable *current_syllable = NULL; |
| 240 |
static char *abovelinestext = NULL; |
| 241 |
|
| 242 |
/* |
| 243 |
* Function called each time we find a space, it updates the current position. |
| 244 |
*/ |
| 245 |
static void update_position_with_space(void) |
| 246 |
{ |
| 247 |
if (position == WORD_MIDDLE) { |
| 248 |
position = WORD_END; |
| 249 |
} |
| 250 |
if (position == WORD_BEGINNING) { |
| 251 |
position = WORD_ONE_SYLLABLE; |
| 252 |
} |
| 253 |
} |
| 254 |
|
| 255 |
/* |
| 256 |
* When we encounter a translation center ending, we call this function that |
| 257 |
* sets translation_type = TR_WITH_CENTER_BEGINNING on previous syllable with |
| 258 |
* translation |
| 259 |
*/ |
| 260 |
static void gregorio_set_translation_center_beginning( |
| 261 |
gregorio_syllable *current_syllable) |
| 262 |
{ |
| 263 |
gregorio_syllable *syllable = current_syllable->previous_syllable; |
| 264 |
while (syllable) { |
| 265 |
if (syllable->translation_type == TR_WITH_CENTER_END) { |
| 266 |
gregorio_message("encountering translation centering end but " |
| 267 |
"cannot find translation centering beginning...", |
| 268 |
"set_translation_center_beginning", VERBOSITY_ERROR, 0); |
| 269 |
current_syllable->translation_type = TR_NORMAL; |
| 270 |
return; |
| 271 |
} |
| 272 |
if (syllable->translation) { |
| 273 |
syllable->translation_type = TR_WITH_CENTER_BEGINNING; |
| 274 |
return; |
| 275 |
} |
| 276 |
syllable = syllable->previous_syllable; |
| 277 |
} |
| 278 |
/* we didn't find any beginning... */ |
| 279 |
gregorio_message("encountering translation centering end but cannot find " |
| 280 |
"translation centering beginning...", |
| 281 |
"set_translation_center_beginning", VERBOSITY_ERROR, 0); |
| 282 |
current_syllable->translation_type = TR_NORMAL; |
| 283 |
} |
| 284 |
|
| 285 |
static void ready_characters(void) |
| 286 |
{ |
| 287 |
if (current_character) { |
| 288 |
gregorio_go_to_first_character_c(¤t_character); |
| 289 |
if (!score->first_syllable || (current_syllable |
| 290 |
&& !current_syllable->previous_syllable |
| 291 |
&& !current_syllable->text)) { |
| 292 |
started_first_word = true; |
| 293 |
} |
| 294 |
} |
| 295 |
} |
| 296 |
|
| 297 |
static void rebuild_score_characters(void) |
| 298 |
{ |
| 299 |
if (score->first_syllable) { |
| 300 |
gregorio_syllable *syllable; |
| 301 |
for (syllable = score->first_syllable; syllable; |
| 302 |
syllable = syllable->next_syllable) { |
| 303 |
const gregorio_character *t; |
| 304 |
|
| 305 |
/* find out if there is a forced center */ |
| 306 |
gregorio_center_determination center = CENTER_NOT_DETERMINED; |
| 307 |
for (t = syllable->text; t; t = t->next_character) { |
| 308 |
if (!t->is_character && t->cos.s.style == ST_FORCED_CENTER) { |
| 309 |
syllable->forced_center = true; |
| 310 |
center = CENTER_FULLY_DETERMINED; |
| 311 |
break; |
| 312 |
} |
| 313 |
} |
| 314 |
|
| 315 |
if (syllable == score->first_syllable) { |
| 316 |
/* leave the first syllable text untouched at this time */ |
| 317 |
continue; |
| 318 |
} |
| 319 |
|
| 320 |
gregorio_rebuild_characters(&(syllable->text), center, false); |
| 321 |
|
| 322 |
if (syllable->first_word) { |
| 323 |
gregorio_set_first_word(&(syllable->text)); |
| 324 |
} |
| 325 |
} |
| 326 |
} |
| 327 |
} |
| 328 |
|
| 329 |
/* |
| 330 |
* |
| 331 |
* The two functions called when lex returns a style, we simply add it. All the |
| 332 |
* complex things will be done by the function after... |
| 333 |
* |
| 334 |
*/ |
| 335 |
|
| 336 |
static void add_style(grestyle_style style, gabc_style_bits bit); |
| 337 |
|
| 338 |
static void maybe_insert_open_styles(void) |
| 339 |
{ |
| 340 |
if (!current_character) { |
| 341 |
/* insert open styles, leaving out ELISION on purpose */ |
| 342 |
if (styles & SB_ITALIC) { |
| 343 |
gregorio_begin_style(¤t_character, ST_ITALIC); |
| 344 |
} |
| 345 |
if (styles & SB_BOLD) { |
| 346 |
gregorio_begin_style(¤t_character, ST_BOLD); |
| 347 |
} |
| 348 |
if (styles & SB_TT) { |
| 349 |
gregorio_begin_style(¤t_character, ST_TT); |
| 350 |
} |
| 351 |
if (styles & SB_SMALL_CAPS) { |
| 352 |
gregorio_begin_style(¤t_character, ST_SMALL_CAPS); |
| 353 |
} |
| 354 |
if (styles & SB_UNDERLINED) { |
| 355 |
gregorio_begin_style(¤t_character, ST_UNDERLINED); |
| 356 |
} |
| 357 |
if (styles & SB_COLORED) { |
| 358 |
gregorio_begin_style(¤t_character, ST_COLORED); |
| 359 |
} |
| 360 |
} |
| 361 |
} |
| 362 |
|
| 363 |
static void add_style(grestyle_style style, gabc_style_bits bit) |
| 364 |
{ |
| 365 |
maybe_insert_open_styles(); |
| 366 |
if (bit) { |
| 367 |
if (styles & bit) { |
| 368 |
gregorio_messagef("add_style", VERBOSITY_ERROR, 0, |
| 369 |
_("style already started: %s"), |
| 370 |
gabc_style_bits_to_string(bit)); |
| 371 |
} else { |
| 372 |
styles ^= bit; |
| 373 |
} |
| 374 |
} |
| 375 |
gregorio_begin_style(¤t_character, style); |
| 376 |
} |
| 377 |
|
| 378 |
static void end_style(grestyle_style style, gabc_style_bits bit) |
| 379 |
{ |
| 380 |
maybe_insert_open_styles(); |
| 381 |
if (bit) { |
| 382 |
if (styles & bit) { |
| 383 |
styles ^= bit; |
| 384 |
} else { |
| 385 |
gregorio_messagef("end_style", VERBOSITY_ERROR, 0, |
| 386 |
_("style not started: %s"), |
| 387 |
gabc_style_bits_to_string(bit)); |
| 388 |
} |
| 389 |
} |
| 390 |
gregorio_end_style(¤t_character, style); |
| 391 |
} |
| 392 |
|
| 393 |
static __inline void save_text(void) |
| 394 |
{ |
| 395 |
if (has_protrusion) { |
| 396 |
end_style(ST_PROTRUSION, SB_IGNORE); |
| 397 |
} |
| 398 |
ready_characters(); |
| 399 |
first_text_character = current_character; |
| 400 |
} |
| 401 |
|
| 402 |
/* a function called when we see a [, basically, all characters are added to |
| 403 |
* the translation pointer instead of the text pointer */ |
| 404 |
static void start_translation(unsigned char asked_translation_type) |
| 405 |
{ |
| 406 |
suspended_character = current_character; |
| 407 |
/* the middle letters of the translation have no sense */ |
| 408 |
/*center_is_determined = CENTER_FULLY_DETERMINED;*/ |
| 409 |
current_character = NULL; |
| 410 |
translation_type = asked_translation_type; |
| 411 |
} |
| 412 |
|
| 413 |
static void end_translation(void) |
| 414 |
{ |
| 415 |
ready_characters(); |
| 416 |
first_translation_character = current_character; |
| 417 |
current_character = suspended_character; |
| 418 |
} |
| 419 |
|
| 420 |
/* |
| 421 |
* add_text is the function called when lex returns a char *. In |
| 422 |
* this function we convert it into grewchar, and then we add the corresponding |
| 423 |
* gregorio_characters in the list of gregorio_characters. |
| 424 |
*/ |
| 425 |
|
| 426 |
static void add_text(char *mbcharacters) |
| 427 |
{ |
| 428 |
maybe_insert_open_styles(); |
| 429 |
if (current_character) { |
| 430 |
current_character->next_character = gregorio_build_char_list_from_buf( |
| 431 |
mbcharacters); |
| 432 |
current_character->next_character->previous_character = |
| 433 |
current_character; |
| 434 |
} else { |
| 435 |
current_character = gregorio_build_char_list_from_buf(mbcharacters); |
| 436 |
} |
| 437 |
while (current_character && current_character->next_character) { |
| 438 |
current_character = current_character->next_character; |
| 439 |
} |
| 440 |
free(mbcharacters); |
| 441 |
} |
| 442 |
|
| 443 |
static void add_protrusion(char *factor) |
| 444 |
{ |
| 445 |
if (has_protrusion) { |
| 446 |
gregorio_message("syllable already has protrusion; pr tag ignored", |
| 447 |
"det_score", VERBOSITY_WARNING, 0); |
| 448 |
free(factor); |
| 449 |
} else { |
| 450 |
if (center_is_determined == CENTER_HALF_DETERMINED) { |
| 451 |
gregorio_message("closing open syllable center before protrusion", |
| 452 |
"det_score", VERBOSITY_WARNING, 0); |
| 453 |
end_style(ST_FORCED_CENTER, SB_IGNORE); |
| 454 |
center_is_determined = CENTER_FULLY_DETERMINED; |
| 455 |
} |
| 456 |
|
| 457 |
add_style(ST_PROTRUSION_FACTOR, SB_IGNORE); |
| 458 |
add_text(factor); |
| 459 |
end_style(ST_PROTRUSION_FACTOR, SB_IGNORE); |
| 460 |
add_style(ST_PROTRUSION, SB_IGNORE); |
| 461 |
has_protrusion = true; |
| 462 |
} |
| 463 |
} |
| 464 |
|
| 465 |
static void add_auto_protrusion(char *protrusion) |
| 466 |
{ |
| 467 |
if (has_protrusion) { |
| 468 |
add_text(protrusion); |
| 469 |
} else { |
| 470 |
add_style(ST_PROTRUSION_FACTOR, SB_IGNORE); |
| 471 |
add_style(ST_VERBATIM, SB_IGNORE); |
| 472 |
add_text(gregorio_strdup("\\GreProtrusionFactor{")); |
| 473 |
|
| 474 |
switch (*protrusion) { |
| 475 |
case ',': |
| 476 |
add_text(gregorio_strdup("comma")); |
| 477 |
break; |
| 478 |
case ';': |
| 479 |
add_text(gregorio_strdup("semicolon")); |
| 480 |
break; |
| 481 |
case ':': |
| 482 |
add_text(gregorio_strdup("colon")); |
| 483 |
break; |
| 484 |
case '.': |
| 485 |
add_text(gregorio_strdup("period")); |
| 486 |
break; |
| 487 |
default: |
| 488 |
/* not reachable unless there's a programming error */ |
| 489 |
/* LCOV_EXCL_START */ |
| 490 |
gregorio_fail2(add_auto_protrusion, |
| 491 |
"unsupported protruding punctuation: %c", *protrusion); |
| 492 |
break; |
| 493 |
/* LCOV_EXCL_STOP */ |
| 494 |
} |
| 495 |
|
| 496 |
add_text(gregorio_strdup("}")); |
| 497 |
end_style(ST_VERBATIM, SB_IGNORE); |
| 498 |
end_style(ST_PROTRUSION_FACTOR, SB_IGNORE); |
| 499 |
|
| 500 |
add_style(ST_PROTRUSION, SB_IGNORE); |
| 501 |
add_text(protrusion); |
| 502 |
end_style(ST_PROTRUSION, SB_IGNORE); |
| 503 |
|
| 504 |
has_protrusion = true; |
| 505 |
} |
| 506 |
} |
| 507 |
|
| 508 |
/* |
| 509 |
* Function to close a syllable and update the position. |
| 510 |
*/ |
| 511 |
|
| 512 |
static void close_syllable(YYLTYPE *loc) |
| 513 |
{ |
| 514 |
int i = 0; |
| 515 |
gregorio_character *ch; |
| 516 |
|
| 517 |
/* make sure any elisions that are opened are closed within the syllable */ |
| 518 |
for (ch = first_text_character; ch; ch = ch->next_character) { |
| 519 |
if (!ch->is_character) { |
| 520 |
switch (ch->cos.s.style) { |
| 521 |
case ST_ELISION: |
| 522 |
switch (ch->cos.s.type) { |
| 523 |
case ST_T_BEGIN: |
| 524 |
++i; |
| 525 |
/* the parser precludes this from falling here */ |
| 526 |
gregorio_assert_only(i <= 1, close_syllable, |
| 527 |
"elisions may not be nested"); |
| 528 |
break; |
| 529 |
|
| 530 |
case ST_T_END: |
| 531 |
--i; |
| 532 |
/* the parser precludes this from failing here */ |
| 533 |
gregorio_assert_only(i >= 0, close_syllable, |
| 534 |
"encountered elision end with no beginning"); |
| 535 |
break; |
| 536 |
|
| 537 |
case ST_T_NOTHING: |
| 538 |
/* not reachable unless there's a programming error */ |
| 539 |
/* LCOV_EXCL_START */ |
| 540 |
gregorio_fail(close_syllable, "encountered ST_T_NOTHING"); |
| 541 |
break; |
| 542 |
/* LCOV_EXCL_STOP */ |
| 543 |
} |
| 544 |
break; |
| 545 |
|
| 546 |
case ST_FORCED_CENTER: |
| 547 |
if (i > 0) { |
| 548 |
gregorio_message( |
| 549 |
_("forced center may not be within an elision"), |
| 550 |
"close_syllable", VERBOSITY_ERROR, 0); |
| 551 |
} |
| 552 |
break; |
| 553 |
|
| 554 |
default: |
| 555 |
break; |
| 556 |
} |
| 557 |
} |
| 558 |
} |
| 559 |
/* the parser precludes this from failing here */ |
| 560 |
gregorio_assert_only(i == 0, close_syllable, |
| 561 |
"encountered elision beginning with no end"); |
| 562 |
|
| 563 |
gregorio_add_syllable(¤t_syllable, number_of_voices, elements, |
| 564 |
first_text_character, first_translation_character, position, |
| 565 |
abovelinestext, translation_type, no_linebreak_area, euouae, loc, |
| 566 |
started_first_word, clear_syllable_text); |
| 567 |
if (!score->first_syllable) { |
| 568 |
/* we rebuild the first syllable if we have to */ |
| 569 |
score->first_syllable = current_syllable; |
| 570 |
} |
| 571 |
if (translation_type == TR_WITH_CENTER_END) { |
| 572 |
gregorio_set_translation_center_beginning(current_syllable); |
| 573 |
} |
| 574 |
/* we update the position */ |
| 575 |
if (position == WORD_BEGINNING) { |
| 576 |
position = WORD_MIDDLE; |
| 577 |
} |
| 578 |
if (position == WORD_ONE_SYLLABLE || position == WORD_END) { |
| 579 |
position = WORD_BEGINNING; |
| 580 |
|
| 581 |
if (started_first_word) { |
| 582 |
started_first_word = false; |
| 583 |
} |
| 584 |
} |
| 585 |
center_is_determined = CENTER_NOT_DETERMINED; |
| 586 |
current_character = NULL; |
| 587 |
suspended_character = NULL; |
| 588 |
first_text_character = NULL; |
| 589 |
first_translation_character = NULL; |
| 590 |
translation_type = TR_NORMAL; |
| 591 |
no_linebreak_area = NLBA_NORMAL; |
| 592 |
euouae = EUOUAE_NORMAL; |
| 593 |
abovelinestext = NULL; |
| 594 |
for (i = 0; i < number_of_voices; i++) { |
| 595 |
elements[i] = NULL; |
| 596 |
} |
| 597 |
current_element = NULL; |
| 598 |
clear_syllable_text = false; |
| 599 |
has_protrusion = false; |
| 600 |
} |
| 601 |
|
| 602 |
void gabc_digest(const void *const buf, const size_t size) |
| 603 |
{ |
| 604 |
sha1_process_bytes(buf, size, &digester); |
| 605 |
} |
| 606 |
|
| 607 |
/* |
| 608 |
* The "main" function. It is the function that is called when we have to read |
| 609 |
* a gabc file. It takes a file descriptor, that is to say a file that is |
| 610 |
* aleady open. It returns a valid gregorio_score |
| 611 |
*/ |
| 612 |
|
| 613 |
gregorio_score *gabc_read_score(FILE *f_in, bool point_and_click) |
| 614 |
{ |
| 615 |
/* compute the SHA-1 digest while parsing, for I/O efficiency */ |
| 616 |
sha1_init_ctx(&digester); |
| 617 |
/* digest GREGORIO_VERSION to get a different value when the version |
| 618 |
changes */ |
| 619 |
sha1_process_bytes(GREGORIO_VERSION, strlen(GREGORIO_VERSION), &digester); |
| 620 |
/* the input file that flex will parse */ |
| 621 |
gabc_score_determination_in = f_in; |
| 622 |
gregorio_assert(f_in, gabc_read_score, "can't read stream from NULL", |
| 623 |
return NULL); |
| 624 |
initialize_variables(point_and_click); |
| 625 |
/* the flex/bison main call, it will build the score (that we have |
| 626 |
* initialized) */ |
| 627 |
gabc_score_determination_parse(); |
| 628 |
if (!score->legacy_oriscus_orientation) { |
| 629 |
gabc_determine_oriscus_orientation(score); |
| 630 |
} |
| 631 |
gabc_determine_punctum_inclinatum_orientation(score); |
| 632 |
gabc_determine_ledger_lines(score); |
| 633 |
gregorio_fix_initial_keys(score, gregorio_default_clef); |
| 634 |
rebuild_score_characters(); |
| 635 |
gabc_suppress_extra_custos_at_linebreak(score); |
| 636 |
gabc_fix_custos_pitches(score); |
| 637 |
gabc_det_notes_finish(); |
| 638 |
free_variables(); |
| 639 |
/* then we check the validity and integrity of the score we have built. */ |
| 640 |
if (!gabc_check_score_integrity(score)) { |
| 641 |
gregorio_message(_("unable to determine a valid score from file"), |
| 642 |
"gabc_read_score", VERBOSITY_ERROR, 0); |
| 643 |
} |
| 644 |
sha1_finish_ctx(&digester, score->digest); |
| 645 |
return score; |
| 646 |
} |
| 647 |
|
| 648 |
unsigned char nabc_state = 0; |
| 649 |
size_t nabc_lines = 0; |
| 650 |
|
| 651 |
static void gabc_y_add_notes(char *notes, YYLTYPE loc) { |
| 652 |
if (nabc_state == 0) { |
| 653 |
if (!elements[voice]) { |
| 654 |
elements[voice] = gabc_det_elements_from_string(notes, ¤t_key, |
| 655 |
macros, &loc, &punctum_inclinatum_orientation, score); |
| 656 |
current_element = elements[voice]; |
| 657 |
} else { |
| 658 |
gregorio_element *new_elements = gabc_det_elements_from_string( |
| 659 |
notes, ¤t_key, macros, &loc, |
| 660 |
&punctum_inclinatum_orientation, score); |
| 661 |
gregorio_element *last_element = elements[voice]; |
| 662 |
while (last_element->next) { |
| 663 |
last_element = last_element->next; |
| 664 |
} |
| 665 |
last_element->next = new_elements; |
| 666 |
new_elements->previous = last_element; |
| 667 |
current_element = new_elements; |
| 668 |
} |
| 669 |
} else { |
| 670 |
if (!elements[voice]) { |
| 671 |
gregorio_add_element(&elements[voice], NULL); |
| 672 |
current_element = elements[voice]; |
| 673 |
} |
| 674 |
gregorio_assert(current_element, gabc_y_add_notes, |
| 675 |
"current_element is null, this shouldn't happen!", |
| 676 |
return); |
| 677 |
if (!current_element->nabc) { |
| 678 |
current_element->nabc = (char **) gregorio_calloc (nabc_lines, |
| 679 |
sizeof (char *)); |
| 680 |
} |
| 681 |
current_element->nabc[nabc_state-1] = gregorio_strdup(notes); |
| 682 |
current_element->nabc_lines = nabc_state; |
| 683 |
} |
| 684 |
} |
| 685 |
|
| 686 |
static char *concatenate(char *first, char *const second) { |
| 687 |
first = (char *)gregorio_realloc(first, strlen(first) + strlen(second) + 1); |
| 688 |
strcat(first, second); |
| 689 |
free(second); |
| 690 |
return first; |
| 691 |
} |
| 692 |
%} |
| 693 |
|
| 694 |
%initial-action { |
| 695 |
@$.first_line = 1; |
| 696 |
@$.first_column = 0; |
| 697 |
@$.first_offset = 0; |
| 698 |
@$.last_line = 1; |
| 699 |
@$.last_column = 0; |
| 700 |
@$.last_offset = 0; |
| 701 |
@$.generate_point_and_click = generate_point_and_click; |
| 702 |
} |
| 703 |
|
| 704 |
%token NAME AUTHOR GABC_COPYRIGHT SCORE_COPYRIGHT |
| 705 |
%token LANGUAGE STAFF_LINES ORISCUS_ORIENTATION |
| 706 |
%token DEF_MACRO OTHER_HEADER |
| 707 |
%token ANNOTATION MODE MODE_MODIFIER MODE_DIFFERENTIA |
| 708 |
%token END_OF_DEFINITIONS END_OF_FILE |
| 709 |
%token COLON SEMICOLON CHARACTERS NOTES HYPHEN ATTRIBUTE |
| 710 |
%token OPENING_BRACKET CLOSING_BRACKET CLOSING_BRACKET_WITH_SPACE |
| 711 |
%token I_BEGIN I_END |
| 712 |
%token TT_BEGIN TT_END |
| 713 |
%token UL_BEGIN UL_END |
| 714 |
%token C_BEGIN C_END |
| 715 |
%token B_BEGIN B_END |
| 716 |
%token SC_BEGIN SC_END |
| 717 |
%token SP_BEGIN SP_END |
| 718 |
%token VERB_BEGIN VERB_END |
| 719 |
%token CENTER_BEGIN CENTER_END |
| 720 |
%token ELISION_BEGIN ELISION_END |
| 721 |
%token TRANSLATION_BEGIN TRANSLATION_END TRANSLATION_CENTER_END |
| 722 |
%token ALT_BEGIN ALT_END |
| 723 |
%token NLBA_B NLBA_E |
| 724 |
%token EUOUAE_B EUOUAE_E |
| 725 |
%token NABC_CUT NABC_LINES |
| 726 |
%token CLEAR |
| 727 |
%token PROTRUSION PROTRUSION_VALUE PROTRUSION_END PROTRUDING_PUNCTUATION |
| 728 |
|
| 729 |
%precedence HYPHEN PROTRUDING_PUNCTUATION |
| 730 |
%precedence TRANSLATION_BEGIN TRANSLATION_CENTER_END |
| 731 |
%precedence TRANSLATION_END |
| 732 |
%precedence OPENING_BRACKET |
| 733 |
|
| 734 |
%% |
| 735 |
|
| 736 |
score: |
| 737 |
all_definitions syllables |
| 738 |
; |
| 739 |
|
| 740 |
all_definitions: |
| 741 |
definitions END_OF_DEFINITIONS { |
| 742 |
end_definitions(); |
| 743 |
} |
| 744 |
; |
| 745 |
|
| 746 |
definitions: |
| 747 |
| definitions definition |
| 748 |
; |
| 749 |
|
| 750 |
attribute_value: |
| 751 |
ATTRIBUTE { |
| 752 |
$$.text = $1.text; |
| 753 |
} |
| 754 |
| attribute_value ATTRIBUTE { |
| 755 |
$$.text = concatenate($1.text, $2.text); |
| 756 |
} |
| 757 |
; |
| 758 |
|
| 759 |
attribute: |
| 760 |
COLON attribute_value SEMICOLON { |
| 761 |
$$.text = $2.text; |
| 762 |
} |
| 763 |
| COLON SEMICOLON { |
| 764 |
$$.text = NULL; |
| 765 |
} |
| 766 |
; |
| 767 |
|
| 768 |
definition: |
| 769 |
DEF_MACRO attribute { |
| 770 |
/* these definitions are not passed through */ |
| 771 |
free(macros[$1.character - '0']); |
| 772 |
macros[$1.character - '0'] = $2.text; |
| 773 |
} |
| 774 |
| NAME attribute { |
| 775 |
if ($2.text == NULL) { |
| 776 |
gregorio_message("name can't be empty","det_score", |
| 777 |
VERBOSITY_WARNING, 0); |
| 778 |
} |
| 779 |
check_multiple("name", score->name != NULL); |
| 780 |
gregorio_add_score_header(score, $1.text, $2.text); |
| 781 |
score->name = $2.text; |
| 782 |
} |
| 783 |
| LANGUAGE attribute { |
| 784 |
check_multiple("language", got_language); |
| 785 |
gregorio_add_score_header(score, $1.text, $2.text); |
| 786 |
gregorio_set_centering_language($2.text); |
| 787 |
got_language = true; |
| 788 |
} |
| 789 |
| GABC_COPYRIGHT attribute { |
| 790 |
check_multiple("gabc-copyright", score->gabc_copyright != NULL); |
| 791 |
gregorio_add_score_header(score, $1.text, $2.text); |
| 792 |
score->gabc_copyright = $2.text; |
| 793 |
} |
| 794 |
| SCORE_COPYRIGHT attribute { |
| 795 |
check_multiple("score_copyright", score->score_copyright != NULL); |
| 796 |
gregorio_add_score_header(score, $1.text, $2.text); |
| 797 |
score->score_copyright = $2.text; |
| 798 |
} |
| 799 |
| MODE attribute { |
| 800 |
check_multiple("mode", score->mode != 0); |
| 801 |
gregorio_add_score_header(score, $1.text, $2.text); |
| 802 |
score->mode = $2.text; |
| 803 |
} |
| 804 |
| MODE_MODIFIER attribute { |
| 805 |
check_multiple("mode-modifier", score->mode_modifier != NULL); |
| 806 |
gregorio_add_score_header(score, $1.text, $2.text); |
| 807 |
score->mode_modifier = $2.text; |
| 808 |
} |
| 809 |
| MODE_DIFFERENTIA attribute { |
| 810 |
check_multiple("mode-differentia", score->mode_differentia != NULL); |
| 811 |
gregorio_add_score_header(score, $1.text, $2.text); |
| 812 |
score->mode_differentia = $2.text; |
| 813 |
} |
| 814 |
| STAFF_LINES attribute { |
| 815 |
check_multiple("staff-lines", got_staff_lines); |
| 816 |
if ($2.text) { |
| 817 |
gregorio_add_score_header(score, $1.text, $2.text); |
| 818 |
gregorio_set_score_staff_lines(score, atoi($2.text)); |
| 819 |
got_staff_lines = true; |
| 820 |
} |
| 821 |
} |
| 822 |
| NABC_LINES attribute { |
| 823 |
check_multiple("nabc lines", score->nabc_lines != 0); |
| 824 |
if ($2.text) { |
| 825 |
gregorio_add_score_header(score, $1.text, $2.text); |
| 826 |
nabc_lines=atoi($2.text); |
| 827 |
score->nabc_lines=nabc_lines; |
| 828 |
} |
| 829 |
} |
| 830 |
| ANNOTATION attribute { |
| 831 |
if (score->annotation [MAX_ANNOTATIONS - 1]) { |
| 832 |
gregorio_messagef("det_score", VERBOSITY_WARNING, 0, |
| 833 |
_("too many definitions of annotation found, only the " |
| 834 |
"first %d will be taken"), MAX_ANNOTATIONS); |
| 835 |
} |
| 836 |
gregorio_add_score_header(score, $1.text, $2.text); |
| 837 |
gregorio_set_score_annotation(score, $2.text); |
| 838 |
} |
| 839 |
| AUTHOR attribute { |
| 840 |
check_multiple("author", score->author != NULL); |
| 841 |
gregorio_add_score_header(score, $1.text, $2.text); |
| 842 |
score->author = $2.text; |
| 843 |
} |
| 844 |
| ORISCUS_ORIENTATION attribute { |
| 845 |
gregorio_add_score_header(score, $1.text, $2.text); |
| 846 |
score->legacy_oriscus_orientation = (strcmp($2.text, "legacy") == 0); |
| 847 |
} |
| 848 |
| OTHER_HEADER attribute { |
| 849 |
gregorio_add_score_header(score, $1.text, $2.text); |
| 850 |
} |
| 851 |
; |
| 852 |
|
| 853 |
notes: |
| 854 |
| notes note |
| 855 |
; |
| 856 |
|
| 857 |
note: |
| 858 |
NOTES CLOSING_BRACKET { |
| 859 |
gabc_y_add_notes($1.text, @1); |
| 860 |
free($1.text); |
| 861 |
nabc_state=0; |
| 862 |
} |
| 863 |
| NOTES closing_bracket_with_space { |
| 864 |
gabc_y_add_notes($1.text, @1); |
| 865 |
free($1.text); |
| 866 |
nabc_state=0; |
| 867 |
update_position_with_space(); |
| 868 |
} |
| 869 |
| NOTES NABC_CUT { |
| 870 |
if (!nabc_lines) { |
| 871 |
gregorio_message(_("You used character \"|\" in gabc without " |
| 872 |
"setting \"nabc-lines\" parameter. Please " |
| 873 |
"set it in your gabc header."), |
| 874 |
"det_score", VERBOSITY_FATAL, 0); |
| 875 |
} |
| 876 |
gabc_y_add_notes($1.text, @1); |
| 877 |
free($1.text); |
| 878 |
nabc_state = (nabc_state + 1) % (nabc_lines+1); |
| 879 |
} |
| 880 |
| CLOSING_BRACKET { |
| 881 |
elements[voice]=NULL; |
| 882 |
nabc_state=0; |
| 883 |
} |
| 884 |
| closing_bracket_with_space { |
| 885 |
elements[voice]=NULL; |
| 886 |
nabc_state=0; |
| 887 |
update_position_with_space(); |
| 888 |
} |
| 889 |
; |
| 890 |
|
| 891 |
closing_bracket_with_space: |
| 892 |
CLOSING_BRACKET_WITH_SPACE |
| 893 |
| CLOSING_BRACKET_WITH_SPACE END_OF_FILE |
| 894 |
| CLOSING_BRACKET END_OF_FILE |
| 895 |
; |
| 896 |
|
| 897 |
style_beginning: |
| 898 |
I_BEGIN { |
| 899 |
add_style(ST_ITALIC, SB_ITALIC); |
| 900 |
} |
| 901 |
| TT_BEGIN { |
| 902 |
add_style(ST_TT, SB_TT); |
| 903 |
} |
| 904 |
| UL_BEGIN { |
| 905 |
add_style(ST_UNDERLINED, SB_UNDERLINED); |
| 906 |
} |
| 907 |
| C_BEGIN { |
| 908 |
add_style(ST_COLORED, SB_COLORED); |
| 909 |
} |
| 910 |
| B_BEGIN { |
| 911 |
add_style(ST_BOLD, SB_BOLD); |
| 912 |
} |
| 913 |
| SC_BEGIN { |
| 914 |
add_style(ST_SMALL_CAPS, SB_SMALL_CAPS); |
| 915 |
} |
| 916 |
| VERB_BEGIN { |
| 917 |
add_style(ST_VERBATIM, SB_IGNORE); |
| 918 |
} |
| 919 |
| SP_BEGIN { |
| 920 |
add_style(ST_SPECIAL_CHAR, SB_IGNORE); |
| 921 |
} |
| 922 |
; |
| 923 |
|
| 924 |
style_end: |
| 925 |
I_END { |
| 926 |
end_style(ST_ITALIC, SB_ITALIC); |
| 927 |
} |
| 928 |
| TT_END { |
| 929 |
end_style(ST_TT, SB_TT); |
| 930 |
} |
| 931 |
| UL_END { |
| 932 |
end_style(ST_UNDERLINED, SB_UNDERLINED); |
| 933 |
} |
| 934 |
| C_END { |
| 935 |
end_style(ST_COLORED, SB_COLORED); |
| 936 |
} |
| 937 |
| B_END { |
| 938 |
end_style(ST_BOLD, SB_BOLD); |
| 939 |
} |
| 940 |
| SC_END { |
| 941 |
end_style(ST_SMALL_CAPS, SB_SMALL_CAPS); |
| 942 |
} |
| 943 |
| VERB_END { |
| 944 |
end_style(ST_VERBATIM, SB_IGNORE); |
| 945 |
} |
| 946 |
| SP_END { |
| 947 |
end_style(ST_SPECIAL_CHAR, SB_IGNORE); |
| 948 |
} |
| 949 |
; |
| 950 |
|
| 951 |
special_style_beginning: |
| 952 |
ELISION_BEGIN { |
| 953 |
add_style(ST_ELISION, SB_ELISION); |
| 954 |
} |
| 955 |
| CENTER_BEGIN { |
| 956 |
if (center_is_determined) { |
| 957 |
gregorio_message( |
| 958 |
"syllable already has center; ignoring additional center", |
| 959 |
"det_score", VERBOSITY_WARNING, 0); |
| 960 |
} else if (has_protrusion) { |
| 961 |
gregorio_message( |
| 962 |
"center not allowed after protrusion; ignored", |
| 963 |
"det_score", VERBOSITY_WARNING, 0); |
| 964 |
} else { |
| 965 |
add_style(ST_FORCED_CENTER, SB_IGNORE); |
| 966 |
center_is_determined = CENTER_HALF_DETERMINED; |
| 967 |
} |
| 968 |
} |
| 969 |
; |
| 970 |
|
| 971 |
special_style_end: |
| 972 |
ELISION_END { |
| 973 |
end_style(ST_ELISION, SB_ELISION); |
| 974 |
} |
| 975 |
| CENTER_END { |
| 976 |
if (center_is_determined == CENTER_HALF_DETERMINED) { |
| 977 |
end_style(ST_FORCED_CENTER, SB_IGNORE); |
| 978 |
center_is_determined = CENTER_FULLY_DETERMINED; |
| 979 |
} else { |
| 980 |
gregorio_message( |
| 981 |
"not within a syllable center", |
| 982 |
"det_score", VERBOSITY_WARNING, 0); |
| 983 |
} |
| 984 |
} |
| 985 |
; |
| 986 |
|
| 987 |
euouae: |
| 988 |
EUOUAE_B { |
| 989 |
euouae = EUOUAE_BEGINNING; |
| 990 |
} |
| 991 |
| EUOUAE_E { |
| 992 |
euouae = EUOUAE_END; |
| 993 |
} |
| 994 |
; |
| 995 |
|
| 996 |
linebreak_area: |
| 997 |
NLBA_B { |
| 998 |
no_linebreak_area = NLBA_BEGINNING; |
| 999 |
} |
| 1000 |
| NLBA_E { |
| 1001 |
no_linebreak_area = NLBA_END; |
| 1002 |
} |
| 1003 |
; |
| 1004 |
|
| 1005 |
protrusion: |
| 1006 |
PROTRUSION PROTRUSION_VALUE PROTRUSION_END { |
| 1007 |
add_protrusion($2.text); |
| 1008 |
} |
| 1009 |
| PROTRUSION { |
| 1010 |
add_protrusion(gregorio_strdup("d")); /* d = default */ |
| 1011 |
} |
| 1012 |
; |
| 1013 |
|
| 1014 |
character: |
| 1015 |
above_line_text |
| 1016 |
| CHARACTERS { |
| 1017 |
add_text($1.text); |
| 1018 |
} |
| 1019 |
| style_beginning |
| 1020 |
| style_end |
| 1021 |
| special_style_beginning |
| 1022 |
| special_style_end |
| 1023 |
| linebreak_area |
| 1024 |
| euouae |
| 1025 |
| CLEAR { |
| 1026 |
clear_syllable_text = true; |
| 1027 |
} |
| 1028 |
| protrusion |
| 1029 |
| HYPHEN { |
| 1030 |
add_text(gregorio_strdup("-")); |
| 1031 |
} |
| 1032 |
| PROTRUDING_PUNCTUATION { |
| 1033 |
add_text($1.text); |
| 1034 |
} |
| 1035 |
; |
| 1036 |
|
| 1037 |
text: |
| 1038 |
character |
| 1039 |
| text character |
| 1040 |
; |
| 1041 |
|
| 1042 |
translation_character: |
| 1043 |
CHARACTERS { |
| 1044 |
add_text($1.text); |
| 1045 |
} |
| 1046 |
| style_beginning |
| 1047 |
| style_end |
| 1048 |
| HYPHEN { |
| 1049 |
add_text(gregorio_strdup("-")); |
| 1050 |
} |
| 1051 |
| PROTRUDING_PUNCTUATION { |
| 1052 |
add_text($1.text); |
| 1053 |
} |
| 1054 |
; |
| 1055 |
|
| 1056 |
translation_text: |
| 1057 |
translation_character |
| 1058 |
| translation_text translation_character |
| 1059 |
; |
| 1060 |
|
| 1061 |
translation_beginning: |
| 1062 |
TRANSLATION_BEGIN { |
| 1063 |
start_translation(TR_NORMAL); |
| 1064 |
} |
| 1065 |
; |
| 1066 |
|
| 1067 |
translation: |
| 1068 |
translation_beginning TRANSLATION_END { |
| 1069 |
end_translation(); |
| 1070 |
} |
| 1071 |
| translation_beginning translation_text TRANSLATION_END { |
| 1072 |
end_translation(); |
| 1073 |
} |
| 1074 |
| TRANSLATION_CENTER_END { |
| 1075 |
start_translation(TR_WITH_CENTER_END); |
| 1076 |
end_translation(); |
| 1077 |
} |
| 1078 |
; |
| 1079 |
|
| 1080 |
above_line_text: |
| 1081 |
ALT_BEGIN CHARACTERS ALT_END { |
| 1082 |
abovelinestext = $2.text; |
| 1083 |
} |
| 1084 |
; |
| 1085 |
|
| 1086 |
syllable_with_notes: |
| 1087 |
text OPENING_BRACKET notes { |
| 1088 |
save_text(); |
| 1089 |
close_syllable(&@1); |
| 1090 |
} |
| 1091 |
| HYPHEN OPENING_BRACKET notes { |
| 1092 |
add_style(ST_VERBATIM, SB_IGNORE); |
| 1093 |
add_text(gregorio_strdup("\\GreForceHyphen")); |
| 1094 |
end_style(ST_VERBATIM, SB_IGNORE); |
| 1095 |
save_text(); |
| 1096 |
close_syllable(&@1); |
| 1097 |
} |
| 1098 |
| text HYPHEN OPENING_BRACKET notes { |
| 1099 |
add_style(ST_VERBATIM, SB_IGNORE); |
| 1100 |
add_text(gregorio_strdup("\\GreForceHyphen")); |
| 1101 |
end_style(ST_VERBATIM, SB_IGNORE); |
| 1102 |
save_text(); |
| 1103 |
close_syllable(&@1); |
| 1104 |
} |
| 1105 |
| PROTRUDING_PUNCTUATION OPENING_BRACKET notes { |
| 1106 |
add_auto_protrusion($1.text); |
| 1107 |
save_text(); |
| 1108 |
close_syllable(&@1); |
| 1109 |
} |
| 1110 |
| text PROTRUDING_PUNCTUATION OPENING_BRACKET notes { |
| 1111 |
add_auto_protrusion($2.text); |
| 1112 |
save_text(); |
| 1113 |
close_syllable(&@1); |
| 1114 |
} |
| 1115 |
| text translation OPENING_BRACKET notes { |
| 1116 |
save_text(); |
| 1117 |
close_syllable(&@1); |
| 1118 |
} |
| 1119 |
| HYPHEN translation OPENING_BRACKET notes { |
| 1120 |
add_style(ST_VERBATIM, SB_IGNORE); |
| 1121 |
add_text(gregorio_strdup("\\GreForceHyphen")); |
| 1122 |
end_style(ST_VERBATIM, SB_IGNORE); |
| 1123 |
save_text(); |
| 1124 |
close_syllable(&@1); |
| 1125 |
} |
| 1126 |
| text HYPHEN translation OPENING_BRACKET notes { |
| 1127 |
add_style(ST_VERBATIM, SB_IGNORE); |
| 1128 |
add_text(gregorio_strdup("\\GreForceHyphen")); |
| 1129 |
end_style(ST_VERBATIM, SB_IGNORE); |
| 1130 |
save_text(); |
| 1131 |
close_syllable(&@1); |
| 1132 |
} |
| 1133 |
| PROTRUDING_PUNCTUATION translation OPENING_BRACKET notes { |
| 1134 |
add_auto_protrusion($1.text); |
| 1135 |
save_text(); |
| 1136 |
close_syllable(&@1); |
| 1137 |
} |
| 1138 |
| text PROTRUDING_PUNCTUATION translation OPENING_BRACKET notes { |
| 1139 |
add_auto_protrusion($2.text); |
| 1140 |
save_text(); |
| 1141 |
close_syllable(&@1); |
| 1142 |
} |
| 1143 |
; |
| 1144 |
|
| 1145 |
notes_without_word: |
| 1146 |
OPENING_BRACKET notes { |
| 1147 |
close_syllable(NULL); |
| 1148 |
} |
| 1149 |
| translation OPENING_BRACKET notes { |
| 1150 |
close_syllable(NULL); |
| 1151 |
} |
| 1152 |
; |
| 1153 |
|
| 1154 |
syllable: |
| 1155 |
syllable_with_notes |
| 1156 |
| notes_without_word |
| 1157 |
; |
| 1158 |
|
| 1159 |
syllables: |
| 1160 |
| syllables syllable |
| 1161 |
; |