summaryrefslogtreecommitdiff
path: root/Build/source/texk/gregorio/gregorio-src/src/vowel/vowel-rules.l
blob: a84ac0e66ff53dce01368963d334b53bb3f7de65 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
%{
/*
 * Gregorio is a program that translates gabc files to GregorioTeX
 * This file implements the vowel rule lexer.
 *
 * Copyright (C) 2015-2021 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 "vowel.h"

#include "vowel-rules.h"
#include "vowel-rules-y.h"

#define YY_NO_INPUT

static __inline void save_lval(void)
{
    gregorio_vowel_rulefile_lval =
            gregorio_malloc(gregorio_vowel_rulefile_leng + 1);
    strncpy(gregorio_vowel_rulefile_lval, gregorio_vowel_rulefile_text,
            gregorio_vowel_rulefile_leng);
    gregorio_vowel_rulefile_lval[gregorio_vowel_rulefile_leng] = '\0';
}

static __inline void invalid(void)
{
    gregorio_messagef("gregorio_vowel_rulefile_lex", VERBOSITY_WARNING, 0,
            _("invalid character in vowel file: %c"),
            *gregorio_vowel_rulefile_text);
}
%}

%x chars
%x lang
%x langname

%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="gregorio_vowel_rulefile_"
%option noyywrap
%option 8bit

%%

<INITIAL>language               { BEGIN(lang); return LANGUAGE; }
<INITIAL>vowel                  { BEGIN(chars); return VOWEL; }
<INITIAL>prefix                 { BEGIN(chars); return PREFIX; }
<INITIAL>suffix                 { BEGIN(chars); return SUFFIX; }
<INITIAL>secondary              { BEGIN(chars); return SECONDARY; }
<INITIAL>alias                  { BEGIN(lang); return ALIAS; }
<*>;                            { BEGIN(INITIAL); return SEMICOLON; }
<lang>to                        { return TO; }
<lang>"["                       { BEGIN(langname); }
<langname>[^\]]+                { save_lval(); return NAME; }
<langname>"]"                   { BEGIN(lang); }
<chars>[^;,# \t\n\r\v\f]+       { save_lval(); return CHARACTERS; }
<*>#[^\n\r]*                    { }
<INITIAL>\xEF\xBB\xBF           { }
<*>[\ \t\n\r\v\f]               { }
<*>.                            { invalid(); return INVALID; }

%%