]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/my-lily-lexer.cc
release: 0.1.49
[lilypond.git] / lily / my-lily-lexer.cc
index 857d364ede06983728cef17f530f3e72070876db..43495eb06cf6a01b960febcc02baa7b151bd5ef0 100644 (file)
@@ -22,8 +22,8 @@
 
 static Keyword_ent the_key_tab[]={
   {"accepts", ACCEPTS},
-  {"alias", ALIAS},
   {"bar", BAR},
+  {"break", BREAK},
   {"cadenza", CADENZA},
   {"clear", CLEAR},
   {"clef", CLEF},
@@ -32,11 +32,9 @@ static Keyword_ent the_key_tab[]={
   {"contains", CONTAINS},
   {"duration", DURATION},
   {"absdynamic", ABSDYNAMIC},
-  {"group", GROUP},
-  {"hshift", HSHIFT},
-  {"id", ID},
   {"in", IN_T},
-  {"requesttranslator", REQUESTTRANSLATOR},
+  {"translator", TRANSLATOR},
+  {"type", TYPE},
   {"lyric", LYRIC},
   {"key", KEY},
   {"melodic" , MELODIC},
@@ -51,15 +49,15 @@ static Keyword_ent the_key_tab[]={
   {"output", OUTPUT},
   {"partial", PARTIAL},
   {"paper", PAPER},
-  {"plet", PLET},
+  {"property", PROPERTY},
   {"pt", PT_T},
   {"score", SCORE},
   {"script", SCRIPT},
+  {"shape", SHAPE},
   {"skip", SKIP},
   {"staff", STAFF},
-  {"stem", STEM},
   {"table", TABLE},
-  {"spandynamic", SPANDYNAMIC}, 
+  {"spandynamic", SPANDYNAMIC},
   {"symboltables", SYMBOLTABLES},
   {"tempo", TEMPO},
   {"texid", TEXID},
@@ -73,7 +71,7 @@ static Keyword_ent the_key_tab[]={
 My_lily_lexer::My_lily_lexer()
 {
   keytable_p_ = new Keyword_table (the_key_tab);
-  identifier_assoc_p_ = new Assoc<String, Identifier*>;
+  identifier_p_dict_p_ = new Dictionary<Identifier*>;
   errorlevel_i_ = 0;
   post_quotes_b_ = false;
   note_tab_p_ = new Notename_table;
@@ -82,16 +80,16 @@ My_lily_lexer::My_lily_lexer()
 int
 My_lily_lexer::lookup_keyword (String s)
 {
-  return keytable_p_->lookup (s);
+  return keytable_p_->lookup (s.ch_C ());
 }
 
 Identifier*
 My_lily_lexer::lookup_identifier (String s)
 {
-  if (!identifier_assoc_p_->elt_b (s))
-       return 0;
-  
-  return (*identifier_assoc_p_)[s];
+  if (!identifier_p_dict_p_->elt_b (s))
+    return 0;
+
+  return (*identifier_p_dict_p_)[s];
 }
 
 
@@ -99,12 +97,12 @@ void
 My_lily_lexer::set_identifier (String name_str, Identifier*i)
 {
   Identifier *old = lookup_identifier (name_str);
-  if  (old) 
+  if  (old)
     {
-       old->warning( "redeclaration of \\" + name_str);
-       delete old;
+      old->warning(_("redeclaration of \\") + name_str);
+      delete old;
     }
-  (*identifier_assoc_p_)[name_str] = i;
+  (*identifier_p_dict_p_)[name_str] = i;
 }
 
 My_lily_lexer::~My_lily_lexer()
@@ -112,42 +110,40 @@ My_lily_lexer::~My_lily_lexer()
   delete keytable_p_;
 
   for (Assoc_iter<String,Identifier*>
-            ai (*identifier_assoc_p_); ai.ok(); ai++) 
-              {
-       DOUT << "deleting: " << ai.key()<<'\n';
-       delete ai.val();
+        ai (*identifier_p_dict_p_); ai.ok(); ai++)
+    {
+      DOUT << "deleting: " << ai.key()<<'\n';
+      delete ai.val();
     }
   delete note_tab_p_;
-  delete identifier_assoc_p_;
+  delete identifier_p_dict_p_;
 }
 void
-My_lily_lexer::print_declarations (bool init_b)const
+My_lily_lexer::print_declarations (bool init_b) const
 {
-  for (Assoc_iter<String,Identifier*> ai (*identifier_assoc_p_); ai.ok(); 
-        ai++) 
-          {
-       if (ai.val()->init_b_ == init_b) 
-         {
-           DOUT << ai.key() << '=';
-           ai.val()->print ();
-         }
+  for (Assoc_iter<String,Identifier*> ai (*identifier_p_dict_p_);
+       ai.ok(); ai++)
+    {
+      if (ai.val()->init_b_ == init_b)
+       {
+         DOUT << ai.key() << '=';
+         ai.val()->print ();
+       }
     }
 }
 
 void
 My_lily_lexer::LexerError (char const *s)
 {
-  if (include_stack_.empty()) 
+  if (include_stack_.empty())
     {
-       *mlog << "error at EOF" << s << '\n';
+      *mlog << _("error at EOF") << s << '\n';
     }
-  else 
+  else
     {
-       errorlevel_i_ |= 1;
-       Input spot (source_file_l(),here_ch_C());
-
-       spot.error (s);
+      errorlevel_i_ |= 1;
+      Input spot (source_file_l(),here_ch_C());
+      spot.error (s);
     }
 }
 
@@ -169,3 +165,21 @@ My_lily_lexer::clear_notenames()
   delete note_tab_p_;
   note_tab_p_ = new Notename_table;
 }
+
+char
+My_lily_lexer::escaped_char(char c) const
+{
+  switch(c)
+    {
+    case 'n':
+      return '\n';
+    case 't':
+      return '\t';
+
+    case '\'':
+    case '\"':
+    case '\\':
+      return c;
+    }
+  return 0;
+}