]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/lexer.ll
release: 1.3.92
[lilypond.git] / lily / lexer.ll
index cbe754c5c38ea7518cc8e29e52a07dba6fd9c3a0..208e7034205c25f956e9ba673a80ba4486eba89a 100644 (file)
@@ -25,7 +25,6 @@
 #include <stdio.h>
 #include <ctype.h>
 
-#include "notename-table.hh"
 #include "lily-guile.hh"
 #include "string.hh"
 #include "string-convert.hh"
 #include "main.hh"
 #include "musical-request.hh"
 #include "identifier.hh"
-#include "mudela-version.hh"
 #include "version.hh"
+#include "mudela-version.hh"
+#include "translator-def.hh"
+
+#define isatty HORRIBLEKLUDGE
 
 void strip_trailing_white (String&);
 void strip_leading_white (String&);
@@ -138,9 +140,9 @@ HYPHEN              --
        String s (YYText ()+1);
        s = s.left_str (s.index_last_i ('"'));
        DEBUG_OUT << "#version `" << s << "'\n";
+       yy_pop_state ();
        if (!valid_version_b (s))
                return INVALID;
-       yy_pop_state ();
 }
 <version>.     {
        LexerError ("No quoted string found after \\version");
@@ -189,18 +191,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 ());
          }
 }
@@ -240,7 +236,8 @@ HYPHEN              --
        int n = 0;
        if (main_input_b_ && safe_global_b) {
                error (_ ("Can't evaluate Scheme in safe mode"));
-               return SCM_EOL;
+               yylval.scm =  SCM_EOL;
+               return SCM_T;
        }
        yylval.scm = ly_parse_scm (s, &n);
        DEBUG_OUT << "Scheme: ";
@@ -331,7 +328,7 @@ HYPHEN              --
                        }
 
                char c = s[s.length_i () - 1];
-               if (c == '{' &&  c == '}') // brace open is for not confusing dumb tools.
+               if (c == '{' ||  c == '}') // brace open is for not confusing dumb tools.
                        here_input ().warning (
                                "Brace found at end of lyric. Did you forget a space?");
                yylval.scm = ly_str02scm (s.ch_C ());
@@ -476,11 +473,33 @@ 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;
+       } else if (gh_number_p (sid)) {
+               yylval.scm = sid;
+               return NUMBER_IDENTIFIER;
+       } else if (unsmob_translator_def (sid)) {
+               yylval.scm = sid;
+               return TRANSLATOR_IDENTIFIER;
+       } else if (Music * mus =unsmob_music (sid)) {
+               yylval.scm = sid;
+               
+               return dynamic_cast<Request*> (mus) ? REQUEST_IDENTIFIER : MUSIC_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);
                
@@ -578,9 +597,9 @@ valid_version_b (String s)
   Mudela_version ver (s);
   if (!((ver >= oldest_version) && (ver <= current)))
        {       
-               error (_f ("incorrect mudela version: %s (%s, %s)", ver.str (), oldest_version.str (), current.str ()));
-               if (!version_ignore_global_b)
-                       return false;
+               non_fatal_error (_f ("incorrect mudela version: %s (%s, %s)", ver.str (), oldest_version.str (), current.str ()));
+               non_fatal_error (_("Consider converting the input with the convert-mudela script")); 
+               return false;
     }
   return true;
 }