1 %{ // -*-Fundamental-*-
6 #include "string-convert.hh"
11 #include "input-score.hh"
12 #include "parseconstruct.hh"
14 #include "identifier.hh"
16 #define start_quote() \
17 yy_push_state(quote);\
18 yylval.string = new String
28 %option yyclass="My_flex_lexer"
45 TEX {AA}|-|{PUNCT}|{ACCENT}|{NATIONAL}
66 <incl>[ \t]* { /* eat the whitespace */ }
67 <incl>\"[^"]*\"+ { /* got the include file name */
68 String s (YYText()+1);
69 s = s.left_str(s.length_i()-1);
70 defined_ch_c_l = here_ch_c_l() - String( YYText() ).length_i() - 1;
76 const char *s = YYText();
77 yylval.string = new String (s);
78 mtor << "rest:"<< yylval.string;
81 <notes,INITIAL>{ALPHAWORD} {
82 String str = YYText();
83 mtor << "word: `" << str<< "'\n";
84 Identifier * id = lookup_identifier(str);
87 return id->token_code_i_;
90 yylval.string=new String( str );
93 <notes,INITIAL>{NOTECOMMAND} {
94 String c = YYText() +1;
95 mtor << "\\word: `" << YYText()+1<<"'\n";
96 int l = lookup_keyword(c);
100 String *sp = new String( c);
106 yylval.i = strlen(YYText());
110 yylval.i = String_convert::dec2_i( String( YYText() ) );
125 return yylval.c = YYText()[0];
133 *yylval.string += YYText();
136 mtor << "quoted string: `" << *yylval.string << "'\n";
145 yylval.i = strlen(YYText());
149 yylval.i = String_convert::dec2_i( String( YYText() ) );
152 <lyrics>{NOTECOMMAND} {
153 String c = YYText() +1;
154 mtor << "\\word: `" << YYText()+1<<"'\n";
155 int l = lookup_keyword(c);
159 /* let's try passing tex's typesetting macros like \ss \alpha \c */
160 String* str_p = new String(YYText());
162 mtor << "\\word: `" << *str_p << "'\n";
165 /* and skip identifiers...
166 Identifier * id = lookup_identifier(c);
171 String *sp = new String( c);
182 while ((i=s.index_i("_")) != -1) // change word binding "_" to " "
183 *(s.ch_l() + i) = ' ';
184 if ((i=s.index_i("\\,")) != -1) // change "\," to TeX's "\c "
186 *(s.ch_l() + i + 1) = 'c';
187 s = s.left_str(i+2) + " " + s.right_str(s.length_i()-i-2);
189 yylval.string = new String(s);
190 mtor << "lyric : `" << s << "'\n";
202 <lyrics>[()\[\]|/.^>_-] {
203 return yylval.c = YYText()[0];
212 yyterminate(); // can't move this, since it actually rets a YY_NULL
216 int cnv=sscanf (YYText(), "%lf", &r);
218 mtor << "REAL" << r<<'\n';
229 char c = YYText()[0];
230 mtor << "misc char" <<c<<"\n";
241 error( String( "illegal character: " ) + String( YYText()[0] ), here_ch_c_l() );
248 My_flex_lexer::push_note_state()
250 yy_push_state(notes);
254 My_flex_lexer::push_lyric_state()
256 yy_push_state(lyrics);
259 My_flex_lexer::pop_state()