]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/my-lily-lexer.cc
release: 0.1.7
[lilypond.git] / lily / my-lily-lexer.cc
index cdbfd35b785da9624948664f38e721dee9f978dd..18155a56e7584574c8faf79fdaec026d8999d632 100644 (file)
@@ -1,18 +1,18 @@
 /*
   my-lily-lexer.cc -- implement My_lily_lexer
 
-  source file of the LilyPond music typesetter
+  source file of the GNU LilyPond music typesetter
 
   (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
 */
 
 #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"
 #include "parseconstruct.hh"
 
 static Keyword_ent the_key_tab[]={
-    "bar", BAR,
-    "cadenza", CADENZA,
-    "clef", CLEF,
-    "cm", CM_T,
-    "duration", DURATIONCOMMAND,
-    "dynamic", DYNAMIC,
-    "geometric", GEOMETRIC,
-    "in", IN_T,
-    "lyrics", LYRICS,
-    "key", KEY,
-    "melodic" , MELODIC,
-    "meter", METER,
-    "midi", MIDI,
-    "mm", MM_T,
-    "multivoice", MULTIVOICE,
-    "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,
-    "symboltables", SYMBOLTABLES,
-    "tempo", TEMPO,
-    "texid", TEXID,
-    "textstyle", TEXTSTYLE,
-    "transpose", TRANSPOSE,
-    "unitspace", UNITSPACE,
-    "width", WIDTH,
-    "music", MUSIC,
-    "grouping", GROUPING,
-    0,0
+    {"accepts", ACCEPTS},
+    {"alias", ALIAS},
+    {"bar", BAR},
+    {"cadenza", CADENZA},
+    {"clear", CLEAR},
+    {"clef", CLEF},
+    {"cm", CM_T},
+    {"consists", CONSISTS},
+    {"contains", CONTAINS},
+    {"duration", DURATIONCOMMAND},
+    {"absdynamic", ABSDYNAMIC},
+    {"group", GROUP},
+    {"hshift", HSHIFT},
+    {"id", ID},
+    {"in", IN_T},
+    {"requesttranslator", REQUESTTRANSLATOR},
+    {"lyric", LYRIC},
+    {"key", KEY},
+    {"melodic" , MELODIC},
+    {"melodic_request", MELODIC_REQUEST},
+    {"meter", METER},
+    {"midi", MIDI},
+    {"mm", MM_T},
+    {"multi", MULTI},
+    {"notenames", NOTENAMES},
+    {"octave", OCTAVECOMMAND},
+    {"output", OUTPUT},
+    {"partial", PARTIAL},
+    {"paper", PAPER},
+    {"plet", PLET},
+    {"pt", PT_T},
+    {"score", SCORE},
+    {"script", SCRIPT},
+    {"skip", SKIP},
+    {"staff", STAFF},
+    {"stem", STEM},
+    {"table", TABLE},
+    {"spandynamic", SPANDYNAMIC}, 
+    {"symboltables", SYMBOLTABLES},
+    {"tempo", TEMPO},
+    {"texid", TEXID},
+    {"textstyle", TEXTSTYLE},
+    {"transpose", TRANSPOSE},
+    {"version", VERSION},
+    {"grouping", GROUPING},
+    {0,0}
 };
 
 My_lily_lexer::My_lily_lexer()
@@ -67,7 +75,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
@@ -79,7 +87,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];
@@ -89,8 +97,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()
@@ -100,12 +108,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_)
-           warning("Variable not used", i_p->defined_ch_C_);
-       
        delete ai.val();
     }
+    delete note_tab_p_;
     delete identifier_assoc_p_;
 }
 void
@@ -124,15 +129,29 @@ My_lily_lexer::LexerError(char const *s)
     if (include_stack_.empty()) {
        *mlog << "error at EOF" << s << '\n';
     } else {
-       char const* ch_C = here_ch_C();
-       if ( ch_C ) {
-           ch_C--;
-           while (isspace(*ch_C == ' ' ))
-                   ch_C--;
-           ch_C++;
-       }
        errorlevel_i_ |= 1;
-       error( s, ch_C );
+       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;
+}