diff options
author | Han-Wen Nienhuys <hanwen@xs4all.nl> | 1997-04-07 22:44:56 +0200 |
---|---|---|
committer | Han-Wen Nienhuys <hanwen@xs4all.nl> | 1997-04-07 22:44:56 +0200 |
commit | 79511c44a27908a1beaed25bbcac8d95a8a6b7c8 (patch) | |
tree | 5905709b4efda8df47ccec37713912678208ccbe /lily/my-lily-lexer.cc | |
parent | 1ca7a2c01e48a2585ab7b43aa18c9c276d4a05d0 (diff) |
release: 0.0.49
Diffstat (limited to 'lily/my-lily-lexer.cc')
-rw-r--r-- | lily/my-lily-lexer.cc | 127 |
1 files changed, 71 insertions, 56 deletions
diff --git a/lily/my-lily-lexer.cc b/lily/my-lily-lexer.cc index 6ff46f282c..28505097c0 100644 --- a/lily/my-lily-lexer.cc +++ b/lily/my-lily-lexer.cc @@ -8,11 +8,11 @@ #include <strstream.h> #include <ctype.h> - +#include "notename-table.hh" #include "interval.hh" #include "identifier.hh" #include "assoc-iter.hh" -#include "out/parser.hh" +#include "parser.hh" #include "keyword.hh" #include "assoc.hh" #include "my-lily-lexer.hh" @@ -21,48 +21,50 @@ #include "parseconstruct.hh" static Keyword_ent the_key_tab[]={ - "bar", BAR, - "cadenza", CADENZA, - "clef", CLEF, - "cm", CM_T, - "duration", DURATIONCOMMAND, - "absdynamic", ABSDYNAMIC, - "group", GROUP, - "geometric", GEOMETRIC, - "in", IN_T, - "inputregister", INPUT_REGS, - "lyric", LYRIC, - "key", KEY, - "melodic" , MELODIC, - "melodic_request", MELODIC_REQUEST, - "meter", METER, - "midi", MIDI, - "mm", MM_T, - "multivoice", MULTIVOICE, - "note", NOTE, - "octave", OCTAVECOMMAND, - "output", OUTPUT, - "partial", PARTIAL, - "paper", PAPER, - "plet", PLET, - "pt", PT_T, - "score", SCORE, - "script", SCRIPT, - "skip", SKIP, - "staff", STAFF, - "start", START_T, - "stem", STEM, - "table", TABLE, - "spandynamic", SPANDYNAMIC, - "symboltables", SYMBOLTABLES, - "tempo", TEMPO, - "texid", TEXID, - "textstyle", TEXTSTYLE, - "transpose", TRANSPOSE, - "unitspace", UNITSPACE, - "width", WIDTH, - "grouping", GROUPING, - 0,0 + {"bar", BAR}, + {"cadenza", CADENZA}, + {"clear", CLEAR}, + {"clef", CLEF}, + {"cm", CM_T}, + {"duration", DURATIONCOMMAND}, + {"absdynamic", ABSDYNAMIC}, + {"group", GROUP}, + {"geometric", GEOMETRIC}, + {"in", IN_T}, + {"inputregister", INPUT_REGS}, + {"lyric", LYRIC}, + {"key", KEY}, + {"melodic" , MELODIC}, + {"melodic_request", MELODIC_REQUEST}, + {"meter", METER}, + {"midi", MIDI}, + {"mm", MM_T}, + {"multivoice", MULTIVOICE}, + {"note", NOTE}, + {"notenames", NOTENAMES}, + {"octave", OCTAVECOMMAND}, + {"output", OUTPUT}, + {"partial", PARTIAL}, + {"paper", PAPER}, + {"plet", PLET}, + {"pt", PT_T}, + {"score", SCORE}, + {"script", SCRIPT}, + {"skip", SKIP}, + {"staff", STAFF}, + {"start", START_T}, + {"stem", STEM}, + {"table", TABLE}, + {"spandynamic", SPANDYNAMIC}, + {"symboltables", SYMBOLTABLES}, + {"tempo", TEMPO}, + {"texid", TEXID}, + {"textstyle", TEXTSTYLE}, + {"transpose", TRANSPOSE}, + {"unitspace", UNITSPACE}, + {"width", WIDTH}, + {"grouping", GROUPING}, + {0,0} }; My_lily_lexer::My_lily_lexer() @@ -71,7 +73,7 @@ My_lily_lexer::My_lily_lexer() identifier_assoc_p_ = new Assoc<String, Identifier*>; errorlevel_i_ = 0; post_quotes_b_ = false; - + note_tab_p_ = new Notename_table; } int @@ -83,7 +85,7 @@ My_lily_lexer::lookup_keyword(String s) Identifier* My_lily_lexer::lookup_identifier(String s) { - if (!identifier_assoc_p_->elt_query(s)) + if (!identifier_assoc_p_->elt_b(s)) return 0; return (*identifier_assoc_p_)[s]; @@ -93,8 +95,8 @@ My_lily_lexer::lookup_identifier(String s) void My_lily_lexer::add_identifier(Identifier*i) { - delete lookup_identifier(i->name); - (*identifier_assoc_p_)[i->name] = i; + delete lookup_identifier(i->name_str_); + (*identifier_assoc_p_)[i->name_str_] = i; } My_lily_lexer::~My_lily_lexer() @@ -104,12 +106,9 @@ My_lily_lexer::~My_lily_lexer() for (Assoc_iter<String,Identifier*> ai(*identifier_assoc_p_); ai.ok(); ai++) { mtor << "deleting: " << ai.key()<<'\n'; - Identifier *i_p = ai.val(); - if (!i_p->accessed_b_ && !i_p->init_b_) - i_p->warning("Variable not used"); - delete ai.val(); } + delete note_tab_p_; delete identifier_assoc_p_; } void @@ -129,12 +128,28 @@ My_lily_lexer::LexerError(char const *s) *mlog << "error at EOF" << s << '\n'; } else { errorlevel_i_ |= 1; - error(String(s)); - // FIXME. -/*Input spot(source_l_g = here_spot(); + + Input spot(source_file_l(),here_ch_C()); spot.error( s ); - */ } } +Melodic_req* +My_lily_lexer::lookup_melodic_req_l(String s) +{ + return note_tab_p_->get_l(s); +} + +void +My_lily_lexer::add_notename(String s, Melodic_req *p) +{ + note_tab_p_->add(s,p); +} + +void +My_lily_lexer::clear_notenames() +{ + delete note_tab_p_; + note_tab_p_ = new Notename_table; +} |