2 #include "identparent.hh"
3 #include "associter.hh"
11 #include "notename.hh"
13 static Keyword_ent the_key_tab[]={
19 "duration", DURATIONCOMMAND,
20 "geometric", GEOMETRIC,
26 "octave", OCTAVECOMMAND,
39 "symboltables", SYMBOLTABLES,
40 "notenames", NOTENAMES,
42 "textstyle", TEXTSTYLE,
45 "unitspace", UNITSPACE,
55 My_flex_lexer::My_flex_lexer()
57 keytable = new Keyword_table(the_key_tab);
58 the_id_tab = new Assoc<String, Identifier*>;
63 My_flex_lexer::lookup_keyword(String s)
65 return keytable->lookup(s);
69 My_flex_lexer::lookup_identifier(String s)
71 if (!the_id_tab->elt_query(s))
74 return (*the_id_tab)[s];
78 My_flex_lexer::add_identifier(Identifier*i)
80 delete lookup_identifier(i->name);
81 (*the_id_tab)[i->name] = i;
84 My_flex_lexer::~My_flex_lexer()
88 for (Assoc_iter<String,Identifier*> ai(*the_id_tab); ai.ok(); ai++) {
89 mtor << "deleting: " << ai.key()<<'\n';
96 My_flex_lexer::LexerError(const char *s)
98 if (lexer->include_stack.empty()) {
99 *mlog << "error at EOF" << s;
101 *mlog << lexer->include_stack.top()->name << ": " <<
102 lexer->lineno() << ": error:" << s << '\n';
105 // set the new input to s, remember old file.
107 My_flex_lexer::new_input(String s)
109 if (!include_stack.empty())
110 include_stack.top()->line = lineno();
112 Input_file *newin = new Input_file(s);
113 include_stack.push(newin);
114 switch_streams(newin->is);
118 // pop the inputstack.
120 My_flex_lexer::close_input()
122 Input_file *old = include_stack.pop();
124 if (include_stack.empty()) {
127 Input_file *i = include_stack.top();
128 switch_streams(i->is);