%option warn
%x incl
-%x header
%x lyrics
%x notes
%x quote
AA {A}|_
N [0-9]
AN {AA}|{N}
-PUNCT [?!,.:;']
+PUNCT [?!,.:']
ACCENT \\[`'"^]
-NATIONAL [\241-\377]
+NATIONAL [\001-\006\021-\027\031\036\200-\377]
TEX {AA}|-|{PUNCT}|{ACCENT}|{NATIONAL}
-
WORD {A}{AN}*
ALPHAWORD {A}+
INT -?{N}+
BLACK [^ \n\t\f]
RESTNAME [rs]
NOTECOMMAND \\{A}+
-LYRICS ({AA}|{NATIONAL})[^0-9 \t\n\f]*
+LYRICS ({AA}|{TEX})[^0-9 \t\n\f]*
+ESCAPED [nt\\'"]
%%
yyterminate (); // can't move this, since it actually rets a YY_NULL
}
}
-<header>{
- [\{\}] {
- return YYText ()[0];
- }
- ^{WORD} {
- String s=YYText ();
- yylval.string = new String (s);
- return FIELDNAME;
- }
- {HORIZONTALWHITE}+{BLACK}.*\n {
- String s=YYText ();
- strip_leading_white (s);
- strip_trailing_white (s);
- yylval.string = new String (s);
- return RECORDLINE;
- }
- {WHITE}* {
- }
- . {
- return YYText ()[0];
- }
-}
<notes,INITIAL,lyrics>\\include {
start_quote ();
}
<quote>{
- \\\\ {
- *yylval.string += '\\';
- }
- \\\" {
- *yylval.string +='\"';
+ \\{ESCAPED} {
+ *yylval.string += escaped_char(YYText()[1]);
}
- [^"]+ {
+ [^\\"]+ {
*yylval.string += YYText ();
}
\" {
yy_pop_state ();
return STRING;
}
+ . {
+ *yylval.string += YYText ();
+ }
}
<lyrics>{
return YY_START == lyrics;
}
-void
-My_lily_lexer::push_header_state ()
-{
- yy_push_state (header);
-}
-
-void strip_trailing_white (String&s)
+void
+strip_trailing_white (String&s)
{
int i=0;
for (; i < s.length_i (); i++)
s = s.nomid_str (0, i);
}
-void strip_leading_white (String&s)
+
+void
+strip_leading_white (String&s)
{
int i=s.length_i ();
while (i--)
break;
s = s.left_str (i+1);
-
}