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[]={
30 {"consists", CONSISTS},
31 {"contains", CONTAINS},
32 {"duration", DURATION},
33 {"absdynamic", ABSDYNAMIC},
35 {"translator", TRANSLATOR},
39 {"melodic" , MELODIC},
40 {"melodic_request", MELODIC_REQUEST},
46 {"notenames", NOTENAMES},
51 {"property", PROPERTY},
58 {"spandynamic", SPANDYNAMIC},
59 {"symboltables", SYMBOLTABLES},
62 {"textstyle", TEXTSTYLE},
63 {"transpose", TRANSPOSE},
65 {"grouping", GROUPING},
69 My_lily_lexer::My_lily_lexer()
71 keytable_p_ = new Keyword_table (the_key_tab);
72 identifier_p_dict_p_ = new Dictionary<Identifier*>;
74 post_quotes_b_ = false;
75 note_tab_p_ = new Notename_table;
79 My_lily_lexer::lookup_keyword (String s)
81 return keytable_p_->lookup (s.ch_C ());
85 My_lily_lexer::lookup_identifier (String s)
87 if (!identifier_p_dict_p_->elt_b (s))
90 return (*identifier_p_dict_p_)[s];
95 My_lily_lexer::set_identifier (String name_str, Identifier*i)
97 Identifier *old = lookup_identifier (name_str);
100 old->warning(_("redeclaration of \\") + name_str);
103 (*identifier_p_dict_p_)[name_str] = i;
106 My_lily_lexer::~My_lily_lexer()
110 for (Assoc_iter<String,Identifier*>
111 ai (*identifier_p_dict_p_); ai.ok(); ai++)
113 DOUT << "deleting: " << ai.key()<<'\n';
117 delete identifier_p_dict_p_;
120 My_lily_lexer::print_declarations (bool init_b) const
122 for (Assoc_iter<String,Identifier*> ai (*identifier_p_dict_p_);
125 if (ai.val()->init_b_ == init_b)
127 DOUT << ai.key() << '=';
134 My_lily_lexer::LexerError (char const *s)
136 if (include_stack_.empty())
138 *mlog << _("error at EOF") << s << '\n';
143 Input spot (source_file_l(),here_ch_C());
149 My_lily_lexer::lookup_melodic_req_l (String s)
151 return note_tab_p_->get_l (s);
155 My_lily_lexer::add_notename (String s, Melodic_req *p)
157 note_tab_p_->add (s,p);
161 My_lily_lexer::clear_notenames()
164 note_tab_p_ = new Notename_table;
168 My_lily_lexer::escaped_char(char c) const