3 #include "identparent.hh"
4 #include "associter.hh"
11 #include "notename.hh"
12 #include "sourcefile.hh"
13 #include "parseconstruct.hh"
15 static Keyword_ent the_key_tab[]={
22 "duration", DURATIONCOMMAND,
23 "geometric", GEOMETRIC,
31 "multivoice", MULTIVOICE,
32 "octave", OCTAVECOMMAND,
45 "symboltables", SYMBOLTABLES,
46 "notenames", NOTENAMES,
49 "textstyle", TEXTSTYLE,
50 "unitspace", UNITSPACE,
60 My_flex_lexer::ret_notename(int *p, String text, int octave_mod)
63 char const* ch_c_l = here_ch_c_l();
66 while ( ( *ch_c_l == ' ' ) || ( *ch_c_l == '\t' ) || ( *ch_c_l == '\n' ) )
71 lookup_notename(p[0], p[1], text);
73 mtor << "notename: "<< text <<eol;
77 error( String( "notename does not exist: " ) + YYText(), ch_c_l );
83 My_flex_lexer::My_flex_lexer()
85 keytable = new Keyword_table(the_key_tab);
86 the_id_tab = new Assoc<String, Identifier*>;
92 My_flex_lexer::lookup_keyword(String s)
94 return keytable->lookup(s);
98 My_flex_lexer::lookup_identifier(String s)
100 if (!the_id_tab->elt_query(s))
103 return (*the_id_tab)[s];
107 My_flex_lexer::here_ch_c_l()
109 return include_stack.top()->sourcefile_l_->ch_c_l() + yyin->tellg();
113 My_flex_lexer::add_identifier(Identifier*i)
115 delete lookup_identifier(i->name);
116 (*the_id_tab)[i->name] = i;
119 My_flex_lexer::~My_flex_lexer()
123 for (Assoc_iter<String,Identifier*> ai(*the_id_tab); ai.ok(); ai++) {
124 mtor << "deleting: " << ai.key()<<'\n';
131 My_flex_lexer::spot()const
133 return include_stack.top()->name + ": " + String( lineno() );
137 My_flex_lexer::LexerError(const char *s)
139 if (lexer->include_stack.empty()) {
140 *mlog << "error at EOF" << s << '\n';
142 char const* ch_c_l = here_ch_c_l();
145 while ( ( *ch_c_l == ' ' ) || ( *ch_c_l == '\t' ) || ( *ch_c_l == '\n' ) )
154 // set the new input to s, remember old file.
156 My_flex_lexer::new_input(String s)
158 if (!include_stack.empty()) {
159 include_stack.top()->line = lineno();
160 // should this be saved at all?
161 include_stack.top()->defined_ch_c_l_ = defined_ch_c_l;
164 Input_file *newin = new Input_file(s);
165 include_stack.push(newin);
166 switch_streams(newin->is);
171 // pop the inputstack.
173 My_flex_lexer::close_input()
175 Input_file *old = include_stack.pop();
177 if (include_stack.empty()) {
180 Input_file *i = include_stack.top();
181 switch_streams(i->is);
183 defined_ch_c_l = i->defined_ch_c_l_;