3 #include "identparent.hh"
4 #include "associter.hh"
6 #include "inputfile.hh"
12 #include "notename.hh"
13 #include "sourcefile.hh"
14 #include "parseconstruct.hh"
16 static Keyword_ent the_key_tab[]={
23 "duration", DURATIONCOMMAND,
24 "geometric", GEOMETRIC,
32 "multivoice", MULTIVOICE,
33 "octave", OCTAVECOMMAND,
46 "symboltables", SYMBOLTABLES,
47 "notenames", NOTENAMES,
50 "textstyle", TEXTSTYLE,
51 "unitspace", UNITSPACE,
61 My_flex_lexer::ret_notename(int *p, String text, int octave_mod)
64 char const* ch_c_l = here_ch_c_l();
67 while ( ( *ch_c_l == ' ' ) || ( *ch_c_l == '\t' ) || ( *ch_c_l == '\n' ) )
72 lookup_notename(p[0], p[1], text);
74 mtor << "notename: "<< text <<eol;
78 error( String( "notename does not exist: " ) + YYText(), ch_c_l );
84 My_flex_lexer::My_flex_lexer()
86 keytable = new Keyword_table(the_key_tab);
87 the_id_tab = new Assoc<String, Identifier*>;
93 My_flex_lexer::lookup_keyword(String s)
95 return keytable->lookup(s);
99 My_flex_lexer::lookup_identifier(String s)
101 if (!the_id_tab->elt_query(s))
104 return (*the_id_tab)[s];
108 My_flex_lexer::here_ch_c_l()
110 return include_stack.top()->sourcefile_l_->ch_c_l() + yyin->tellg();
114 My_flex_lexer::add_identifier(Identifier*i)
116 delete lookup_identifier(i->name);
117 (*the_id_tab)[i->name] = i;
120 My_flex_lexer::~My_flex_lexer()
124 for (Assoc_iter<String,Identifier*> ai(*the_id_tab); ai.ok(); ai++) {
125 mtor << "deleting: " << ai.key()<<'\n';
132 My_flex_lexer::spot()const
134 return include_stack.top()->name + ": " + String( lineno() );
138 My_flex_lexer::LexerError(const char *s)
140 if (lexer->include_stack.empty()) {
141 *mlog << "error at EOF" << s << '\n';
143 char const* ch_c_l = here_ch_c_l();
146 while ( ( *ch_c_l == ' ' ) || ( *ch_c_l == '\t' ) || ( *ch_c_l == '\n' ) )
155 // set the new input to s, remember old file.
157 My_flex_lexer::new_input(String s)
159 if (!include_stack.empty()) {
160 include_stack.top()->line = lineno();
161 // should this be saved at all?
162 include_stack.top()->defined_ch_c_l_ = defined_ch_c_l;
165 Input_file *newin = new Input_file(s);
166 include_stack.push(newin);
167 switch_streams(newin->is);
172 // pop the inputstack.
174 My_flex_lexer::close_input()
176 Input_file *old = include_stack.pop();
178 if (include_stack.empty()) {
181 Input_file *i = include_stack.top();
182 switch_streams(i->is);
184 defined_ch_c_l = i->defined_ch_c_l_;