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>
12 #include "interval.hh"
13 #include "identifier.hh"
14 #include "assoc-iter.hh"
15 #include "out/parser.hh"
18 #include "my-lily-lexer.hh"
20 #include "source-file.hh"
21 #include "parseconstruct.hh"
23 static Keyword_ent the_key_tab[]={
28 "duration", DURATIONCOMMAND,
29 "absdynamic", ABSDYNAMIC,
31 "geometric", GEOMETRIC,
33 "inputregister", INPUT_REGS,
37 "melodic_request", MELODIC_REQUEST,
41 "multivoice", MULTIVOICE,
43 "octave", OCTAVECOMMAND,
56 "spandynamic", SPANDYNAMIC,
57 "symboltables", SYMBOLTABLES,
60 "textstyle", TEXTSTYLE,
61 "transpose", TRANSPOSE,
62 "unitspace", UNITSPACE,
68 My_lily_lexer::My_lily_lexer()
70 keytable_p_ = new Keyword_table(the_key_tab);
71 identifier_assoc_p_ = new Assoc<String, Identifier*>;
73 post_quotes_b_ = false;
78 My_lily_lexer::lookup_keyword(String s)
80 return keytable_p_->lookup(s);
84 My_lily_lexer::lookup_identifier(String s)
86 if (!identifier_assoc_p_->elt_query(s))
89 return (*identifier_assoc_p_)[s];
94 My_lily_lexer::add_identifier(Identifier*i)
96 delete lookup_identifier(i->name);
97 (*identifier_assoc_p_)[i->name] = i;
100 My_lily_lexer::~My_lily_lexer()
104 for (Assoc_iter<String,Identifier*>
105 ai(*identifier_assoc_p_); ai.ok(); ai++) {
106 mtor << "deleting: " << ai.key()<<'\n';
107 Identifier *i_p = ai.val();
108 if (!i_p->accessed_b_ && !i_p->init_b_)
109 i_p->warning("Variable not used");
113 delete identifier_assoc_p_;
116 My_lily_lexer::print_declarations(bool init_b)const
118 for (Assoc_iter<String,Identifier*> ai(*identifier_assoc_p_); ai.ok();
120 if (ai.val()->init_b_ == init_b)
126 My_lily_lexer::LexerError(char const *s)
128 if (include_stack_.empty()) {
129 *mlog << "error at EOF" << s << '\n';
131 char const* ch_C = here_ch_C();
134 while (isspace(*ch_C == ' ' ))