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
},
39 {"requesttranslator", REQUESTTRANSLATOR
},
42 {"melodic" , MELODIC
},
43 {"melodic_request", MELODIC_REQUEST
},
49 {"notenames", NOTENAMES
},
62 {"spandynamic", SPANDYNAMIC
},
63 {"symboltables", SYMBOLTABLES
},
66 {"textstyle", TEXTSTYLE
},
67 {"transpose", TRANSPOSE
},
69 {"grouping", GROUPING
},
73 My_lily_lexer::My_lily_lexer()
75 keytable_p_
= new Keyword_table (the_key_tab
);
76 identifier_assoc_p_
= new Assoc
<String
, Identifier
*>;
78 post_quotes_b_
= false;
79 note_tab_p_
= new Notename_table
;
83 My_lily_lexer::lookup_keyword (String s
)
85 return keytable_p_
->lookup (s
);
89 My_lily_lexer::lookup_identifier (String s
)
91 if (!identifier_assoc_p_
->elt_b (s
))
94 return (*identifier_assoc_p_
)[s
];
99 My_lily_lexer::set_identifier (String name_str
, Identifier
*i
)
101 Identifier
*old
= lookup_identifier (name_str
);
104 old
->warning("redeclaration of \\" + name_str
);
107 (*identifier_assoc_p_
)[name_str
] = i
;
110 My_lily_lexer::~My_lily_lexer()
114 for (Assoc_iter
<String
,Identifier
*>
115 ai (*identifier_assoc_p_
); ai
.ok(); ai
++)
117 DOUT
<< "deleting: " << ai
.key()<<'\n';
121 delete identifier_assoc_p_
;
124 My_lily_lexer::print_declarations (bool init_b
) const
126 for (Assoc_iter
<String
,Identifier
*> ai (*identifier_assoc_p_
); ai
.ok();
129 if (ai
.val()->init_b_
== init_b
)
131 DOUT
<< ai
.key() << '=';
138 My_lily_lexer::LexerError (char const *s
)
140 if (include_stack_
.empty())
142 *mlog
<< "error at EOF" << s
<< '\n';
148 Input
spot (source_file_l(),here_ch_C());
155 My_lily_lexer::lookup_melodic_req_l (String s
)
157 return note_tab_p_
->get_l (s
);
161 My_lily_lexer::add_notename (String s
, Melodic_req
*p
)
163 note_tab_p_
->add (s
,p
);
167 My_lily_lexer::clear_notenames()
170 note_tab_p_
= new Notename_table
;