1 %{ // -*-Fundamental-*-
6 #include "string-convert.hh"
12 #include "input-score.hh"
13 #include "parseconstruct.hh"
15 #include "identparent.hh"
24 %option yyclass="My_flex_lexer"
41 TEX {AA}|-|{PUNCT}|{ACCENT}|{NATIONAL}
49 PITCHMOD ['`]*{OPTSIGN}
65 yy_push_state(lyrics);
69 const char *s = YYText();
70 yylval.string = new String (s);
71 mtor << "rest:"<< yylval.string;
76 return ret_notename(p, YYText(), -1);
81 return ret_notename(p, YYText(), 0);
84 <notes>{NOTECOMMAND} {
85 String c = YYText() +1;
86 mtor << "\\word: " << YYText()+1<<eol;
87 int l = lookup_keyword(c);
90 Identifier * id = lookup_identifier(c);
93 return id->token_code_i_;
95 String *sp = new String( c);
101 const char *s = YYText();
102 mtor << "pitchmod:"<< YYText()<<eol;
103 yylval.string = new String (s);
107 yylval.i = strlen(YYText());
111 yylval.i = String_convert::dec2_i( String( YYText() ) );
123 String s (YYText()+1);
124 s = s.left_str(s.length_i()-1);
125 yylval.string = new String(s);
129 return yylval.c = YYText()[0];
133 yy_push_state(quote);
136 yylval.string = new String (YYText());
139 mtor << "quoted 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<<eol;
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());//huh?
163 /* and skip identifiers...
164 Identifier * id = lookup_identifier(c);
169 String *sp = new String( c);
176 String s (YYText()+1);
177 s = s.left_str(s.length_i()-1);
178 yylval.string = new String(s);
184 while ((i=s.index_i("_")) != -1) // change word binding "_" to " "
185 *(s.ch_l() + i) = ' ';
186 if ((i=s.index_i("\\,")) != -1) // change "\," to TeX's "\c "
188 *(s.ch_l() + i + 1) = 'c';
189 s = s.left_str(i+2) + " " + s.right_str(s.length_i()-i-2);
191 yylval.string = new String(s);
203 <lyrics>[()\[\]|/.^>_-] {
204 return yylval.c = YYText()[0];
216 yyterminate(); // can't move this, since it actually rets a YY_NULL
223 <incl>[ \t]* { /* eat the whitespace */ }
224 <incl>\"[^"]*\"+ { /* got the include file name */
225 String s (YYText()+1);
226 s = s.left_str(s.length_i()-1);
227 defined_ch_c_l = here_ch_c_l() - String( YYText() ).length_i() - 1;
234 mtor << "word: " << YYText()<<eol;
236 int l = lookup_keyword(c);
239 Identifier * id = lookup_identifier(c);
244 String *sp = new String( c);
245 mtor << "new id: " << *sp << eol;
252 int cnv=sscanf (YYText(), "%lf", &r);
254 mtor << "REAL" << r<<'\n';
265 char c = YYText()[0];
266 mtor << "misc char" <<c<<"\n";
277 error( String( "illegal character: " ) + String( YYText()[0] ), here_ch_c_l() );