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,
35 "melodic_request", MELODIC_REQUEST,
39 "multivoice", MULTIVOICE,
41 "octave", OCTAVECOMMAND,
54 "symboltables", SYMBOLTABLES,
57 "textstyle", TEXTSTYLE,
58 "transpose", TRANSPOSE,
59 "unitspace", UNITSPACE,
65 My_lily_lexer::My_lily_lexer()
67 keytable_p_ = new Keyword_table(the_key_tab);
68 identifier_assoc_p_ = new Assoc<String, Identifier*>;
70 post_quotes_b_ = false;
75 My_lily_lexer::lookup_keyword(String s)
77 return keytable_p_->lookup(s);
81 My_lily_lexer::lookup_identifier(String s)
83 if (!identifier_assoc_p_->elt_query(s))
86 return (*identifier_assoc_p_)[s];
91 My_lily_lexer::add_identifier(Identifier*i)
93 delete lookup_identifier(i->name);
94 (*identifier_assoc_p_)[i->name] = i;
97 My_lily_lexer::~My_lily_lexer()
101 for (Assoc_iter<String,Identifier*>
102 ai(*identifier_assoc_p_); ai.ok(); ai++) {
103 mtor << "deleting: " << ai.key()<<'\n';
104 Identifier *i_p = ai.val();
105 if (!i_p->accessed_b_ && !i_p->init_b_)
106 warning("Variable not used", i_p->defined_ch_C_);
110 delete identifier_assoc_p_;
113 My_lily_lexer::print_declarations(bool init_b)const
115 for (Assoc_iter<String,Identifier*> ai(*identifier_assoc_p_); ai.ok();
117 if (ai.val()->init_b_ == init_b)
123 My_lily_lexer::LexerError(char const *s)
125 if (include_stack_.empty()) {
126 *mlog << "error at EOF" << s << '\n';
128 char const* ch_C = here_ch_C();
131 while (isspace(*ch_C == ' ' ))