From ad547a6b5986815fda458221149728d9d9ab1d87 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Thu, 25 Feb 2021 19:22:25 +0000 Subject: restore Build,TODO from r57911 git-svn-id: svn://tug.org/texlive/trunk@57915 c570f23f-e606-0410-a88d-b1316a301751 --- .../src/gabc/gabc-score-determination.l | 430 +++++++++++++++++++++ 1 file changed, 430 insertions(+) create mode 100644 Build/source/texk/gregorio/gregorio-src/src/gabc/gabc-score-determination.l (limited to 'Build/source/texk/gregorio/gregorio-src/src/gabc/gabc-score-determination.l') diff --git a/Build/source/texk/gregorio/gregorio-src/src/gabc/gabc-score-determination.l b/Build/source/texk/gregorio/gregorio-src/src/gabc/gabc-score-determination.l new file mode 100644 index 00000000000..c0d68c1148f --- /dev/null +++ b/Build/source/texk/gregorio/gregorio-src/src/gabc/gabc-score-determination.l @@ -0,0 +1,430 @@ +%{ +/* + * Gregorio is a program that translates gabc files to GregorioTeX + * This file implements the score lexer. + * + * Gregorio score determination in gabc input. + * Copyright (C) 2006-2019 The Gregorio Project (see CONTRIBUTORS.md) + * + * This file is part of Gregorio. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + */ + +#include "config.h" +#include +#include +#include +#include "struct.h" +#include "messages.h" +#include "bool.h" +#include "support.h" + +#include "gabc.h" +#include "gabc-score-determination.h" +#include "gabc-score-determination-y.h" + +static bool eof_found = false; + +#define START_STYLE(STYLE) \ + if (*styles & SB_ ## STYLE) { \ + gregorio_messagef("gabc_score_determination_lex", VERBOSITY_ERROR, 0, \ + _("style already started: %s"), gabc_score_determination_text); \ + } else { \ + *styles ^= SB_ ## STYLE; \ + return STYLE ## _BEGIN; \ + } + +#define END_STYLE(STYLE) \ + if (*styles & SB_ ## STYLE) { \ + *styles ^= SB_ ## STYLE; \ + return STYLE ## _END; \ + } else { \ + gregorio_messagef("gabc_score_determination_lex", VERBOSITY_ERROR, 0, \ + _("style not started: %s"), gabc_score_determination_text); \ + } + +#define RETURN_CHARACTERS \ + gabc_score_determination_lval.text = \ + gregorio_strdup(gabc_score_determination_text); \ + return CHARACTERS + +#define RETURN_SPACE \ + gabc_score_determination_lval.text = gregorio_strdup(" "); \ + return CHARACTERS + +#define YY_NO_INPUT + +#define YY_INPUT(buf,result,max_size) \ + if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) { \ + int c = '*'; \ + int n; \ + for (n = 0; n < max_size \ + && (c = getc(gabc_score_determination_in)) != EOF \ + && c != '\n'; ++n ) { \ + buf[n] = (char) c; \ + } \ + if (c == '\n') { \ + buf[n++] = (char) c; \ + } \ + if (c == EOF && ferror(gabc_score_determination_in)) { \ + YY_FATAL_ERROR("input in flex scanner failed"); \ + } \ + result = n; \ + } else { \ + errno=0; \ + while ((result = fread(buf, 1, max_size, gabc_score_determination_in)) \ + == 0 && ferror(gabc_score_determination_in)) { \ + if (errno != EINTR) { \ + YY_FATAL_ERROR("input in flex scanner failed"); \ + break; \ + } \ + errno = 0; \ + clearerr(gabc_score_determination_in); \ + } \ + } \ + gabc_digest(buf, result) + +#define YY_USER_ACTION gabc_update_location(&gabc_score_determination_lloc, \ + gabc_score_determination_text, gabc_score_determination_leng); + +%} + +%x attribute +%x score +%x notes +%x sp +%x verb +%x comments +%x inicomments +%x alt +%x protrusion_value +%x protrusion_end + +%option stack +%option pointer +%option nounput +%option noyy_push_state +%option noyy_pop_state +%option noyy_top_state +%option align +%option noread +%option nomain +%option noalways-interactive +%option nonever-interactive +%option prefix="gabc_score_determination_" +%option noyywrap +%option 8bit + + +/* The expression for attribute below is rather messy because we allow +for (a) single-line values, ending with a semicolon at end of line or a +double semicolon, (b) multi-line values, which end at a double +semicolon. */ + +%% +^(\xBB|\xEF|\xBF)+ { + /* BOM written by a lot of windows softwares when they write UTF-8 */ + } +^[\n\r]+ { + /* ignoring empty lines */ + } +^[\%#] { + BEGIN(inicomments); + } +(\n|\r)+ { + BEGIN(INITIAL); + } +[^\n\r]+ { + /* ignored */ + } +:(\ )? { + BEGIN(attribute); + return COLON; + } +;;?[\n\r \t]*[\n\r] { + BEGIN(INITIAL); + return SEMICOLON; + } +[^;]+ { + gabc_score_determination_lval.text = + gregorio_strdup(gabc_score_determination_text); + return ATTRIBUTE; + } +; { + gabc_score_determination_lval.text = + gregorio_strdup(gabc_score_determination_text); + return ATTRIBUTE; +} +def-m[0-9] { + gabc_score_determination_lval.character = gabc_score_determination_text[5]; + return DEF_MACRO; + } +name { + gabc_score_determination_lval.text = + gregorio_strdup(gabc_score_determination_text); + return NAME; + } +score-copyright { + gabc_score_determination_lval.text = + gregorio_strdup(gabc_score_determination_text); + return SCORE_COPYRIGHT; + } +gabc-copyright { + gabc_score_determination_lval.text = + gregorio_strdup(gabc_score_determination_text); + return GABC_COPYRIGHT; + } +mode { + gabc_score_determination_lval.text = + gregorio_strdup(gabc_score_determination_text); + return MODE; + } +mode-modifier { + gabc_score_determination_lval.text = + gregorio_strdup(gabc_score_determination_text); + return MODE_MODIFIER; + } +mode-differentia { + gabc_score_determination_lval.text = + gregorio_strdup(gabc_score_determination_text); + return MODE_DIFFERENTIA; + } +annotation { + gabc_score_determination_lval.text = + gregorio_strdup(gabc_score_determination_text); + return ANNOTATION; + } +author { + gabc_score_determination_lval.text = + gregorio_strdup(gabc_score_determination_text); + return AUTHOR; + } +language { + gabc_score_determination_lval.text = + gregorio_strdup(gabc_score_determination_text); + return LANGUAGE; + } +staff-lines { + gabc_score_determination_lval.text = + gregorio_strdup(gabc_score_determination_text); + return STAFF_LINES; + } +nabc-lines { + gabc_score_determination_lval.text = + gregorio_strdup(gabc_score_determination_text); + return NABC_LINES; + } +oriscus-orientation { + gabc_score_determination_lval.text = + gregorio_strdup(gabc_score_determination_text); + return ORISCUS_ORIENTATION; + } +[A-Za-z0-9_]+(-[A-Za-z0-9_]+)* { + gabc_score_determination_lval.text = + gregorio_strdup(gabc_score_determination_text); + return OTHER_HEADER; + } +%%+(\n|\r)+ { + BEGIN(score); + return END_OF_DEFINITIONS; + } +. { + gregorio_messagef("det_score", VERBOSITY_ERROR, 0, + _("unrecognized character: \"%c\" in definition part"), + gabc_score_determination_text[0]); + } +[\n\r][\n\r \t]* { + RETURN_SPACE; + } +[^-,;:.\{\}\(\[\]<%\n\r]+ { + RETURN_CHARACTERS; + } +- { + return HYPHEN; + } +[,;:.] { + gabc_score_determination_lval.text = + gregorio_strdup(gabc_score_determination_text); + return PROTRUDING_PUNCTUATION; + } + { + return NLBA_B; + } +<\/nlba> { + return NLBA_E; + } + { + START_STYLE(I); + } +<\/i> { + END_STYLE(I); + } + { + START_STYLE(TT); + } +<\/tt> { + END_STYLE(TT); + } +
    { + START_STYLE(UL); + } +<\/ul> { + END_STYLE(UL); + } + { + START_STYLE(C); + } +<\/c> { + END_STYLE(C); + } + { + START_STYLE(B); + } +<\/b> { + END_STYLE(B); + } + { + START_STYLE(SC); + } +<\/sc> { + END_STYLE(SC); + } + { + START_STYLE(ELISION); + } +<\/e> { + END_STYLE(ELISION); + } + { + BEGIN(sp); + return SP_BEGIN; + } +<\/sp> { + BEGIN(score); + return SP_END; + } +[\n\r][\n\r \t]* { + RETURN_SPACE; + } +[^<\{\}\n\r]+ { + RETURN_CHARACTERS; + } +\% { + BEGIN(comments); + } +(\n|\r)+ { + BEGIN(score); + } +[^\n\r]+ { + /* ignored */ + } + { + BEGIN(verb); + return VERB_BEGIN; + } +<\/v> { + BEGIN(score); + return VERB_END; + } +[^<]+ { + RETURN_CHARACTERS; + } +< { + RETURN_CHARACTERS; + } +\{ { + return CENTER_BEGIN; + } +\} { + return CENTER_END; + } + { + BEGIN(alt); + return ALT_BEGIN; + } +<\/alt> { + BEGIN(score); + return ALT_END; + } + { + return EUOUAE_B; + } +<\/eu> { + return EUOUAE_E; + } +\[\/] { + return TRANSLATION_CENTER_END; + } +\[ { + return TRANSLATION_BEGIN; + } +\] { + return TRANSLATION_END; + } +<[\n\r \t]*clear[\n\r \t]*\/?[\n\r \t]*> { + return CLEAR; + } +<[\n\r \t]*pr[\n\r \t]*\/?[\n\r \t]*> { + return PROTRUSION; + } +<[\n\r \t]*pr[\n\r \t]*:[\n\r \t]* { + BEGIN(protrusion_value); + return PROTRUSION; + } +([0-9]*\.?[0-9]+|[0-9]+\.) { + BEGIN(protrusion_end); + gabc_score_determination_lval.text = + gregorio_strdup(gabc_score_determination_text); + return PROTRUSION_VALUE; + } +[\n\r \t]*\/?[\n\r \t]*> { + BEGIN(score); + return PROTRUSION_END; + } +\( { + BEGIN(notes); + return OPENING_BRACKET; + } +[^|\)]+ { + gabc_score_determination_lval.text = + gregorio_strdup(gabc_score_determination_text); + return NOTES; + } +\| { + return NABC_CUT; + } +\) { + BEGIN(score); + return CLOSING_BRACKET; + } +\)(\ |\t|\n|\r)+ { + BEGIN(score); + return CLOSING_BRACKET_WITH_SPACE; + } +<> { + if (!eof_found) { + eof_found = true; + return END_OF_FILE; + } else { + yyterminate(); + } + } +.|\n { + gregorio_messagef("gabc_score_determination_lex", VERBOSITY_ERROR, 0, + _("unrecognized character: \"%c\""), + gabc_score_determination_text[0]); + } +%% + -- cgit v1.2.3