]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/my-lily-lexer.cc
*** empty log message ***
[lilypond.git] / lily / my-lily-lexer.cc
index 8d9fcb93deeebc4ac12fbdf60771c6a1add66bfd..374a078390db5bc698d06101c26f08db1299c4df 100644 (file)
@@ -85,7 +85,6 @@ static Keyword_ent the_key_tab[] = {
 
 
 My_lily_lexer::My_lily_lexer (Sources *sources)
-  
 {
   keytable_ = new Keyword_table (the_key_tab);
   encoding_ = SCM_EOL;
@@ -102,14 +101,31 @@ My_lily_lexer::My_lily_lexer (Sources *sources)
 My_lily_lexer::My_lily_lexer (My_lily_lexer const &src)
   : Includable_lexer ()
 {
-  keytable_ = src.keytable_;
+  keytable_ =  (src.keytable_) ? new Keyword_table (*src.keytable_) : 0;
   encoding_ = src.encoding_;
   chordmodifier_tab_ = src.chordmodifier_tab_;
   pitchname_tab_stack_ = src.pitchname_tab_stack_;
   sources_ = src.sources_;
-  scopes_ = src.scopes_;
+  
   error_level_ = src.error_level_; 
   main_input_b_ = src.main_input_b_;
+
+  SCM scopes = SCM_EOL;
+  SCM* tail = &scopes;
+  for (SCM s = src.scopes_; ly_c_pair_p (s); s = ly_cdr (s))
+    {
+      SCM newmod = ly_make_anonymous_module (false);
+      ly_import_module (newmod, ly_car (s));
+      *tail = scm_cons (newmod, SCM_EOL);
+      tail = SCM_CDRLOC (*tail);
+    }
+  
+  scopes_ =  scopes;
+}
+
+My_lily_lexer::~My_lily_lexer ()
+{
+  delete keytable_;
 }
 
 SCM
@@ -149,9 +165,8 @@ My_lily_lexer::lookup_keyword (String s)
 }
 
 SCM
-My_lily_lexer::lookup_identifier (String name)
+My_lily_lexer::lookup_identifier_symbol (SCM sym)
 {
-  SCM sym = ly_symbol2scm (name.to_str0 ());
   for (SCM s = scopes_; ly_c_pair_p (s); s = ly_cdr (s))
     {
       SCM var = ly_module_lookup (ly_car (s), sym);
@@ -162,13 +177,20 @@ My_lily_lexer::lookup_identifier (String name)
   return SCM_UNDEFINED;
 }
 
+SCM
+My_lily_lexer::lookup_identifier (String name)
+{
+  return lookup_identifier_symbol (ly_symbol2scm (name.to_str0 ()));
+}
+
 void
 My_lily_lexer::start_main_input ()
 {
   // yy_flex_debug = 1;
   new_input (main_input_name_, sources_);
+  
   /* Do not allow \include in --safe-mode */
-  allow_includes_b_ = allow_includes_b_ && ! safe_global_b;
+  allow_includes_b_ = allow_includes_b_ && !safe_global_b;
 
   scm_module_define (ly_car (scopes_),
                     ly_symbol2scm ("input-file-name"),
@@ -193,20 +215,12 @@ My_lily_lexer::set_identifier (SCM name, SCM s)
 
       scm_module_define (mod, sym, s);
     }
-  
   else
     {
       programming_error ("Identifier is not a symbol.");
     }
 }
 
-My_lily_lexer::~My_lily_lexer ()
-{
-  delete keytable_;
-}
-
-
-
 void
 My_lily_lexer::LexerError (char const *s)
 {
@@ -229,7 +243,6 @@ My_lily_lexer::escaped_char (char c) const
       return '\n';
     case 't':
       return '\t';
-
     case '\'':
     case '\"':
     case '\\':