summaryrefslogtreecommitdiff
path: root/Build/source/texk/gregorio/gregorio-src/src/gabc/gabc-notes-determination.l
diff options
context:
space:
mode:
authorAkira Kakuto <kakuto@fuk.kindai.ac.jp>2016-01-23 22:38:00 +0000
committerAkira Kakuto <kakuto@fuk.kindai.ac.jp>2016-01-23 22:38:00 +0000
commitfaa5f31c4901212372d2dcf7080d9f0a23d5f195 (patch)
treecda02ce149a95cfa5d20f01943eceae7ff256b7b /Build/source/texk/gregorio/gregorio-src/src/gabc/gabc-notes-determination.l
parent21d19604dc80efef1747f4a048c9dae5e8e810b1 (diff)
gregorio 4.1.0-beta1
git-svn-id: svn://tug.org/texlive/trunk@39470 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/gregorio/gregorio-src/src/gabc/gabc-notes-determination.l')
-rw-r--r--Build/source/texk/gregorio/gregorio-src/src/gabc/gabc-notes-determination.l663
1 files changed, 538 insertions, 125 deletions
diff --git a/Build/source/texk/gregorio/gregorio-src/src/gabc/gabc-notes-determination.l b/Build/source/texk/gregorio/gregorio-src/src/gabc/gabc-notes-determination.l
index f48875aea4a..c3813238d43 100644
--- a/Build/source/texk/gregorio/gregorio-src/src/gabc/gabc-notes-determination.l
+++ b/Build/source/texk/gregorio/gregorio-src/src/gabc/gabc-notes-determination.l
@@ -42,12 +42,35 @@ static char char_for_brace;
static unsigned int nbof_isolated_episema;
static char *notesmacros[10];
static char tempstr[256];
-static int brace_var_counter;
-static int overbrace_var, underbrace_var;
+static int brace_var_counter = 0;
+static int overbrace_var = 0, underbrace_var = 0;
static const char *overbrace_var_kind;
+static int before_ledger_type;
+static char *before_ledger_length = NULL;
+static int ledger_var[2] = { 0, 0 };
+static unsigned char staff_lines;
+static signed char highest_pitch;
+static bool legacy_oriscus_orientation;
+static int slur_var[2] = { 0, 0 };
+static char slur_shift[2] = { '\0', '\0' };
+static gregorio_note *slur_start[] = { NULL, NULL };
+
+typedef enum ledger_line_type {
+ LL_OVER = 0,
+ LL_UNDER = 1
+} ledger_line_type;
static __inline char pitch_letter_to_height(const char pitch) {
- return pitch - 'a' + LOWEST_PITCH;
+ char result = pitch - 'a' + LOWEST_PITCH;
+ if (pitch == 'p') {
+ --result;
+ }
+ if (result > highest_pitch) {
+ gregorio_messagef("pitch_letter_to_height", VERBOSITY_ERROR, 0,
+ _("invalid pitch for %u lines: %c"), (unsigned int)staff_lines,
+ pitch);
+ }
+ return result;
}
static gregorio_shape punctum(const char pitch)
@@ -63,9 +86,19 @@ static __inline void lex_add_note(int i, gregorio_shape shape, char signs,
char liquescentia)
{
nbof_isolated_episema = 0;
- gregorio_add_note(&current_note,
- pitch_letter_to_height(tolower((unsigned char)gabc_notes_determination_text[i])),
+ gregorio_add_note(&current_note, pitch_letter_to_height(
+ tolower((unsigned char)gabc_notes_determination_text[i])),
shape, signs, liquescentia, NULL, &notes_lloc);
+
+ if (ledger_var[LL_OVER]) {
+ current_note->supposed_high_ledger_line = true;
+ current_note->explicit_high_ledger_line = true;
+ }
+
+ if (ledger_var[LL_UNDER]) {
+ current_note->supposed_low_ledger_line = true;
+ current_note->explicit_low_ledger_line = true;
+ }
}
static __inline void add_bar_as_note(gregorio_bar bar)
@@ -81,7 +114,8 @@ static __inline void error(void)
gabc_notes_determination_text[3] - '0');
}
-static void add_h_episema(void) {
+static void add_h_episema(void)
+{
grehepisema_size size = H_NORMAL;
gregorio_vposition vposition = VPOS_AUTO;
bool disable_bridge = false;
@@ -121,7 +155,8 @@ static void add_h_episema(void) {
&nbof_isolated_episema);
}
-static void add_sign(gregorio_sign sign) {
+static void add_sign(gregorio_sign sign)
+{
gregorio_vposition vposition = VPOS_AUTO;
switch(gabc_notes_determination_text[1]) {
case '0':
@@ -134,10 +169,266 @@ static void add_sign(gregorio_sign sign) {
gregorio_add_sign(current_note, sign, vposition);
}
-static __inline void add_alteration(const gregorio_type type) {
- gregorio_add_alteration_as_note(&current_note, type,
- pitch_letter_to_height(gabc_notes_determination_text[0]),
- &notes_lloc);
+static void save_before_ledger(const char *const before_ledger)
+{
+ if (strcmp(before_ledger, "0") == 0) {
+ before_ledger_type = 0;
+ before_ledger_length = "";
+ } else if (strcmp(before_ledger, "1") == 0) {
+ before_ledger_type = 1;
+ before_ledger_length = "";
+ } else {
+ before_ledger_type = 2;
+ before_ledger_length = gregorio_strdup(before_ledger);
+ }
+}
+
+static void add_static_ledger(const ledger_line_type type, const char *length) {
+ gregorio_snprintf(tempstr, sizeof tempstr,
+ "\\GreDrawAdditionalLine{%d}{%s}{%d}{%s}{0}{}",
+ type, length + 1, before_ledger_type, before_ledger_length);
+
+ if (before_ledger_type == 2) {
+ free(before_ledger_length);
+ before_ledger_length = NULL;
+ }
+
+ gregorio_add_texverb_as_note(&current_note, gregorio_strdup(tempstr),
+ GRE_TEXVERB_GLYPH, &notes_lloc);
+}
+
+static __inline const char *ledger_type_name(const ledger_line_type type) {
+ switch (type) {
+ case LL_OVER:
+ return "over";
+ case LL_UNDER:
+ return "under";
+ }
+ gregorio_messagef("ledger_type_name", VERBOSITY_ERROR, 0,
+ _("invalid ledger type %d"), type);
+ return NULL;
+}
+
+static void add_variable_ledger(const ledger_line_type type,
+ const char *after_ledger)
+{
+ if (ledger_var[type]) {
+ const char *const typename = ledger_type_name(type);
+ gregorio_messagef("add_variable_ledger", VERBOSITY_ERROR, 0,
+ _("variable %s-staff ledger line without termination of "
+ "previous %s-staff ledger line"), typename, typename);
+ } else {
+ int after_ledger_type;
+ const char *after_ledger_length;
+
+ ++after_ledger;
+
+ if (strcmp(after_ledger, "0") == 0) {
+ after_ledger_type = 0;
+ after_ledger_length = "";
+ } else if (strcmp(after_ledger, "1") == 0) {
+ after_ledger_type = 1;
+ after_ledger_length = "";
+ } else {
+ after_ledger_type = 2;
+ after_ledger_length = after_ledger;
+ }
+
+ ledger_var[type] = ++brace_var_counter;
+ gregorio_snprintf(tempstr, sizeof tempstr,
+ "\\GreVarBraceSavePos{%d}{0}{1}"
+ "\\GreDrawAdditionalLine{%d}{\\GreVarBraceLength{%d}}"
+ "{%d}{%s}{%d}{%s}",
+ ledger_var[type], type, ledger_var[type], before_ledger_type,
+ before_ledger_length, after_ledger_type, after_ledger_length);
+
+ if (before_ledger_type == 2) {
+ free(before_ledger_length);
+ before_ledger_length = NULL;
+ }
+
+ gregorio_add_texverb_as_note(&current_note, gregorio_strdup(tempstr),
+ GRE_TEXVERB_GLYPH, &notes_lloc);
+ }
+}
+
+static void end_variable_ledger(const ledger_line_type type)
+{
+ if (!ledger_var[type]) {
+ const char *const typename = ledger_type_name(type);
+ gregorio_messagef("end_variable_ledger", VERBOSITY_ERROR, 0,
+ _("variable %s-staff ledger line termination without variable "
+ "%s-staff ledger line start"), typename, typename);
+ } else {
+ gregorio_snprintf(tempstr, sizeof tempstr,
+ "\\GreVarBraceSavePos{%d}{0}{2}", ledger_var[type]);
+ ledger_var[type] = 0;
+ gregorio_add_texverb_as_note(&current_note, gregorio_strdup(tempstr),
+ GRE_TEXVERB_GLYPH, &notes_lloc);
+ }
+}
+
+static __inline int parse_clef_line(char line)
+{
+ line -= '0';
+ if (line < 0 || line > staff_lines) {
+ gregorio_messagef("parse_clef_line", VERBOSITY_ERROR, 0,
+ _("invalid clef line for %u lines: %d"),
+ (unsigned int)staff_lines, (int)line);
+ return 1;
+ }
+ return line;
+}
+
+static __inline gregorio_bar parse_dominican_bar(char bar)
+{
+ bar -= '0';
+ if (bar < 1 || bar > (2 * (staff_lines - 1))) {
+ gregorio_messagef("parse_dominican_line", VERBOSITY_ERROR, 0,
+ _("invalid dominican bar for %u lines: ;%d"),
+ (unsigned int)staff_lines, (int)bar);
+ }
+
+ switch (bar) {
+ case 1:
+ return B_DIVISIO_MINOR_D1;
+ case 2:
+ return B_DIVISIO_MINOR_D2;
+ case 3:
+ return B_DIVISIO_MINOR_D3;
+ case 4:
+ return B_DIVISIO_MINOR_D4;
+ case 5:
+ return B_DIVISIO_MINOR_D5;
+ case 6:
+ return B_DIVISIO_MINOR_D6;
+ case 7:
+ return B_DIVISIO_MINOR_D7;
+ case 8:
+ return B_DIVISIO_MINOR_D8;
+ }
+
+ gregorio_messagef("check_dominican_line", VERBOSITY_ERROR, 0,
+ _("invalid dominican bar: %d"), (int)bar);
+ return B_NO_BAR;
+}
+
+static __inline gregorio_clef letter_to_clef(char letter)
+{
+ switch (letter) {
+ case 'c':
+ return CLEF_C;
+ case 'f':
+ return CLEF_F;
+ }
+ gregorio_messagef("letter_to_clef", VERBOSITY_ERROR, 0,
+ _("invalid clef: %c"), letter);
+ return CLEF_C;
+}
+
+static __inline void slur_assert(char *fn, bool test) {
+ if (!test) {
+ gregorio_message(_("invalid slur text"), fn, VERBOSITY_FATAL, 0);
+ exit(1);
+ }
+}
+
+static char *parse_slur_shift(char *shift)
+{
+ char *c;
+
+ c = strchr(gabc_notes_determination_text, ':');
+ slur_assert("parse_slur_shift", c != NULL);
+ slur_assert("parse_slur_shift", *(++c) != '\0');
+ *shift = *c;
+ return c;
+}
+
+static void parse_slur(int direction)
+{
+ char shift, *width, *height, *end;
+
+ if (!current_note || current_note->type != GRE_NOTE) {
+ gregorio_message(
+ _("cannot add a slur to something that is not a note"),
+ "parse_slur", VERBOSITY_ERROR, 0);
+ return;
+ }
+
+ end = parse_slur_shift(&shift);
+ width = strchr(end, ';');
+ slur_assert("parse_slur", width != NULL);
+ height = strchr(++width, ',');
+ slur_assert("parse_slur", height != NULL);
+ *height = '\0';
+ end = strchr(++height, ']');
+ slur_assert("parse_slur", end != NULL);
+ *end = '\0';
+
+ gregorio_snprintf(tempstr, sizeof tempstr,
+ "\\GreSlur{%d}{%d}{%c}{%s}{%s}{}",
+ current_note->u.note.pitch + direction, direction, shift, width,
+ height);
+ gregorio_add_texverb_to_note(current_note, gregorio_strdup(tempstr));
+}
+
+static void start_var_slur(int index)
+{
+ if (!current_note || current_note->type != GRE_NOTE) {
+ gregorio_message(
+ _("cannot add a slur to something that is not a note"),
+ "start_var_slur", VERBOSITY_ERROR, 0);
+ return;
+ }
+
+ if (slur_var[index]) {
+ gregorio_message(
+ _("variable slur without termination of previous slur"),
+ "start_var_slur", VERBOSITY_ERROR, 0);
+ return;
+ }
+
+ slur_var[index] = ++brace_var_counter;
+ parse_slur_shift(slur_shift + index);
+ slur_start[index] = current_note;
+}
+
+static void end_var_slur(int direction, int index)
+{
+ char shift;
+
+ if (!current_note || current_note->type != GRE_NOTE) {
+ gregorio_message(
+ _("cannot add a slur to something that is not a note"),
+ "end_var_slur", VERBOSITY_ERROR, 0);
+ return;
+ }
+
+ if (!slur_var[index] || !slur_shift[index] || !slur_start[index]) {
+ gregorio_message(_("variable slur end without variable slur start"),
+ "end_var_slur", VERBOSITY_ERROR, 0);
+ return;
+ }
+
+ parse_slur_shift(&shift);
+
+ gregorio_snprintf(tempstr, sizeof tempstr,
+ "\\GreVarBraceSavePos{%d}{%c}{1}"
+ "\\GreSlur{%d}{%d}{%c}{\\GreVarBraceLength{%d}}{}{%d}",
+ slur_var[index], slur_shift[index],
+ slur_start[index]->u.note.pitch + direction, direction,
+ slur_shift[index], slur_var[index],
+ current_note->u.note.pitch + direction);
+ gregorio_add_texverb_to_note(slur_start[index], gregorio_strdup(tempstr));
+
+ gregorio_snprintf(tempstr, sizeof tempstr,
+ "\\GreVarBraceSavePos{%d}{%c}{2}", slur_var[index], shift);
+ gregorio_add_texverb_to_note(current_note, gregorio_strdup(tempstr));
+
+
+ slur_var[index] = 0;
+ slur_shift[index] = '\0';
+ slur_start[index] = NULL;
}
%}
@@ -168,6 +459,11 @@ static __inline void add_alteration(const gregorio_type type) {
%x underbrace
%x overcurlybrace
%x overcurlyaccentusbrace
+%x space
+%x nbspace
+%x overledger overledger2
+%x underledger underledger2
+%x endledger
%%
<INITIAL>\% {
@@ -214,7 +510,7 @@ static __inline void add_alteration(const gregorio_type type) {
"\\GreVarBraceSavePos{%d}{%d}{1}"
"\\GreOverBrace{\\GreVarBraceLength{%d}}{0pt}{0pt}{%d}",
overbrace_var, char_for_brace, overbrace_var, char_for_brace);
- gregorio_add_texverb_to_note(&current_note, gregorio_strdup(tempstr));
+ gregorio_add_texverb_to_note(current_note, gregorio_strdup(tempstr));
}
}
<INITIAL>\[ub:[01]\{\] {
@@ -229,7 +525,7 @@ static __inline void add_alteration(const gregorio_type type) {
"\\GreVarBraceSavePos{%d}{%d}{1}"
"\\GreUnderBrace{\\GreVarBraceLength{%d}}{0pt}{0pt}{%d}",
underbrace_var, char_for_brace, underbrace_var, char_for_brace);
- gregorio_add_texverb_to_note(&current_note, gregorio_strdup(tempstr));
+ gregorio_add_texverb_to_note(current_note, gregorio_strdup(tempstr));
}
}
<INITIAL>\[ocb:[01]\{\] {
@@ -245,7 +541,7 @@ static __inline void add_alteration(const gregorio_type type) {
"\\GreVarBraceSavePos{%d}{%d}{1}"
"\\GreOverCurlyBrace{\\GreVarBraceLength{%d}}{0pt}{0pt}{%d}{0}",
overbrace_var, char_for_brace, overbrace_var, char_for_brace);
- gregorio_add_texverb_to_note(&current_note, gregorio_strdup(tempstr));
+ gregorio_add_texverb_to_note(current_note, gregorio_strdup(tempstr));
}
}
<INITIAL>\[ocba:[01]\{\] {
@@ -261,7 +557,7 @@ static __inline void add_alteration(const gregorio_type type) {
"\\GreVarBraceSavePos{%d}{%d}{1}"
"\\GreOverCurlyBrace{\\GreVarBraceLength{%d}}{0pt}{0pt}{%d}{1}",
overbrace_var, char_for_brace, overbrace_var, char_for_brace);
- gregorio_add_texverb_to_note(&current_note, gregorio_strdup(tempstr));
+ gregorio_add_texverb_to_note(current_note, gregorio_strdup(tempstr));
}
}
<INITIAL>\[ob:[01]\}\] {
@@ -280,7 +576,7 @@ static __inline void add_alteration(const gregorio_type type) {
"\\GreVarBraceSavePos{%d}{%d}{2}", overbrace_var,
char_for_brace);
overbrace_var = 0;
- gregorio_add_texverb_to_note(&current_note, gregorio_strdup(tempstr));
+ gregorio_add_texverb_to_note(current_note, gregorio_strdup(tempstr));
}
}
<INITIAL>\[ub:[01]\}\] {
@@ -294,7 +590,7 @@ static __inline void add_alteration(const gregorio_type type) {
"\\GreVarBraceSavePos{%d}{%d}{2}", underbrace_var,
char_for_brace);
underbrace_var = 0;
- gregorio_add_texverb_to_note(&current_note, gregorio_strdup(tempstr));
+ gregorio_add_texverb_to_note(current_note, gregorio_strdup(tempstr));
}
}
<INITIAL>\[ocb:[01]\}\] {
@@ -313,7 +609,7 @@ static __inline void add_alteration(const gregorio_type type) {
"\\GreVarBraceSavePos{%d}{%d}{2}", overbrace_var,
char_for_brace);
overbrace_var = 0;
- gregorio_add_texverb_to_note(&current_note, gregorio_strdup(tempstr));
+ gregorio_add_texverb_to_note(current_note, gregorio_strdup(tempstr));
}
}
<INITIAL>\[ocba:[01]\}\] {
@@ -332,12 +628,12 @@ static __inline void add_alteration(const gregorio_type type) {
"\\GreVarBraceSavePos{%d}{%d}{2}", overbrace_var,
char_for_brace);
overbrace_var = 0;
- gregorio_add_texverb_to_note(&current_note, gregorio_strdup(tempstr));
+ gregorio_add_texverb_to_note(current_note, gregorio_strdup(tempstr));
}
}
<INITIAL>\[nm[1-9]\] {
if (notesmacros[gabc_notes_determination_text[3]-'0']) {
- gregorio_add_texverb_to_note(&current_note,
+ gregorio_add_texverb_to_note(current_note,
gregorio_strdup(notesmacros[gabc_notes_determination_text[3]-'0']));
} else error();
}
@@ -380,29 +676,35 @@ static __inline void add_alteration(const gregorio_type type) {
<INITIAL><\/nlba> {
gregorio_add_nlba_as_note(&current_note, NLBA_END, &notes_lloc);
}
+<INITIAL>@\[ {
+ gregorio_start_autofuse(&current_note, &notes_lloc);
+ }
+<INITIAL>\] {
+ gregorio_end_autofuse(&current_note, &notes_lloc);
+ }
<overbrace>[^\]]+ {
gregorio_snprintf(tempstr, sizeof tempstr,
"\\GreOverBrace{%s}{0pt}{0pt}{%d}",
gabc_notes_determination_text, char_for_brace);
- gregorio_add_texverb_to_note(&current_note, gregorio_strdup(tempstr));
+ gregorio_add_texverb_to_note(current_note, gregorio_strdup(tempstr));
}
<underbrace>[^\]]+ {
gregorio_snprintf(tempstr, sizeof tempstr,
"\\GreUnderBrace{%s}{0pt}{0pt}{%d}",
gabc_notes_determination_text, char_for_brace);
- gregorio_add_texverb_to_note(&current_note, gregorio_strdup(tempstr));
+ gregorio_add_texverb_to_note(current_note, gregorio_strdup(tempstr));
}
<overcurlybrace>[^\]]+ {
gregorio_snprintf(tempstr, sizeof tempstr,
"\\GreOverCurlyBrace{%s}{0pt}{0pt}{%d}{0}",
gabc_notes_determination_text, char_for_brace);
- gregorio_add_texverb_to_note(&current_note, gregorio_strdup(tempstr));
+ gregorio_add_texverb_to_note(current_note, gregorio_strdup(tempstr));
}
<overcurlyaccentusbrace>[^\]]+ {
gregorio_snprintf(tempstr, sizeof tempstr,
"\\GreOverCurlyBrace{%s}{0pt}{0pt}{%d}{1}",
gabc_notes_determination_text, char_for_brace);
- gregorio_add_texverb_to_note(&current_note, gregorio_strdup(tempstr));
+ gregorio_add_texverb_to_note(current_note, gregorio_strdup(tempstr));
}
<choralsign>[^\]]+ {
gregorio_add_cs_to_note(&current_note,
@@ -413,7 +715,7 @@ static __inline void add_alteration(const gregorio_type type) {
gregorio_strdup(gabc_notes_determination_text), true);
}
<texverbnote>[^\]]+ {
- gregorio_add_texverb_to_note(&current_note,
+ gregorio_add_texverb_to_note(current_note,
gregorio_strdup(gabc_notes_determination_text));
}
<texverbglyph>[^\]]+ {
@@ -431,9 +733,77 @@ static __inline void add_alteration(const gregorio_type type) {
gregorio_strdup(gabc_notes_determination_text), GRE_ALT,
&notes_lloc);
}
-<texverbnote,texverbglyph,texverbelement,choralsign,choralnabc,alt,overcurlyaccentusbrace,overcurlybrace,overbrace,underbrace>\] {
+<INITIAL>\/\[ {
+ BEGIN(space);
+ }
+<space>-?(\.[0-9]+|[0-9]+(\.[0-9]*)?)/\] {
+ gregorio_add_space_as_note(&current_note, SP_AD_HOC_SPACE,
+ gregorio_strdup(gabc_notes_determination_text), &notes_lloc);
+ }
+<INITIAL>!\/\[ {
+ BEGIN(nbspace);
+ }
+<nbspace>-?(\.[0-9]+|[0-9]+(\.[0-9]*)?)/\] {
+ gregorio_add_space_as_note(&current_note, SP_AD_HOC_SPACE_NB,
+ gregorio_strdup(gabc_notes_determination_text), &notes_lloc);
+ }
+<INITIAL>\[oll:\}\] {
+ end_variable_ledger(LL_OVER);
+ }
+<INITIAL>\[oll: {
+ BEGIN(overledger);
+ }
+<overledger>[^;{]+ {
+ save_before_ledger(gabc_notes_determination_text);
+ BEGIN(overledger2);
+ }
+<overledger2>;[^\]]+ {
+ add_static_ledger(LL_OVER, gabc_notes_determination_text);
+ BEGIN(endledger);
+ }
+<overledger2>\{[^\]]+ {
+ add_variable_ledger(LL_OVER, gabc_notes_determination_text);
+ BEGIN(endledger);
+ }
+<INITIAL>\[ull:\}\] {
+ end_variable_ledger(LL_UNDER);
+ }
+<INITIAL>\[ull: {
+ BEGIN(underledger);
+ }
+<underledger>[^;{]+ {
+ save_before_ledger(gabc_notes_determination_text);
+ BEGIN(underledger2);
+ }
+<underledger2>;[^\]]+ {
+ add_static_ledger(LL_UNDER, gabc_notes_determination_text);
+ BEGIN(endledger);
+ }
+<underledger2>\{[^\]]+ {
+ add_variable_ledger(LL_UNDER, gabc_notes_determination_text);
+ BEGIN(endledger);
+ }
+<texverbnote,texverbglyph,texverbelement,choralsign,choralnabc,alt,overcurlyaccentusbrace,overcurlybrace,overbrace,underbrace,space,nbspace,endledger>\] {
BEGIN(INITIAL);
}
+<INITIAL>\[oslur:[012];[^,]+,[^\]]+\] {
+ parse_slur(1);
+ }
+<INITIAL>\[oslur:[012]\{\] {
+ start_var_slur(0);
+ }
+<INITIAL>\[oslur:[012]\}\] {
+ end_var_slur(1, 0);
+ }
+<INITIAL>\[uslur:[012];[^,]+,[^\]]+\] {
+ parse_slur(-1);
+ }
+<INITIAL>\[uslur:[012]\{\] {
+ start_var_slur(1);
+ }
+<INITIAL>\[uslur:[012]\}\] {
+ end_var_slur(-1, 1);
+ }
\{ {
gregorio_add_texverb_as_note(&current_note,
gregorio_strdup("\\hbox to 0pt{"), GRE_TEXVERB_ELEMENT,
@@ -444,88 +814,73 @@ static __inline void add_alteration(const gregorio_type type) {
gregorio_strdup("\\hss%\n}%\n\\GreNoBreak\\relax "),
GRE_TEXVERB_ELEMENT, &notes_lloc);
}
-[a-m]\+ {
+[a-np]\+ {
gregorio_add_manual_custos_as_note(&current_note,
pitch_letter_to_height(gabc_notes_determination_text[0]),
&notes_lloc);
}
[\t\r\n]+ /* ignore ends of line and tabs */;
+z0 {
+ gregorio_add_custo_as_note(&current_note, &notes_lloc);
+ }
z {
- gregorio_add_end_of_line_as_note(&current_note, GRE_END_OF_LINE,
+ gregorio_add_end_of_line_as_note(&current_note, false, false, false,
&notes_lloc);
}
-z0 {
- gregorio_add_custo_as_note(&current_note, &notes_lloc);
+z\+ {
+ gregorio_add_end_of_line_as_note(&current_note, false, true, true,
+ &notes_lloc);
}
-Z {
- gregorio_add_end_of_line_as_note(&current_note, GRE_END_OF_PAR,
+z- {
+ gregorio_add_end_of_line_as_note(&current_note, false, true, false,
&notes_lloc);
}
-(c|f)[1-4] {
- if (gabc_notes_determination_text[0]=='c') {
- gregorio_add_clef_change_as_note(&current_note, GRE_C_KEY_CHANGE,
- gabc_notes_determination_text[1], &notes_lloc);
- } else {
- gregorio_add_clef_change_as_note(&current_note, GRE_F_KEY_CHANGE,
- gabc_notes_determination_text[1], &notes_lloc);
- }
+Z {
+ gregorio_add_end_of_line_as_note(&current_note, true, false, false,
+ &notes_lloc);
}
-(cb|fb)[1-4] {
- if (gabc_notes_determination_text[0]=='c') {
- gregorio_add_clef_change_as_note(&current_note,
- GRE_C_KEY_CHANGE_FLATED, gabc_notes_determination_text[2],
- &notes_lloc);
- } else {
- gregorio_add_clef_change_as_note(&current_note,
- GRE_F_KEY_CHANGE_FLATED, gabc_notes_determination_text[2],
- &notes_lloc);
- }
+Z\+ {
+ gregorio_add_end_of_line_as_note(&current_note, true, true, true,
+ &notes_lloc);
}
-` {
- add_bar_as_note(B_VIRGULA);
+Z- {
+ gregorio_add_end_of_line_as_note(&current_note, true, true, false,
+ &notes_lloc);
}
-, {
- add_bar_as_note(B_DIVISIO_MINIMA);
+[cf][1-5] {
+ gregorio_add_clef_as_note(&current_note,
+ letter_to_clef(gabc_notes_determination_text[0]),
+ parse_clef_line(gabc_notes_determination_text[1]), false,
+ &notes_lloc);
}
-,1 {
- add_bar_as_note(B_DIVISIO_MINOR_D1);
+[cf]b[1-5] {
+ gregorio_add_clef_as_note(&current_note,
+ letter_to_clef(gabc_notes_determination_text[0]),
+ parse_clef_line(gabc_notes_determination_text[2]), true,
+ &notes_lloc);
}
-,2 {
- add_bar_as_note(B_DIVISIO_MINOR_D2);
+@[cf][1-5] {
+ gregorio_add_secondary_clef_to_note(current_note,
+ letter_to_clef(gabc_notes_determination_text[1]),
+ parse_clef_line(gabc_notes_determination_text[2]), false);
}
-,3 {
- add_bar_as_note(B_DIVISIO_MINOR_D3);
+@[cf]b[1-5] {
+ gregorio_add_secondary_clef_to_note(current_note,
+ letter_to_clef(gabc_notes_determination_text[1]),
+ parse_clef_line(gabc_notes_determination_text[3]), true);
}
-,4 {
- add_bar_as_note(B_DIVISIO_MINOR_D4);
+` {
+ add_bar_as_note(B_VIRGULA);
}
-,5 {
- add_bar_as_note(B_DIVISIO_MINOR_D5);
+, {
+ add_bar_as_note(B_DIVISIO_MINIMA);
}
-,6 {
- add_bar_as_note(B_DIVISIO_MINOR_D6);
+[,;][1-8] {
+ add_bar_as_note(parse_dominican_bar(gabc_notes_determination_text[1]));
}
; {
add_bar_as_note(B_DIVISIO_MINOR);
}
-;1 {
- add_bar_as_note(B_DIVISIO_MINOR_D1);
- }
-;2 {
- add_bar_as_note(B_DIVISIO_MINOR_D2);
- }
-;3 {
- add_bar_as_note(B_DIVISIO_MINOR_D3);
- }
-;4 {
- add_bar_as_note(B_DIVISIO_MINOR_D4);
- }
-;5 {
- add_bar_as_note(B_DIVISIO_MINOR_D5);
- }
-;6 {
- add_bar_as_note(B_DIVISIO_MINOR_D6);
- }
: {
add_bar_as_note(B_DIVISIO_MAIOR);
}
@@ -533,13 +888,16 @@ Z {
add_bar_as_note(B_DIVISIO_FINALIS);
}
r {
- gregorio_change_shape(current_note, S_PUNCTUM_CAVUM);
+ gregorio_change_shape(current_note, S_PUNCTUM_CAVUM,
+ legacy_oriscus_orientation);
}
R {
- gregorio_change_shape(current_note, S_LINEA_PUNCTUM);
+ gregorio_change_shape(current_note, S_LINEA_PUNCTUM,
+ legacy_oriscus_orientation);
}
r0 {
- gregorio_change_shape(current_note, S_LINEA_PUNCTUM_CAVUM);
+ gregorio_change_shape(current_note, S_LINEA_PUNCTUM_CAVUM,
+ legacy_oriscus_orientation);
}
r1 {
gregorio_add_special_sign(current_note, _ACCENTUS);
@@ -556,74 +914,97 @@ r4 {
r5 {
gregorio_add_special_sign(current_note, _SEMI_CIRCULUS_REVERSUS);
}
-[a-mA-M]x {
- add_alteration(GRE_FLAT);
+x {
+ gregorio_change_shape(current_note, S_FLAT, legacy_oriscus_orientation);
}
-[a-mA-M]# {
- add_alteration(GRE_SHARP);
+# {
+ gregorio_change_shape(current_note, S_SHARP,
+ legacy_oriscus_orientation);
}
-[a-mA-M]y {
- add_alteration(GRE_NATURAL);
+y {
+ gregorio_change_shape(current_note, S_NATURAL,
+ legacy_oriscus_orientation);
+ }
+!?\/0 {
+ gregorio_add_space_as_note(&current_note, SP_HALF_SPACE, NULL,
+ &notes_lloc);
}
\/ {
- gregorio_add_space_as_note(&current_note, SP_NEUMATIC_CUT, &notes_lloc);
+ gregorio_add_space_as_note(&current_note, SP_NEUMATIC_CUT, NULL,
+ &notes_lloc);
+ }
+\//\/\[ {
+ gregorio_add_space_as_note(&current_note, SP_NEUMATIC_CUT, NULL,
+ &notes_lloc);
}
\/\/ {
- gregorio_add_space_as_note(&current_note, SP_LARGER_SPACE, &notes_lloc);
+ gregorio_add_space_as_note(&current_note, SP_LARGER_SPACE, NULL,
+ &notes_lloc);
}
\ {
- gregorio_add_space_as_note(&current_note, SP_GLYPH_SPACE, &notes_lloc);
+ gregorio_add_space_as_note(&current_note, SP_GLYPH_SPACE, NULL,
+ &notes_lloc);
}
!\/ {
- gregorio_add_space_as_note(&current_note, SP_NEUMATIC_CUT_NB,
+ gregorio_add_space_as_note(&current_note, SP_NEUMATIC_CUT_NB, NULL,
+ &notes_lloc);
+ }
+!\//\/\[ {
+ gregorio_add_space_as_note(&current_note, SP_NEUMATIC_CUT_NB, NULL,
&notes_lloc);
}
!\/\/ {
- gregorio_add_space_as_note(&current_note, SP_LARGER_SPACE_NB,
+ gregorio_add_space_as_note(&current_note, SP_LARGER_SPACE_NB, NULL,
&notes_lloc);
}
!\ {
- gregorio_add_space_as_note(&current_note, SP_GLYPH_SPACE_NB,
+ gregorio_add_space_as_note(&current_note, SP_GLYPH_SPACE_NB, NULL,
&notes_lloc);
}
!/[^\/ ] {
- gregorio_add_space_as_note(&current_note, SP_ZERO_WIDTH, &notes_lloc);
+ gregorio_add_space_as_note(&current_note, SP_ZERO_WIDTH, NULL,
+ &notes_lloc);
}
= {
- gregorio_change_shape(current_note, S_LINEA);
+ gregorio_change_shape(current_note, S_LINEA,
+ legacy_oriscus_orientation);
}
-[a-mA-M]vv {
+[a-npA-NP]vv {
lex_add_note(0, S_BIVIRGA, _NO_SIGN, L_NO_LIQUESCENTIA);
}
-[a-mA-M]vvv {
+[a-npA-NP]vvv {
lex_add_note(0, S_TRIVIRGA, _NO_SIGN, L_NO_LIQUESCENTIA);
}
-[a-mA-M]VV {
+[a-npA-NP]VV {
lex_add_note(0, S_BIVIRGA, _NO_SIGN, L_NO_LIQUESCENTIA);
}
-[a-mA-M]VVV {
+[a-npA-NP]VVV {
lex_add_note(0, S_TRIVIRGA, _NO_SIGN, L_NO_LIQUESCENTIA);
}
-[a-mA-M]ss {
+[a-npA-NP]ss {
lex_add_note(0, S_DISTROPHA, _NO_SIGN, L_NO_LIQUESCENTIA);
}
-[a-mA-M]ss(\<|\>) {
- lex_add_note(0, S_DISTROPHA, _NO_SIGN, L_AUCTA);
+[a-npA-NP]ss(\<|\>) {
+ lex_add_note(0, S_DISTROPHA, _NO_SIGN, L_AUCTUS_ASCENDENS);
}
-[a-mA-M]sss {
+[a-npA-NP]sss {
lex_add_note(0, S_TRISTROPHA, _NO_SIGN, L_NO_LIQUESCENTIA);
}
-[a-mA-M]sss(\<|\>) {
- lex_add_note(0, S_TRISTROPHA, _NO_SIGN, L_AUCTA);
+[a-npA-NP]sss(\<|\>) {
+ lex_add_note(0, S_TRISTROPHA, _NO_SIGN, L_AUCTUS_ASCENDENS);
}
-[a-mA-M] {
+[a-npA-NP] {
lex_add_note(0, punctum(gabc_notes_determination_text[0]), _NO_SIGN,
L_NO_LIQUESCENTIA);
}
--[a-mA-M] {
+-[a-npA-NP] {
lex_add_note(1, punctum(gabc_notes_determination_text[1]), _NO_SIGN,
L_INITIO_DEBILIS);
}
+@[a-npA-NP] {
+ lex_add_note(1, punctum(gabc_notes_determination_text[1]), _NO_SIGN,
+ L_FUSED);
+ }
\'[01]? {
add_sign(_V_EPISEMA);
}
@@ -634,37 +1015,65 @@ _[0-5]* {
add_sign(_PUNCTUM_MORA);
}
~ {
- gregorio_add_liquescentia(current_note, L_DEMINUTUS);
+ gregorio_add_tail_liquescentia(current_note, L_DEMINUTUS,
+ legacy_oriscus_orientation);
}
> {
- gregorio_add_liquescentia(current_note, L_AUCTUS_DESCENDENS);
+ gregorio_add_tail_liquescentia(current_note, L_AUCTUS_DESCENDENS,
+ legacy_oriscus_orientation);
}
\< {
- gregorio_add_liquescentia(current_note, L_AUCTUS_ASCENDENS);
+ gregorio_add_tail_liquescentia(current_note, L_AUCTUS_ASCENDENS,
+ legacy_oriscus_orientation);
}
q {
- gregorio_change_shape(current_note, S_QUADRATUM);
+ gregorio_change_shape(current_note, S_QUADRATUM,
+ legacy_oriscus_orientation);
}
o {
- gregorio_change_shape(current_note, S_ORISCUS);
+ gregorio_change_shape(current_note, legacy_oriscus_orientation
+ ? S_ORISCUS_ASCENDENS : S_ORISCUS_UNDETERMINED,
+ legacy_oriscus_orientation);
}
O {
- gregorio_change_shape(current_note, S_ORISCUS_SCAPUS);
+ gregorio_change_shape(current_note, S_ORISCUS_SCAPUS,
+ legacy_oriscus_orientation);
}
w {
- gregorio_change_shape(current_note, S_QUILISMA);
+ gregorio_change_shape(current_note, S_QUILISMA,
+ legacy_oriscus_orientation);
}
W {
- gregorio_change_shape(current_note, S_QUILISMA_QUADRATUM);
+ gregorio_change_shape(current_note, S_QUILISMA_QUADRATUM,
+ legacy_oriscus_orientation);
}
v {
- gregorio_change_shape(current_note, S_VIRGA);
+ gregorio_change_shape(current_note, S_VIRGA,
+ legacy_oriscus_orientation);
}
V {
- gregorio_change_shape(current_note, S_VIRGA_REVERSA);
+ gregorio_change_shape(current_note, S_VIRGA_REVERSA,
+ legacy_oriscus_orientation);
}
s {
- gregorio_change_shape(current_note, S_STROPHA);
+ gregorio_change_shape(current_note, S_STROPHA,
+ legacy_oriscus_orientation);
+ }
+\[hl:1\] {
+ current_note->supposed_high_ledger_line = true;
+ current_note->explicit_high_ledger_line = true;
+ }
+\[hl:0\] {
+ current_note->supposed_high_ledger_line = false;
+ current_note->explicit_high_ledger_line = true;
+ }
+\[ll:1\] {
+ current_note->supposed_low_ledger_line = true;
+ current_note->explicit_low_ledger_line = true;
+ }
+\[ll:0\] {
+ current_note->supposed_low_ledger_line = false;
+ current_note->explicit_low_ledger_line = true;
}
. {
gregorio_messagef("det_notes_from_string", VERBOSITY_ERROR, 0,
@@ -675,7 +1084,7 @@ s {
%%
gregorio_note *gabc_det_notes_from_string(char *str, char *newmacros[10],
- gregorio_scanner_location *loc)
+ gregorio_scanner_location *loc, const gregorio_score *const score)
{
int i;
YY_BUFFER_STATE buf;
@@ -688,6 +1097,10 @@ gregorio_note *gabc_det_notes_from_string(char *str, char *newmacros[10],
notes_lloc.last_column = loc->first_column;
notes_lloc.last_offset = loc->first_offset;
+ staff_lines = score->staff_lines;
+ highest_pitch = score->highest_pitch;
+ legacy_oriscus_orientation = score->legacy_oriscus_orientation;
+
/* a small optimization could uccur here: we could do it only once at the
* beginning of the score, not at each syllable */
for (i = 0; i < 10; i++) {