]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/my-lily-lexer.cc
(find_create_context): assign to lvalue.
[lilypond.git] / lily / my-lily-lexer.cc
index c1934df8de16791ec3a54e96176996f662282540..d070a412c97c4ab51616ac7da815f02a5088012f 100644 (file)
@@ -12,7 +12,6 @@
 #include "lily-proto.hh"
 #include "scm-hash.hh"
 #include "interval.hh"
-#include "input-file-results.hh"
 #include "lily-guile.hh"
 #include "parser.hh"
 #include "keyword.hh"
@@ -38,6 +37,7 @@ static Keyword_ent the_key_tab[] = {
   {"appoggiatura", APPOGGIATURA},
   {"autochange", AUTOCHANGE},
   {"bar", BAR},
+  {"book", BOOK},
   {"breathe", BREATHE},
   {"change", CHANGE},
   {"chords", CHORDS},
@@ -92,13 +92,13 @@ static Keyword_ent the_key_tab[] = {
 };
 
 
-My_lily_lexer::My_lily_lexer ()
+My_lily_lexer::My_lily_lexer (Sources *srcs)
 {
   keytable_ = new Keyword_table (the_key_tab);
-
+  encoding_ = SCM_EOL;
   chordmodifier_tab_ = scm_make_vector (scm_int2num (1), SCM_EOL);
   pitchname_tab_stack_ = SCM_EOL; 
-  
+  sources_ = srcs;
   scopes_ = SCM_EOL;
   
   add_scope (ly_make_anonymous_module ());
@@ -107,12 +107,18 @@ My_lily_lexer::My_lily_lexer ()
   main_input_b_ = false;
 }
 
+SCM
+My_lily_lexer::encoding () const
+{
+  return encoding_ ;
+}
+
 void
 My_lily_lexer::add_scope (SCM module)
 {
   ly_reexport_module (scm_current_module ());
   scm_set_current_module (module);
-  for (SCM s = scopes_; ly_pair_p (s); s = ly_cdr (s))
+  for (SCM s = scopes_; ly_c_pair_p (s); s = ly_cdr (s))
     {
       /* UGH. how to do this more neatly? */      
       SCM expr
@@ -146,7 +152,7 @@ SCM
 My_lily_lexer::lookup_identifier (String s)
 {
   SCM sym = ly_symbol2scm (s.to_str0());
-  for (SCM s = scopes_; ly_pair_p (s); s = ly_cdr (s))
+  for (SCM s = scopes_; ly_c_pair_p (s); s = ly_cdr (s))
     {
       SCM var = ly_module_lookup (ly_car (s), sym);
       if (var != SCM_BOOL_F)
@@ -160,8 +166,7 @@ void
 My_lily_lexer::start_main_input ()
 {
   // yy_flex_debug = 1;
-
-  new_input (main_input_name_, &global_input_file->sources_);
+  new_input (main_input_name_, sources_);
   /* Do not allow \include in --safe-mode */
   allow_includes_b_ = allow_includes_b_ && ! safe_global_b;
 
@@ -173,7 +178,7 @@ My_lily_lexer::start_main_input ()
 void
 My_lily_lexer::set_identifier (SCM name, SCM s)
 {
-  assert (gh_string_p (name));
+  assert (ly_c_string_p (name));
   
   if (lookup_keyword (ly_scm2string (name)) >= 0)
     {
@@ -181,7 +186,7 @@ My_lily_lexer::set_identifier (SCM name, SCM s)
     }
 
   SCM sym = scm_string_to_symbol (name);
-  SCM mod = gh_car (scopes_);
+  SCM mod = ly_car (scopes_);
 
   scm_module_define (mod, sym, s);
 }
@@ -240,5 +245,8 @@ My_lily_lexer::prepare_for_next_token ()
 void
 My_lily_lexer::set_encoding (String s)
 {
-  encoding_ = s;
+  if (s.length ())
+    encoding_ = ly_symbol2scm (s.to_str0 ());
+  else
+    encoding_ = SCM_EOL;
 }