]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/lexer.ll
parser.yy et al: implement optional arguments for music functions
[lilypond.git] / lily / lexer.ll
index 8a07f1b2c00e64cd74208bdc6fdffc479b711746..e88ed791c4eb55383a55c6219b404eca83131559 100644 (file)
@@ -828,7 +828,14 @@ Lily_lexer::scan_escaped_word (string str)
                push_extra_token (EXPECT_NO_MORE_ARGS);
                for (s = scm_cdr (s); scm_is_pair (s); s = scm_cdr (s))
                {
+                       SCM optional = SCM_UNDEFINED;
                        cs = scm_car (s);
+
+                       if (scm_is_pair (cs))
+                       {
+                               optional = SCM_CDR (cs);
+                               cs = SCM_CAR (cs);
+                       }
                        
                        if (cs == ly_music_p_proc)
                                push_extra_token (EXPECT_MUSIC);
@@ -840,7 +847,13 @@ Lily_lexer::scan_escaped_word (string str)
                                push_extra_token (EXPECT_MARKUP);
                        else if (ly_is_procedure (cs))
                                push_extra_token (EXPECT_SCM);
-                       else programming_error ("Function parameter without type-checking predicate");
+                       else
+                       {
+                               programming_error ("Function parameter without type-checking predicate");
+                               continue;
+                       }
+                       if (!scm_is_eq (optional, SCM_UNDEFINED))
+                               push_extra_token (EXPECT_OPTIONAL, optional);
                }
                return funtype;
        }