2 my-lily-lexer.cc -- implement My_lily_lexer
4 source file of the LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
11 #include "notename-table.hh"
12 #include "interval.hh"
13 #include "identifier.hh"
14 #include "assoc-iter.hh"
18 #include "my-lily-lexer.hh"
20 #include "source-file.hh"
21 #include "parseconstruct.hh"
23 static Keyword_ent the_key_tab[]={
29 {"duration", DURATIONCOMMAND},
30 {"absdynamic", ABSDYNAMIC},
32 {"geometric", GEOMETRIC},
35 {"init_end", INIT_END},
36 {"inputregister", INPUT_REGS},
39 {"melodic" , MELODIC},
40 {"melodic_request", MELODIC_REQUEST},
44 {"multivoice", MULTIVOICE},
46 {"notenames", NOTENAMES},
47 {"octave", OCTAVECOMMAND},
60 {"spandynamic", SPANDYNAMIC},
61 {"symboltables", SYMBOLTABLES},
64 {"textstyle", TEXTSTYLE},
65 {"transpose", TRANSPOSE},
66 {"unitspace", UNITSPACE},
69 {"grouping", GROUPING},
73 My_lily_lexer::My_lily_lexer()
75 keytable_p_ = new Keyword_table(the_key_tab);
76 identifier_assoc_p_ = new Assoc<String, Identifier*>;
78 post_quotes_b_ = false;
79 note_tab_p_ = new Notename_table;
83 My_lily_lexer::lookup_keyword(String s)
85 return keytable_p_->lookup(s);
89 My_lily_lexer::lookup_identifier(String s)
91 if (!identifier_assoc_p_->elt_b(s))
94 return (*identifier_assoc_p_)[s];
99 My_lily_lexer::add_identifier(Identifier*i)
101 delete lookup_identifier(i->name_str_);
102 (*identifier_assoc_p_)[i->name_str_] = i;
105 My_lily_lexer::~My_lily_lexer()
109 for (Assoc_iter<String,Identifier*>
110 ai(*identifier_assoc_p_); ai.ok(); ai++) {
111 mtor << "deleting: " << ai.key()<<'\n';
115 delete identifier_assoc_p_;
118 My_lily_lexer::print_declarations(bool init_b)const
120 for (Assoc_iter<String,Identifier*> ai(*identifier_assoc_p_); ai.ok();
122 if (ai.val()->init_b_ == init_b)
128 My_lily_lexer::LexerError(char const *s)
130 if (include_stack_.empty()) {
131 *mlog << "error at EOF" << s << '\n';
135 Input spot(source_file_l(),here_ch_C());
142 My_lily_lexer::lookup_melodic_req_l(String s)
144 return note_tab_p_->get_l(s);
148 My_lily_lexer::add_notename(String s, Melodic_req *p)
150 note_tab_p_->add(s,p);
154 My_lily_lexer::clear_notenames()
157 note_tab_p_ = new Notename_table;