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},
59 {"spandynamic", SPANDYNAMIC},
60 {"symboltables", SYMBOLTABLES},
63 {"textstyle", TEXTSTYLE},
64 {"transpose", TRANSPOSE},
66 {"grouping", GROUPING},
70 My_lily_lexer::My_lily_lexer()
72 keytable_p_ = new Keyword_table (the_key_tab);
73 identifier_p_dict_p_ = new Dictionary<Identifier*>;
75 post_quotes_b_ = false;
76 note_tab_p_ = new Notename_table;
80 My_lily_lexer::lookup_keyword (String s)
82 return keytable_p_->lookup (s.ch_C ());
86 My_lily_lexer::lookup_identifier (String s)
88 if (!identifier_p_dict_p_->elt_b (s))
91 return (*identifier_p_dict_p_)[s];
96 My_lily_lexer::set_identifier (String name_str, Identifier*i)
98 Identifier *old = lookup_identifier (name_str);
101 old->warning(_("redeclaration of \\") + name_str);
104 (*identifier_p_dict_p_)[name_str] = i;
107 My_lily_lexer::~My_lily_lexer()
111 for (Assoc_iter<String,Identifier*>
112 ai (*identifier_p_dict_p_); ai.ok(); ai++)
114 DOUT << "deleting: " << ai.key()<<'\n';
118 delete identifier_p_dict_p_;
121 My_lily_lexer::print_declarations (bool init_b) const
123 for (Assoc_iter<String,Identifier*> ai (*identifier_p_dict_p_);
126 if (ai.val()->init_b_ == init_b)
128 DOUT << ai.key() << '=';
135 My_lily_lexer::LexerError (char const *s)
137 if (include_stack_.empty())
139 *mlog << _("error at EOF") << s << '\n';
144 Input spot (source_file_l(),here_ch_C());
150 My_lily_lexer::lookup_melodic_req_l (String s)
152 return note_tab_p_->get_l (s);
156 My_lily_lexer::add_notename (String s, Melodic_req *p)
158 note_tab_p_->add (s,p);
162 My_lily_lexer::clear_notenames()
165 note_tab_p_ = new Notename_table;
169 My_lily_lexer::escaped_char(char c) const