]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/my-lily-lexer.cc
* lily/paper-score.cc (process): Do not show progress newline.
[lilypond.git] / lily / my-lily-lexer.cc
index 7fa4569c05cdd444ebb30e7cc4cb6f45124ac1f8..a2ad7efaf0328c28078f70a7515645f34c6adb6f 100644 (file)
 
 
 static Keyword_ent the_key_tab[] = {
-  {"acciaccatura", ACCIACCATURA},
   {"accepts", ACCEPTS},
-  {"addlyrics", ADDLYRICS},
   {"addquote", ADDQUOTE},
   {"alias", ALIAS},
   {"alternative", ALTERNATIVE},
-  {"applycontext", APPLYCONTEXT},
-  {"applyoutput", APPLYOUTPUT},
-  {"appoggiatura", APPOGGIATURA},
-  {"autochange", AUTOCHANGE},
   {"bar", BAR},
   {"book", BOOK},
-  {"breathe", BREATHE},
+  {"bookpaper", BOOKPAPER},
   {"change", CHANGE},
   {"chords", CHORDS},
   {"clef", CLEF},
@@ -49,7 +43,6 @@ static Keyword_ent the_key_tab[] = {
   {"drums", DRUMS},
   {"description", DESCRIPTION},
   {"figures",FIGURES},
-  {"grace", GRACE},
   {"grobdescriptions", GROBDESCRIPTIONS},
   {"header", HEADER},
   {"key", KEY},
@@ -66,7 +59,6 @@ static Keyword_ent the_key_tab[] = {
   {"once", ONCE},
   {"override", OVERRIDE},
   {"paper", PAPER},
-  {"partcombine", PARTCOMBINE},
   {"partial", PARTIAL},
   {"quote", QUOTE},
   {"relative", RELATIVE},
@@ -93,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;
@@ -104,13 +95,13 @@ My_lily_lexer::My_lily_lexer (Sources *sources)
   error_level_ = 0; 
   main_input_b_ = false;
   
-  add_scope (ly_make_anonymous_module (safe_global_b));
+  add_scope (ly_make_anonymous_module (false));
 }
 
 My_lily_lexer::My_lily_lexer (My_lily_lexer const &src)
   : Includable_lexer ()
 {
-  keytable_ = src.keytable_;
+  keytable_ = new Keyword_table (*src.keytable_);
   encoding_ = src.encoding_;
   chordmodifier_tab_ = src.chordmodifier_tab_;
   pitchname_tab_stack_ = src.pitchname_tab_stack_;
@@ -120,6 +111,11 @@ My_lily_lexer::My_lily_lexer (My_lily_lexer const &src)
   main_input_b_ = src.main_input_b_;
 }
 
+My_lily_lexer::~My_lily_lexer ()
+{
+  delete keytable_;
+}
+
 SCM
 My_lily_lexer::encoding () const
 {
@@ -157,9 +153,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);
@@ -170,6 +165,12 @@ 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 ()
 {
@@ -186,22 +187,26 @@ My_lily_lexer::start_main_input ()
 void
 My_lily_lexer::set_identifier (SCM name, SCM s)
 {
-  assert (ly_c_string_p (name));
+  SCM sym = name;
+  if (ly_c_string_p (name))
+    sym =  scm_string_to_symbol (name);
   
-  if (lookup_keyword (ly_scm2string (name)) >= 0)
+  if (ly_c_symbol_p (sym))
     {
-      warning (_f ("Identifier name is a keyword: `%s'", SCM_STRING_CHARS (name)));
-    }
-
-  SCM sym = scm_string_to_symbol (name);
-  SCM mod = ly_car (scopes_);
+      if (lookup_keyword (ly_symbol2string (sym)) >= 0)
+       {
+         warning (_f ("Identifier name is a keyword: `%s'", SCM_SYMBOL_CHARS (sym)));
+       }
 
-  scm_module_define (mod, sym, s);
-}
+      SCM mod = ly_car (scopes_);
 
-My_lily_lexer::~My_lily_lexer ()
-{
-  delete keytable_;
+      scm_module_define (mod, sym, s);
+    }
+  
+  else
+    {
+      programming_error ("Identifier is not a symbol.");
+    }
 }