1 %{ // -*-Fundamental-*-
6 #include "string-convert.hh"
11 #include "input-score.hh"
12 #include "parseconstruct.hh"
14 #include "identparent.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}
53 PITCHMOD ['`]*{OPTSIGN}
67 yy_push_state(lyrics);
71 const char *s = YYText();
72 yylval.string = new String (s);
73 mtor << "rest:"<< yylval.string;
77 String str = YYText();
78 mtor << "word: " << str<< eol;
79 Identifier * id = lookup_identifier(str);
82 return id->token_code_i_;
85 yylval.string=new String( str );
88 <notes>{NOTECOMMAND} {
89 String c = YYText() +1;
90 mtor << "\\word: " << YYText()+1<<eol;
91 int l = lookup_keyword(c);
94 Identifier * id = lookup_identifier(c);
97 return id->token_code_i_;
99 String *sp = new String( c);
105 yylval.i = strlen(YYText());
109 yylval.i = String_convert::dec2_i( String( YYText() ) );
124 return yylval.c = YYText()[0];
132 *yylval.string += YYText();
135 mtor << "quoted string: `" << *yylval.string << "'\n";
144 yylval.i = strlen(YYText());
148 yylval.i = String_convert::dec2_i( String( YYText() ) );
151 <lyrics>{NOTECOMMAND} {
152 String c = YYText() +1;
153 mtor << "\\word: " << YYText()+1<<eol;
154 int l = lookup_keyword(c);
158 /* let's try passing tex's typesetting macros like \ss \alpha \c */
159 String* str_p = new String(YYText());
161 mtor << "\\word: `" << *str_p << "'\n";
164 /* and skip identifiers...
165 Identifier * id = lookup_identifier(c);
170 String *sp = new String( c);
181 while ((i=s.index_i("_")) != -1) // change word binding "_" to " "
182 *(s.ch_l() + i) = ' ';
183 if ((i=s.index_i("\\,")) != -1) // change "\," to TeX's "\c "
185 *(s.ch_l() + i + 1) = 'c';
186 s = s.left_str(i+2) + " " + s.right_str(s.length_i()-i-2);
188 yylval.string = new String(s);
189 mtor << "lyric : `" << s << "'\n";
201 <lyrics>[()\[\]|/.^>_-] {
202 return yylval.c = YYText()[0];
214 yyterminate(); // can't move this, since it actually rets a YY_NULL
221 <incl>[ \t]* { /* eat the whitespace */ }
222 <incl>\"[^"]*\"+ { /* got the include file name */
223 String s (YYText()+1);
224 s = s.left_str(s.length_i()-1);
225 defined_ch_c_l = here_ch_c_l() - String( YYText() ).length_i() - 1;
232 mtor << "word: " << YYText()<<eol;
234 int l = lookup_keyword(c);
237 Identifier * id = lookup_identifier(c);
242 String *sp = new String( c);
243 mtor << "new id: " << *sp << eol;
250 int cnv=sscanf (YYText(), "%lf", &r);
252 mtor << "REAL" << r<<'\n';
263 char c = YYText()[0];
264 mtor << "misc char" <<c<<"\n";
275 error( String( "illegal character: " ) + String( YYText()[0] ), here_ch_c_l() );