]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/lexer.ll
new file, move from
[lilypond.git] / lily / lexer.ll
index 8b25deb071c507bd01b7ea8ef9b39f21985bd5c3..b8a502edc127113667e558202797cd6ebd2ab10a 100644 (file)
@@ -32,7 +32,7 @@
 
 #include <iostream>
 using namespace std;
-
+#include "music-function.hh"
 #include "source-file.hh"
 #include "parse-scm.hh"
 #include "lily-guile.hh"
@@ -57,7 +57,7 @@ RH 7 fix (?)
 void strip_trailing_white (String&);
 void strip_leading_white (String&);
 String lyric_fudge (String s);
-
+int music_function_type (SCM);
 SCM lookup_markup_command (String s);
 bool is_valid_version (String s);
 
@@ -161,7 +161,7 @@ HYPHEN              --
   }
 }
 
-<INITIAL>\\encoding{WHITE}*    {
+<INITIAL,notes>\\encoding{WHITE}* {
        yy_push_state (encoding);
 }
 <INITIAL,chords,lyrics,notes,figures>\\version{WHITE}* {
@@ -699,6 +699,13 @@ My_lily_lexer::scan_escaped_word (String str)
                return l;
        }
        SCM sid = lookup_identifier (str);
+       if (is_music_function (sid))
+       {
+               yylval.scm = get_music_function_transform (sid);
+               
+               return music_function_type (yylval.scm);
+       }
+
        if (sid != SCM_UNDEFINED)
        {
                yylval.scm = sid;
@@ -880,3 +887,45 @@ lookup_markup_command (String s)
        SCM proc = ly_scheme_function ("lookup-markup-command");
        return scm_call_1 (proc, scm_makfrom0str (s.to_str0 ()));
 }
+
+
+int
+music_function_type (SCM func)
+{
+       SCM type= scm_object_property (func, ly_symbol2scm ("music-function-signature-keyword"));
+       if (type == ly_symbol2scm ("scm"))
+       {
+               return MUSIC_FUNCTION_SCM;
+       }
+       else if (type == ly_symbol2scm ("music"))
+       {
+               return MUSIC_FUNCTION_MUSIC;
+       }
+       else if (type == ly_symbol2scm ("scm-music"))
+       {
+               return MUSIC_FUNCTION_SCM_MUSIC;
+       }
+       else if (type == ly_symbol2scm ("music-music"))
+       {
+               return MUSIC_FUNCTION_MUSIC_MUSIC;
+       }
+       else if (type == ly_symbol2scm ("scm-music-music"))
+       {
+               return MUSIC_FUNCTION_SCM_MUSIC_MUSIC;
+       }
+       else if (type == ly_symbol2scm ("scm-scm-music"))
+       {
+               return MUSIC_FUNCTION_SCM_SCM_MUSIC;
+       }
+       else if (type == ly_symbol2scm ("noarg"))
+       {
+               return MUSIC_FUNCTION;
+       }
+       else
+               {
+               /* TODO: print location */
+               error ("Can not find sigature for music function.");
+               }
+
+       return MUSIC_FUNCTION_SCM;
+}