]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/parser.yy
Doc-es: update Notation/Appendices.
[lilypond.git] / lily / parser.yy
index 29ecf1c3222f88e4d8a7b6325486d24c098fa605..b8849e8f4acaa79447fe0a81daa4d6e0d8a218d3 100644 (file)
@@ -119,6 +119,7 @@ FIXME:
 using namespace std;
 
 #include "book.hh"
+#include "context.hh"
 #include "context-def.hh"
 #include "context-mod.hh"
 #include "dimensions.hh"
@@ -353,6 +354,7 @@ If we give names, Bison complains.
 %token EVENT_IDENTIFIER
 %token EVENT_FUNCTION
 %token FRACTION
+%token LOOKUP_IDENTIFIER
 %token LYRIC_ELEMENT
 %token MARKUP_FUNCTION
 %token MARKUP_LIST_FUNCTION
@@ -492,6 +494,15 @@ toplevel_expression:
        }
        ;
 
+lookup:
+       LOOKUP_IDENTIFIER
+       | LOOKUP_IDENTIFIER '.' symbol_list_rev
+       {
+               $$ = loc_on_music (parser, @$,
+                                  nested_property ($1, scm_reverse_x ($3, SCM_EOL)));
+       }
+       ;
+
 embedded_scm_bare:
        SCM_TOKEN
        {
@@ -503,6 +514,7 @@ embedded_scm_bare:
 embedded_scm_active:
        SCM_IDENTIFIER
        | scm_function_call
+       | lookup
        ;
 
 embedded_scm_bare_arg:
@@ -520,6 +532,7 @@ embedded_scm_bare_arg:
        | book_block
        | bookpart_block
        | output_def
+       | lookup
        ;
 
 /* The generic version may end in music, or not */
@@ -527,6 +540,7 @@ embedded_scm_bare_arg:
 embedded_scm:
        embedded_scm_bare
        | scm_function_call
+       | lookup
        ;
 
 /* embedded_scm_arg is _not_ casting pitches to music by default, this
@@ -644,11 +658,6 @@ assignment:
                parser->lexer_->set_identifier ($1, $3);
                 $$ = SCM_UNSPECIFIED;
        }
-       | assignment_id property_path '=' identifier_init {
-               SCM path = scm_cons (scm_string_to_symbol ($1), $2);
-               parser->lexer_->set_identifier (path, $4);
-                $$ = SCM_UNSPECIFIED;
-       }
        | assignment_id '.' property_path '=' identifier_init {
                SCM path = scm_cons (scm_string_to_symbol ($1), $3);
                parser->lexer_->set_identifier (path, $5);
@@ -665,6 +674,14 @@ assignment:
 identifier_init:
        identifier_init_nonumber
        | number_expression
+       | symbol_list_part_bare '.' property_path
+       {
+               $$ = scm_reverse_x ($1, $3);
+       }
+       | symbol_list_part_bare ',' property_path
+       {
+               $$ = scm_reverse_x ($1, $3);
+       }
        | post_event_nofinger post_events
        {
                $$ = scm_reverse_x ($2, SCM_EOL);
@@ -1701,9 +1718,9 @@ symbol_list_rev:
 symbol_list_part:
        symbol_list_element
        {
-               $$ = try_string_variants (Lily::symbol_list_p, $1);
+               $$ = try_string_variants (Lily::key_list_p, $1);
                if (SCM_UNBNDP ($$)) {
-                       parser->parser_error (@1, _("not a symbol"));
+                       parser->parser_error (@1, _("not a key"));
                        $$ = SCM_EOL;
                } else
                        $$ = scm_reverse ($$);
@@ -1714,8 +1731,24 @@ symbol_list_part:
 symbol_list_element:
        STRING
        | embedded_scm_bare
+       | UNSIGNED
        ;
 
+symbol_list_part_bare:
+       STRING
+       {
+               $$ = try_string_variants (Lily::key_list_p, $1);
+               if (SCM_UNBNDP ($$)) {
+                       parser->parser_error (@1, _("not a key"));
+                       $$ = SCM_EOL;
+               } else
+                       $$ = scm_reverse ($$);
+       }
+       | UNSIGNED
+       {
+               $$ = scm_list_1 ($1);
+       }
+       ;
 
 function_arglist_nonbackup:
        function_arglist_common
@@ -1887,6 +1920,8 @@ function_arglist_nonbackup_reparse:
                if (scm_is_true (scm_call_1 ($2, $4)))
                        // May be 3 \cm or similar
                        MYREPARSE (@4, $2, REAL, $4);
+               else if (scm_is_true (scm_call_1 ($2, scm_list_1 ($4))))
+                       MYREPARSE (@4, $2, SYMBOL_LIST, scm_list_1 ($4));
                else {
                        SCM d = make_duration ($4);
                        if (!SCM_UNBNDP (d)) {
@@ -1993,6 +2028,8 @@ function_arglist_backup:
                if (scm_is_true (scm_call_1 ($2, $4)))
                        // May be 3 \cm or similar
                        MYREPARSE (@4, $2, REAL, $4);
+               else if (scm_is_true (scm_call_1 ($2, scm_list_1 ($4))))
+                       MYREPARSE (@4, $2, SYMBOL_LIST, scm_list_1 ($4));
                else {
                        SCM d = make_duration ($4);
                        if (!SCM_UNBNDP (d)) {
@@ -2363,6 +2400,8 @@ function_arglist_common_reparse:
                if (scm_is_true (scm_call_1 ($1, $3)))
                        // May be 3 \cm or similar
                        MYREPARSE (@3, $1, REAL, $3);
+               else if (scm_is_true (scm_call_1 ($1, scm_list_1 ($3))))
+                       MYREPARSE (@3, $1, SYMBOL_LIST, scm_list_1 ($3));
                else {
                        SCM d = make_duration ($3);
                        if (!SCM_UNBNDP (d)) {
@@ -2558,9 +2597,6 @@ property_path:
        symbol_list_rev  {
                $$ = scm_reverse_x ($1, SCM_EOL);
        }
-       | symbol_list_rev property_path {
-               $$ = scm_reverse_x ($1, $2);
-       }
        ;
 
 property_operation:
@@ -2570,7 +2606,7 @@ property_operation:
        | UNSET symbol {
                $$ = scm_list_2 (ly_symbol2scm ("unset"), $2);
        }
-       | OVERRIDE property_path '=' scalar {
+       | OVERRIDE revert_arg '=' scalar {
                if (scm_ilength ($2) < 2) {
                        parser->parser_error (@2, _("bad grob property path"));
                        $$ = SCM_UNDEFINED;
@@ -2870,6 +2906,14 @@ scalar:
                $$ = scm_difference ($2, SCM_UNDEFINED);
        }
        | string
+       | symbol_list_part_bare '.' property_path
+       {
+               $$ = scm_reverse_x ($1, $3);
+       }
+       | symbol_list_part_bare ',' property_path
+       {
+               $$ = scm_reverse_x ($1, $3);
+       }
        ;
 
 event_chord:
@@ -4034,8 +4078,12 @@ Lily_lexer::try_special_identifiers (SCM *destination, SCM sid)
        } else if (unsmob<Score> (sid)) {
                *destination = unsmob<Score> (sid)->clone ()->unprotect ();
                return SCM_IDENTIFIER;
+       } else if (scm_is_pair (sid)
+                  && scm_is_pair (scm_car (sid))
+                  && scm_is_true (Lily::key_p (scm_caar (sid)))) {
+               *destination = sid;
+               return LOOKUP_IDENTIFIER;
        }
-
        return -1;
 }
 
@@ -4105,7 +4153,7 @@ try_string_variants (SCM pred, SCM str)
        if (scm_is_true (scm_call_1 (pred, str)))
                return str;
        // a symbol may be interpreted as a list of symbols if it helps
-       if (scm_is_symbol (str)) {
+       if (scm_is_true (Lily::key_p (str))) {
                str = scm_list_1 (str);
                if (scm_is_true (scm_call_1 (pred, str)))
                        return str;