2 #include "identparent.hh"
3 #include "associter.hh"
11 #include "notename.hh"
13 static Keyword_ent the_key_tab[]={
20 "duration", DURATIONCOMMAND,
21 "geometric", GEOMETRIC,
30 "octave", OCTAVECOMMAND,
43 "symboltables", SYMBOLTABLES,
44 "notenames", NOTENAMES,
46 "textstyle", TEXTSTYLE,
49 "unitspace", UNITSPACE,
58 My_flex_lexer::My_flex_lexer()
60 keytable = new Keyword_table(the_key_tab);
61 the_id_tab = new Assoc<String, Identifier*>;
66 My_flex_lexer::lookup_keyword(String s)
68 return keytable->lookup(s);
72 My_flex_lexer::lookup_identifier(String s)
74 if (!the_id_tab->elt_query(s))
77 return (*the_id_tab)[s];
81 My_flex_lexer::add_identifier(Identifier*i)
83 delete lookup_identifier(i->name);
84 (*the_id_tab)[i->name] = i;
87 My_flex_lexer::~My_flex_lexer()
91 for (Assoc_iter<String,Identifier*> ai(*the_id_tab); ai.ok(); ai++) {
92 mtor << "deleting: " << ai.key()<<'\n';
99 My_flex_lexer::spot()const
101 return include_stack.top()->name + ": " + lineno();
105 My_flex_lexer::LexerError(const char *s)
107 if (lexer->include_stack.empty()) {
108 *mlog << "error at EOF" << s << '\n';
110 *mlog << spot() << ": error:" << s << '\n';
113 // set the new input to s, remember old file.
115 My_flex_lexer::new_input(String s)
117 if (!include_stack.empty())
118 include_stack.top()->line = lineno();
120 Input_file *newin = new Input_file(s);
121 include_stack.push(newin);
122 switch_streams(newin->is);
126 // pop the inputstack.
128 My_flex_lexer::close_input()
130 Input_file *old = include_stack.pop();
132 if (include_stack.empty()) {
135 Input_file *i = include_stack.top();
136 switch_streams(i->is);