4 #include "identifier.hh"
5 #include "assoc-iter.hh"
7 #include "input-file.hh"
8 #include "out/parser.hh"
14 #include "source-file.hh"
15 #include "parseconstruct.hh"
17 static Keyword_ent the_key_tab[]={
24 "duration", DURATIONCOMMAND,
26 "geometric", GEOMETRIC,
35 "multivoice", MULTIVOICE,
36 "octave", OCTAVECOMMAND,
49 "symboltables", SYMBOLTABLES,
52 "textstyle", TEXTSTYLE,
53 "unitspace", UNITSPACE,
62 My_flex_lexer::My_flex_lexer()
64 keytable_p_ = new Keyword_table(the_key_tab);
65 identifier_assoc_p_ = new Assoc<String, Identifier*>;
70 My_flex_lexer::lookup_keyword(String s)
72 return keytable_p_->lookup(s);
76 My_flex_lexer::lookup_identifier(String s)
78 if (!identifier_assoc_p_->elt_query(s))
81 return (*identifier_assoc_p_)[s];
85 My_flex_lexer::here_ch_c_l()
87 return include_stack_.top()->sourcefile_l_->ch_c_l() + yyin->tellg();
91 My_flex_lexer::add_identifier(Identifier*i)
93 delete lookup_identifier(i->name);
94 (*identifier_assoc_p_)[i->name] = i;
97 My_flex_lexer::~My_flex_lexer()
101 for (Assoc_iter<String,Identifier*>
102 ai(*identifier_assoc_p_); ai.ok(); ai++) {
103 mtor << "deleting: " << ai.key()<<'\n';
106 delete identifier_assoc_p_;
109 My_flex_lexer::print_declarations()const
111 for (Assoc_iter<String,Identifier*> ai(*identifier_assoc_p_); ai.ok(); ai++) {
117 My_flex_lexer::spot()const
119 return include_stack_.top()->name + ": " + String( lineno() );
123 My_flex_lexer::LexerError(char const *s)
125 if (lexer->include_stack_.empty()) {
126 *mlog << "error at EOF" << s << '\n';
128 char const* ch_c_l = here_ch_c_l();
131 while ( ( *ch_c_l == ' ' ) || ( *ch_c_l == '\t' ) || ( *ch_c_l == '\n' ) )
140 // set the new input to s, remember old file.
142 My_flex_lexer::new_input(String s)
144 if (!include_stack_.empty()) {
145 include_stack_.top()->line = lineno();
146 // should this be saved at all?
147 include_stack_.top()->defined_ch_c_l_ = defined_ch_c_l;
150 Input_file *newin = new Input_file(s);
151 include_stack_.push(newin);
152 switch_streams(newin->is);
157 // pop the inputstack.
159 My_flex_lexer::close_input()
161 Input_file *old = include_stack_.pop();
163 if (include_stack_.empty()) {
166 Input_file *i = include_stack_.top();
167 switch_streams(i->is);
169 defined_ch_c_l = i->defined_ch_c_l_;