]> git.donarmstrong.com Git - lilypond.git/blob - lily/identifier.cc
release: 0.0.40
[lilypond.git] / lily / identifier.cc
1 /*
2   identifier.cc -- implement identifier and derived classes
3
4   source file of the LilyPond music typesetter
5
6   (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
8
9 #include <assert.h>
10
11 #include "identifier.hh"
12 #include "lexer.hh"
13 #include "debug.hh"
14
15 void
16 Identifier::error(String expect)
17 {
18     String e("Wrong identifier type: ");
19     e += String(classname()) + "(expected " + expect + ")";
20     ::error(e);
21 }
22
23 void
24 Identifier::print()const
25 {
26     mtor << "identifier \'" << name << "\'=";
27     do_print();
28 }
29
30 /* ugh. */
31 #define DEFAULT_PRINT(Class, Content_type, accessor) \
32 void \
33 Class::do_print() const { \
34     ((Class*)this)->accessor(false)->print(); \
35 } \
36 class Class
37
38 DEFAULT_PRINT(Script_id, Script_def, script);
39 DEFAULT_PRINT(Lookup_id, Lookup, lookup);
40 DEFAULT_PRINT(Symtables_id, Symtables, symtables);
41 DEFAULT_PRINT(Staff_id, Input_staff, staff);
42 DEFAULT_PRINT(M_chord_id, Music_general_chord, mchord);
43 DEFAULT_PRINT(M_voice_id, Music_voice, mvoice);
44 DEFAULT_PRINT(Request_id, Request, request);
45 void
46 Real_id::do_print() const
47 {
48     Identifier::print();
49     mtor << *((Real_id*)this)->real(false)<< "\n";
50 }
51
52 void
53 Notetab_id::do_print() const
54 {
55     mtor << "unknown" << "\n";
56 }
57