diff options
author | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2015-12-09 22:20:21 +0000 |
---|---|---|
committer | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2015-12-09 22:20:21 +0000 |
commit | fbfb4e16cc7761a5aefcae7cacf662fec7092c92 (patch) | |
tree | 0a1f90f31434d7c8fc766c97df33cb3e2456ef75 /Build/source/texk/gregorio/gregorio-src/src/gabc/gabc-score-determination.l | |
parent | b4c906f1397a603ffc06957cb835ddd687c8fe2b (diff) |
Import Gregorio-4.0.0.
git-svn-id: svn://tug.org/texlive/trunk@39063 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/gregorio/gregorio-src/src/gabc/gabc-score-determination.l')
-rw-r--r-- | Build/source/texk/gregorio/gregorio-src/src/gabc/gabc-score-determination.l | 427 |
1 files changed, 427 insertions, 0 deletions
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..1001a2f72a6 --- /dev/null +++ b/Build/source/texk/gregorio/gregorio-src/src/gabc/gabc-score-determination.l @@ -0,0 +1,427 @@ +%{ +/* + * 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-2015 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 <http://www.gnu.org/licenses/>. + */ + +#include "config.h" +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include "struct.h" +#include "messages.h" +#include "support.h" + +#include "gabc.h" +#include "gabc-score-determination.h" +#include "gabc-score-determination-y.h" + +static unsigned char style_stack = 0; + +#define YY_NO_INPUT + +#define YY_INPUT(buf,result,max_size) \ + if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) { \ + int c = '*'; \ + size_t 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 style +%x verb +%x comments +%x inicomments +%x alt + +%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. */ + +%% +<INITIAL>^(\xBB|\xEF|\xBF)* { + /* BOM written by a lot of windows softwares when they write UTF-8 */ + } +<INITIAL>^[\n\r]+ { + /* ignoring empty lines */ + } +<INITIAL>^[\%#] { + BEGIN(inicomments); + } +<inicomments>(\n|\r)+ { + BEGIN(INITIAL); + } +<inicomments>[^\n\r]* { + /* ignored */ + } +<INITIAL>:(\ )? { + BEGIN(attribute); + return COLON; + } +<attribute>[^;\n\r]*(;[^;\n\r]+)*([\n\r]+[^;]*(;[^;]+)*)? { + gabc_score_determination_lval.text = + gregorio_strdup(gabc_score_determination_text); + return ATTRIBUTE; + } +<attribute>;(;|[\n\r]+) { + BEGIN(INITIAL); + return SEMICOLON; + } +<INITIAL>def-m[0-9] { + gabc_score_determination_lval.character = gabc_score_determination_text[5]; + return DEF_MACRO; + } +<INITIAL>number-of-voices { + return NUMBER_OF_VOICES; + } +<INITIAL>name { + return NAME; + } +<INITIAL>score-copyright { + return SCORE_COPYRIGHT; + } +<INITIAL>gabc-copyright { + return GABC_COPYRIGHT; + } +<INITIAL>office-part { + return OFFICE_PART; + } +<INITIAL>occasion { + return OCCASION; + } +<INITIAL>meter { + return METER; + } +<INITIAL>commentary { + return COMMENTARY; + } +<INITIAL>arranger { + return ARRANGER; + } +<INITIAL>gabc-version { + return GABC_VERSION; + } +<INITIAL>initial-style { + return INITIAL_STYLE; + } +<INITIAL>mode { + return MODE; + } +<INITIAL>annotation { + return ANNOTATION; + } +<INITIAL>author { + return AUTHOR; + } +<INITIAL>date { + return DATE; + } +<INITIAL>manuscript { + return MANUSCRIPT; + } +<INITIAL>manuscript-reference { + return MANUSCRIPT_REFERENCE; + } +<INITIAL>manuscript-storage-place { + return MANUSCRIPT_STORAGE_PLACE; + } +<INITIAL>book { + return BOOK; + } +<INITIAL>transcriber { + return TRANSCRIBER; + } +<INITIAL>generated-by { + return GENERATED_BY; + } +<INITIAL>centering-scheme { + return CENTERING_SCHEME; + } +<INITIAL>language { + return LANGUAGE; + } +<INITIAL>transcription-date { + return TRANSCRIPTION_DATE; + } +<INITIAL>style { + return STYLE; + } +<INITIAL>virgula-position { + return VIRGULA_POSITION; + } +<INITIAL>gregoriotex-font { + return GREGORIOTEX_FONT; + } +<INITIAL>nabc-lines { + return NABC_LINES; + } +<INITIAL>user-notes { + return USER_NOTES; + } +<INITIAL>--(.*) { + return VOICE_CHANGE; + } +<INITIAL>%(%)*(\n|\r)+ { + BEGIN(score); + return END_OF_DEFINITIONS; + } +<INITIAL>. { + gregorio_messagef("det_score", VERBOSITY_ERROR, 0, + _("unrecognized character: \"%c\" in definition part"), + gabc_score_determination_text[0]); + } +<score>[^\{\}\(\[\]<%]+ { + gabc_score_determination_lval.text = + gregorio_strdup(gabc_score_determination_text); + return CHARACTERS; + } +<score,style><i> { + BEGIN(style); + style_stack ++; + return I_BEGINNING; + } +<score,style><nlba> { + return BNLBA; + } +<score,style><\/nlba> { + return ENLBA; + } +<style><\/i> { + style_stack --; + if (style_stack == 0) { + BEGIN(score); + } + return I_END; + } +<score,style><tt> { + BEGIN(style); + style_stack ++; + return TT_BEGINNING; + } +<style><\/tt> { + style_stack --; + if (style_stack == 0) { + BEGIN(score); + } + return TT_END; + } +<score,style><ul> { + BEGIN(style); + style_stack ++; + return UL_BEGINNING; + } +<style><\/ul> { + style_stack --; + if (style_stack == 0) { + BEGIN(score); + } + return UL_END; + } +<score,style><c> { + BEGIN(style); + style_stack ++; + return C_BEGINNING; + } +<style><\/c> { + style_stack --; + if (style_stack == 0) { + BEGIN(score); + } + return C_END; + } +<score,style><b> { + BEGIN(style); + style_stack ++; + return B_BEGINNING; + } +<style><\/b> { + style_stack --; + if (style_stack == 0) { + BEGIN(score); + } + return B_END; + } +<score,style><sc> { + BEGIN(style); + style_stack ++; + return SC_BEGINNING; + } +<style><\/sc> { + style_stack --; + if (style_stack == 0) { + BEGIN(score); + } + return SC_END; + } +<score,style><sp> { + BEGIN(style); + style_stack ++; + return SP_BEGINNING; + } +<style><\/sp> { + style_stack --; + if (style_stack == 0) { + BEGIN(score); + } + return SP_END; + } +<style>[^<\{\}]* { + gabc_score_determination_lval.text = + gregorio_strdup(gabc_score_determination_text); + return CHARACTERS; + } +<score>\% { + BEGIN(comments); + } +<comments>(\n|\r)+ { + BEGIN(score); + } +<comments>[^\n\r]* { + /* ignored */ + } +<style,score><v> { + BEGIN(verb); + return VERB_BEGINNING; + } +<verb><\/v> { + if (style_stack == 0) { + BEGIN(score); + } else { + BEGIN(style); + } + return VERB_END; + } +<verb>[^<]* { + gabc_score_determination_lval.text = + gregorio_strdup(gabc_score_determination_text); + return CHARACTERS; + } +<verb,style,score,alt>< { + gabc_score_determination_lval.text = + gregorio_strdup(gabc_score_determination_text); + return CHARACTERS; + } +<score,style>\{ { + return CENTER_BEGINNING; + } +<score,style>\} { + return CENTER_END; + } +<score><alt> { + BEGIN(alt); + return ALT_BEGIN; + } +<alt>[^<]* { + gabc_score_determination_lval.text = + gregorio_strdup(gabc_score_determination_text); + return CHARACTERS; + } +<alt><\/alt> { + BEGIN(score); + return ALT_END; + } +<score><eu> { + return EUOUAE_B; + } +<score><\/eu> { + return EUOUAE_E; + } +<score>\[\/] { + return TRANSLATION_CENTER_END; + } +<score>\[ { + return TRANSLATION_BEGINNING; + } +<score>\] { + return TRANSLATION_END; + } +<score>\( { + BEGIN(notes); + return OPENING_BRACKET; + } +<notes>[^&|\)]* { + gabc_score_determination_lval.text = + gregorio_strdup(gabc_score_determination_text); + return NOTES; + } +<notes>& { + return VOICE_CUT; + } +<notes>\| { + return NABC_CUT; + } +<notes>\) { + BEGIN(score); + return CLOSING_BRACKET; + } +<notes>\)(\ |\t|\n|\r)+ { + BEGIN(score); + return CLOSING_BRACKET_WITH_SPACE; + } +%% + |