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[]={
31 {"consists", CONSISTS},
32 {"contains", CONTAINS},
33 {"duration", DURATION},
34 {"absdynamic", ABSDYNAMIC},
36 {"translator", TRANSLATOR},
40 {"melodic" , MELODIC},
41 {"melodic_request", MELODIC_REQUEST},
47 {"notenames", NOTENAMES},
52 {"property", PROPERTY},
60 {"spandynamic", SPANDYNAMIC},
61 {"symboltables", SYMBOLTABLES},
64 {"textstyle", TEXTSTYLE},
65 {"transpose", TRANSPOSE},
67 {"grouping", GROUPING},
71 My_lily_lexer::My_lily_lexer()
73 keytable_p_ = new Keyword_table (the_key_tab);
74 identifier_p_dict_p_ = new Dictionary<Identifier*>;
76 post_quotes_b_ = false;
77 note_tab_p_ = new Notename_table;
81 My_lily_lexer::lookup_keyword (String s)
83 return keytable_p_->lookup (s.ch_C ());
87 My_lily_lexer::lookup_identifier (String s)
89 if (!identifier_p_dict_p_->elt_b (s))
92 return (*identifier_p_dict_p_)[s];
97 My_lily_lexer::set_identifier (String name_str, Identifier*i)
99 Identifier *old = lookup_identifier (name_str);
102 old->warning(_("redeclaration of \\") + name_str);
105 (*identifier_p_dict_p_)[name_str] = i;
108 My_lily_lexer::~My_lily_lexer()
112 for (Assoc_iter<String,Identifier*>
113 ai (*identifier_p_dict_p_); ai.ok(); ai++)
115 DOUT << "deleting: " << ai.key()<<'\n';
119 delete identifier_p_dict_p_;
122 My_lily_lexer::print_declarations (bool init_b) const
124 for (Assoc_iter<String,Identifier*> ai (*identifier_p_dict_p_);
127 if (ai.val()->init_b_ == init_b)
129 DOUT << ai.key() << '=';
136 My_lily_lexer::LexerError (char const *s)
138 if (include_stack_.empty())
140 *mlog << _("error at EOF") << s << '\n';
145 Input spot (source_file_l(),here_ch_C());
151 My_lily_lexer::lookup_melodic_req_l (String s)
153 return note_tab_p_->get_l (s);
157 My_lily_lexer::add_notename (String s, Melodic_req *p)
159 note_tab_p_->add (s,p);
163 My_lily_lexer::clear_notenames()
166 note_tab_p_ = new Notename_table;
170 My_lily_lexer::escaped_char(char c) const