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,
30 "geometric", GEOMETRIC,
38 "multivoice", MULTIVOICE,
39 "octave", OCTAVECOMMAND,
52 "symboltables", SYMBOLTABLES,
55 "textstyle", TEXTSTYLE,
56 "transpose", TRANSPOSE,
57 "unitspace", UNITSPACE,
64 My_lily_lexer::My_lily_lexer()
66 keytable_p_ = new Keyword_table(the_key_tab);
67 identifier_assoc_p_ = new Assoc<String, Identifier*>;
69 post_quotes_b_ = false;
74 My_lily_lexer::lookup_keyword(String s)
76 return keytable_p_->lookup(s);
80 My_lily_lexer::lookup_identifier(String s)
82 if (!identifier_assoc_p_->elt_query(s))
85 return (*identifier_assoc_p_)[s];
90 My_lily_lexer::add_identifier(Identifier*i)
92 delete lookup_identifier(i->name);
93 (*identifier_assoc_p_)[i->name] = i;
96 My_lily_lexer::~My_lily_lexer()
100 for (Assoc_iter<String,Identifier*>
101 ai(*identifier_assoc_p_); ai.ok(); ai++) {
102 mtor << "deleting: " << ai.key()<<'\n';
103 Identifier *i_p = ai.val();
104 if (!i_p->accessed_b_ && !i_p->init_b_)
105 warning("Variable not used", i_p->defined_ch_C_);
109 delete identifier_assoc_p_;
112 My_lily_lexer::print_declarations(bool init_b)const
114 for (Assoc_iter<String,Identifier*> ai(*identifier_assoc_p_); ai.ok();
116 if (ai.val()->init_b_ == init_b)
122 My_lily_lexer::LexerError(char const *s)
124 if (include_stack_.empty()) {
125 *mlog << "error at EOF" << s << '\n';
127 char const* ch_C = here_ch_C();
130 while (isspace(*ch_C == ' ' ))