]> git.donarmstrong.com Git - lilypond.git/commitdiff
Add nested properties setting to \paper blocks.
authorJoe Neeman <joeneeman@gmail.com>
Wed, 23 Dec 2009 05:44:56 +0000 (21:44 -0800)
committerJoe Neeman <joeneeman@gmail.com>
Sun, 10 Jan 2010 01:39:33 +0000 (12:39 +1100)
input/regression/paper-nested-override.ly [new file with mode: 0644]
lily/lily-lexer.cc
lily/parser.yy

diff --git a/input/regression/paper-nested-override.ly b/input/regression/paper-nested-override.ly
new file mode 100644 (file)
index 0000000..67ca679
--- /dev/null
@@ -0,0 +1,11 @@
+\version "2.13.9"
+
+\header {
+  texidoc = "Nested properties can be set in the paper block."
+}
+
+\paper {
+  between-system-spacing #'minimum-distance = #0.0
+}
+
+{ c1 \break c1 }
index 0adee98fec480614e90665289bb05a40897bb352..3d51d54903c8a29f553eb3271c5421ce3927a14d 100644 (file)
@@ -23,6 +23,7 @@
 #include <sstream>
 using namespace std;
 
+#include "context.hh"  // for nested_property_alist
 #include "international.hh"
 #include "interval.hh"
 #include "keyword.hh"
@@ -270,11 +271,17 @@ Lily_lexer::new_input (string str, Sources *ss)
 }
 
 void
-Lily_lexer::set_identifier (SCM name, SCM s)
+Lily_lexer::set_identifier (SCM path, SCM s)
 {
-  SCM sym = name;
-  if (scm_is_string (name))
-    sym = scm_string_to_symbol (name);
+  SCM sym = path;
+  SCM val = s;
+  if (scm_is_string (path))
+    sym = scm_string_to_symbol (path);
+  else if (scm_is_pair (path))
+    {
+      sym = scm_car (path);
+      path = scm_cdr (path);
+    }
 
   if (scm_is_symbol (sym))
     {
@@ -286,7 +293,13 @@ Lily_lexer::set_identifier (SCM name, SCM s)
 
       SCM mod = scm_car (scopes_);
 
-      scm_module_define (mod, sym, s);
+      if (scm_is_pair (path))
+       {
+         SCM prev = scm_module_lookup (mod, sym);
+         if (prev != SCM_UNDEFINED)
+           val = nested_property_alist (prev, path, s);
+       }
+      scm_module_define (mod, sym, val);
     }
   else
     programming_error ("identifier is not a symbol");
index a4ac1ec0356ce3bf1afd3a0a813035b1870ded98..979ab2c26194e0a557ee1416afddc1082ca98afb 100644 (file)
@@ -564,7 +564,11 @@ assignment_id:
 assignment:
        assignment_id '=' identifier_init  {
                PARSER->lexer_->set_identifier ($1, $3);
-
+       }
+       | assignment_id property_path '=' identifier_init {
+               SCM path = scm_cons (scm_string_to_symbol ($1), $2);
+               PARSER->lexer_->set_identifier (path, $4);
+       ;
 /*
  TODO: devise standard for protection in parser.