2 my-lily-lexer.cc -- implement My_lily_lexer
4 source file of the GNU 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[]={
31 {"consists", CONSISTS},
32 {"contains", CONTAINS},
33 {"duration", DURATIONCOMMAND},
34 {"absdynamic", ABSDYNAMIC},
36 {"geometric", GEOMETRIC},
40 {"init_end", INIT_END},
41 {"requestregister", REQUESTREGISTER},
44 {"melodic" , MELODIC},
45 {"melodic_request", MELODIC_REQUEST},
51 {"notenames", NOTENAMES},
52 {"octave", OCTAVECOMMAND},
65 {"spandynamic", SPANDYNAMIC},
66 {"symboltables", SYMBOLTABLES},
69 {"textstyle", TEXTSTYLE},
70 {"transpose", TRANSPOSE},
71 {"unitspace", UNITSPACE},
74 {"grouping", GROUPING},
78 My_lily_lexer::My_lily_lexer()
80 keytable_p_ = new Keyword_table(the_key_tab);
81 identifier_assoc_p_ = new Assoc<String, Identifier*>;
83 post_quotes_b_ = false;
84 note_tab_p_ = new Notename_table;
88 My_lily_lexer::lookup_keyword(String s)
90 return keytable_p_->lookup(s);
94 My_lily_lexer::lookup_identifier(String s)
96 if (!identifier_assoc_p_->elt_b(s))
99 return (*identifier_assoc_p_)[s];
104 My_lily_lexer::add_identifier(Identifier*i)
106 delete lookup_identifier(i->name_str_);
107 (*identifier_assoc_p_)[i->name_str_] = i;
110 My_lily_lexer::~My_lily_lexer()
114 for (Assoc_iter<String,Identifier*>
115 ai(*identifier_assoc_p_); ai.ok(); ai++) {
116 mtor << "deleting: " << ai.key()<<'\n';
120 delete identifier_assoc_p_;
123 My_lily_lexer::print_declarations(bool init_b)const
125 for (Assoc_iter<String,Identifier*> ai(*identifier_assoc_p_); ai.ok();
127 if (ai.val()->init_b_ == init_b)
133 My_lily_lexer::LexerError(char const *s)
135 if (include_stack_.empty()) {
136 *mlog << "error at EOF" << s << '\n';
140 Input spot(source_file_l(),here_ch_C());
147 My_lily_lexer::lookup_melodic_req_l(String s)
149 return note_tab_p_->get_l(s);
153 My_lily_lexer::add_notename(String s, Melodic_req *p)
155 note_tab_p_->add(s,p);
159 My_lily_lexer::clear_notenames()
162 note_tab_p_ = new Notename_table;