1 %{ // -*-Fundamental-*-
14 sstack<istream *> include_stack;
15 static int last_print;
16 const int DOTPRINT=50; // every 50 lines dots
31 NOTENAMEI A|B|C|D|E|F|G|As|Bes|Ces|Des|Es|Fes|Ges|Ais|Bis|Cis|Dis|Eis|Fis|Gis
32 NOTENAMEII a|b|c|d|e|f|g|as|bes|ces|des|es|fes|ges|ais|bis|cis|dis|eis|fis|gis
33 NOTENAMEIII Ases|Beses|Ceses|Deses|Eses|Feses|Geses|Aisis|Bisis|Cisis|Disis|Eisis|Fisis|Gisis
34 NOTENAMEIIII ases|beses|ceses|deses|eses|feses|geses|aisis|bisis|cisis|disis|eisis|fisis|gisis
36 NOTENAME {NOTENAMEI}|{NOTENAMEII}|{NOTENAMEIII}|{NOTENAMEIIII}
37 PITCH ['`]*{OPTSIGN}{NOTENAME}
40 FULLNOTE {PITCH}{DURATION}?
41 WORD [a-zA-Z][a-zA-Z0-9_]+
42 REAL -?[0-9]+(\.[0-9]*)?
50 <notes>{NOTECOMMAND} {
51 String c = YYText() +1;
53 int l = lookup_keyword(c);
56 Identifier * id = lookup_identifier(c);
61 String *sp = new String( c);
62 mtor << "new id: " << *sp;
68 const char *s = YYText();
69 yylval.string = new String (s);
70 mtor << "rest:"<< yylval.string;
74 const char *s = YYText();
75 yylval.string = new String (s);
76 mtor << "pitch:"<< *yylval.string;
80 yylval.string = new String (YYText());
99 <notes>[\[)] { /* parens () are NO mistake */
100 yylval.c = YYText()[0];
101 return OPEN_REQUEST_PARENS;
103 <notes>[\](] { /* parens () are NO mistake */
104 yylval.c = YYText()[0];
105 return CLOSE_REQUEST_PARENS;
109 String s("lexer error: illegal character found: " + String(YYText()));
117 yylval.string = new String (YYText());
130 int l = lookup_keyword(c);
133 Identifier * id = lookup_identifier(c);
138 String *sp = new String( c);
139 mtor << "new id: " << *sp;
141 return NEWIDENTIFIER;
146 int cnv=sscanf (YYText(), "%lf", &r);
148 mtor << "token (REAL)" << r;
159 char c = YYText()[0];
160 mtor << "misc char" <<c<<"\n";
171 error("lexer error: illegal character '"+String(YYText()[0])+
178 yyFlexLexer *lexer=0;
186 // set the new input to s, remember old file.
195 newin = new ifstream( s ); //
198 error("cant open " + s);
199 cout << "["<<s<<flush;
201 include_stack.push(newin);
204 lexer = new yyFlexLexer;
205 lexer->set_debug( !monitor.silence("Lexer"));
208 lexer->switch_streams(newin);
212 // pop the inputstack.
217 istream *closing= include_stack.pop();
221 cout << "]" << flush;
223 if (include_stack.empty()) {
226 lexer->switch_streams(include_stack.top());
232 return lexer->yylex();
236 yyerror(const char *s)
238 *mlog << "error in line " << lexer->lineno() << ": " << s << '\n';