| 1 |
%{ |
| 2 |
/* |
| 3 |
* Gregorio is a program that translates gabc files to GregorioTeX |
| 4 |
* This file implements the vowel rule lexer. |
| 5 |
* |
| 6 |
* Copyright (C) 2015-2025 The Gregorio Project (see CONTRIBUTORS.md) |
| 7 |
* |
| 8 |
* This file is part of Gregorio. |
| 9 |
* |
| 10 |
* This program is free software: you can redistribute it and/or modify it |
| 11 |
* under the terms of the GNU General Public License as published by the Free |
| 12 |
* Software Foundation, either version 3 of the License, or (at your option) |
| 13 |
* any later version. |
| 14 |
* |
| 15 |
* This program is distributed in the hope that it will be useful, but WITHOUT |
| 16 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 17 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 18 |
* more details. |
| 19 |
* |
| 20 |
* You should have received a copy of the GNU General Public License along with |
| 21 |
* this program. If not, see <http://www.gnu.org/licenses/>. |
| 22 |
*/ |
| 23 |
|
| 24 |
#include "config.h" |
| 25 |
#include <stdio.h> |
| 26 |
#include <stdlib.h> |
| 27 |
#include <string.h> |
| 28 |
#include "struct.h" |
| 29 |
#include "messages.h" |
| 30 |
#include "support.h" |
| 31 |
|
| 32 |
#include "vowel.h" |
| 33 |
|
| 34 |
#include "vowel-rules.h" |
| 35 |
#include "vowel-rules-y.h" |
| 36 |
|
| 37 |
#define YY_NO_INPUT |
| 38 |
|
| 39 |
static __inline void save_lval(void) |
| 40 |
{ |
| 41 |
gregorio_vowel_rulefile_lval = |
| 42 |
gregorio_malloc(gregorio_vowel_rulefile_leng + 1); |
| 43 |
strncpy(gregorio_vowel_rulefile_lval, gregorio_vowel_rulefile_text, |
| 44 |
gregorio_vowel_rulefile_leng); |
| 45 |
gregorio_vowel_rulefile_lval[gregorio_vowel_rulefile_leng] = '\0'; |
| 46 |
} |
| 47 |
|
| 48 |
static __inline void invalid(void) |
| 49 |
{ |
| 50 |
gregorio_messagef("gregorio_vowel_rulefile_lex", VERBOSITY_WARNING, 0, |
| 51 |
_("invalid character in vowel file: %c"), |
| 52 |
*gregorio_vowel_rulefile_text); |
| 53 |
} |
| 54 |
%} |
| 55 |
|
| 56 |
%x chars |
| 57 |
%x lang |
| 58 |
%x langname |
| 59 |
|
| 60 |
%option stack |
| 61 |
%option pointer |
| 62 |
%option nounput |
| 63 |
%option noyy_push_state |
| 64 |
%option noyy_pop_state |
| 65 |
%option noyy_top_state |
| 66 |
%option align |
| 67 |
%option noread |
| 68 |
%option nomain |
| 69 |
%option noalways-interactive |
| 70 |
%option nonever-interactive |
| 71 |
%option prefix="gregorio_vowel_rulefile_" |
| 72 |
%option noyywrap |
| 73 |
%option 8bit |
| 74 |
|
| 75 |
%% |
| 76 |
|
| 77 |
<INITIAL>language { BEGIN(lang); return LANGUAGE; } |
| 78 |
<INITIAL>vowel { BEGIN(chars); return VOWEL; } |
| 79 |
<INITIAL>prefix { BEGIN(chars); return PREFIX; } |
| 80 |
<INITIAL>suffix { BEGIN(chars); return SUFFIX; } |
| 81 |
<INITIAL>secondary { BEGIN(chars); return SECONDARY; } |
| 82 |
<INITIAL>alias { BEGIN(lang); return ALIAS; } |
| 83 |
<*>; { BEGIN(INITIAL); return SEMICOLON; } |
| 84 |
<lang>to { return TO; } |
| 85 |
<lang>"[" { BEGIN(langname); } |
| 86 |
<langname>[^\]]+ { save_lval(); return NAME; } |
| 87 |
<langname>"]" { BEGIN(lang); } |
| 88 |
<chars>[^;,# \t\n\r\v\f]+ { save_lval(); return CHARACTERS; } |
| 89 |
<*>#[^\n\r]* { } |
| 90 |
<INITIAL>\xEF\xBB\xBF { } |
| 91 |
<*>[\ \t\n\r\v\f] { } |
| 92 |
<*>. { invalid(); return INVALID; } |
| 93 |
|
| 94 |
%% |
| 95 |
|