]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-1.3.60
authorfred <fred>
Tue, 26 Mar 2002 23:23:03 +0000 (23:23 +0000)
committerfred <fred>
Tue, 26 Mar 2002 23:23:03 +0000 (23:23 +0000)
lily/lexer.ll
lily/lily-guile.cc
lily/my-lily-lexer.cc

index 23692d60d74c93cc9041d9c20594094494ad5cf6..57d9537bf137fef7023c4ade6d29e8ca51c10d6e 100644 (file)
@@ -188,18 +188,12 @@ HYPHEN            --
        if (s.length_i () && (s[s.length_i () - 1] == ';'))
          s = s.left_str (s.length_i () - 1);
        DEBUG_OUT << "#include `\\" << s << "'\n";
-       Identifier * id = lookup_identifier (s);
-       if (id) 
-         {
-           String* s_l = id->access_content_String (false);
-           DEBUG_OUT << "#include `" << *s_l << "'\n";
-           new_input (*s_l, source_global_l);
-
-           yy_pop_state ();
-         }
-       else
-         {
-           String msg (_f ("undefined identifier: `%s'", s )); 
+       SCM sid = lookup_identifier (s);
+       if (gh_string_p (sid)) {
+               new_input (ly_scm2string (sid), source_global_l);
+               yy_pop_state ();
+       } else { 
+           String msg (_f ("wrong or undefined identifier: `%s'", s ));        
            LexerError (msg.ch_C ());
          }
 }
@@ -475,11 +469,21 @@ My_lily_lexer::scan_escaped_word (String str)
        if (l != -1) {
                return l;
        }
-       Identifier * id = lookup_identifier (str);
+       SCM sid = lookup_identifier (str);
+       if (gh_string_p (sid)) {
+               yylval.scm = sid; 
+               return STRING_IDENTIFIER;
+       }
+
+       Identifier * id = unsmob_identifier (sid);
        if (id) {
                yylval.id = id;
                return id->token_code_i_;
+       } else if (sid != SCM_UNDEFINED) {
+               yylval.scm = sid;
+               return SCM_IDENTIFIER;
        }
+
        if ((YYSTATE != notes) && (YYSTATE != chords)) {
                SCM pitch = scm_hashq_ref (pitchname_tab_, sym, SCM_BOOL_F);
                
index 9f5b91fa931ae3ccb105eebdc67e2fc9b61aaff4..6336f7dd1131f2397839bac238cbd46d4ebb8a6f 100644 (file)
@@ -373,6 +373,10 @@ ly_number2string (SCM s)
   return gh_str02scm (str);
 }
 
+/*
+  Undef this to see if GUILE GC is causing too many swaps.
+ */
+
 // #define TEST_GC
 
 #ifdef TEST_GC
index a547335081321d302fe8c5342824b5df1568e987..adfde155302b912cd23a8278cbe2ee51701c2c4f 100644 (file)
@@ -92,15 +92,15 @@ My_lily_lexer::lookup_keyword (String s)
   return keytable_p_->lookup (s.ch_C ());
 }
 
-Identifier*
+SCM
 My_lily_lexer::lookup_identifier (String s)
 {
   SCM sym = ly_symbol2scm (s.ch_C());
   
   for (int i = scope_l_arr_.size (); i--; )
     if (scope_l_arr_[i]->elem_b (sym))
-      return scope_l_arr_[i]->elem(sym);
-  return 0;
+      return scope_l_arr_[i]->scm_elem(sym);
+  return SCM_UNDEFINED;
 }
 
 void
@@ -111,23 +111,14 @@ My_lily_lexer::start_main_input ()
 }
 
 void
-My_lily_lexer::set_identifier (String name_str, Identifier* i, bool )
+My_lily_lexer::set_identifier (String name_str, SCM s)
 {
-  Identifier *old =0;
-  if (scope_l_arr_.top ()->elem_b (name_str))
-    old = scope_l_arr_.top ()->elem(name_str);
-   
-  if  (old)
-    {
-      delete old;
-    }
   if (lookup_keyword (name_str) >= 0)
     {
       warning (  _f ("Identifier name is a keyword: `%s'", name_str));
     }
   
-  scope_l_arr_.top ()->elem (name_str) = i;
+  scope_l_arr_.top ()->set (name_str, s);
 }
 
 My_lily_lexer::~My_lily_lexer()