X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fparser.yy;h=48dc5680b3bc5cae6b1d16fa962a50b68e2e8d96;hb=999595939c26d7f060ca73c6fd537248962942e0;hp=cda631865443a1fe04b820d56b223f4658604094;hpb=785441aeb8cc557217d1b0658ef88d058f58eeb4;p=lilypond.git diff --git a/lily/parser.yy b/lily/parser.yy index cda6318654..48dc5680b3 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -113,7 +113,7 @@ or -%pure_parser +%pure-parser %locations @@ -309,16 +309,8 @@ int yylex (YYSTYPE *s, YYLTYPE *loc, Lily_parser *parser); %token DOUBLE_ANGLE_OPEN "<<" %token DOUBLE_ANGLE_CLOSE ">>" %token E_BACKSLASH "\\" -%token E_ANGLE_CLOSE "\\>" -%token E_CHAR "\\C[haracter]" -%token E_CLOSE "\\)" %token E_EXCLAMATION "\\!" -%token E_BRACKET_OPEN "\\[" -%token E_OPEN "\\(" -%token E_BRACKET_CLOSE "\\]" -%token E_ANGLE_OPEN "\\<" %token E_PLUS "\\+" -%token E_TILDE "\\~" %token EXTENDER "__" /* @@ -635,7 +627,16 @@ context_def_spec_block: context_mod_arg: embedded_scm - | composite_music + | + { + SCM nn = parser->lexer_->lookup_identifier ("pitchnames"); + parser->lexer_->push_note_state (nn); + } + composite_music + { + parser->lexer_->pop_state (); + $$ = $2; + } ; context_mod_embedded: @@ -1046,9 +1047,9 @@ music_embedded: $$ = SCM_UNSPECIFIED; } } - | music_embedded_backup BACKUP SCM_ARG + | music_embedded_backup { - $$ = $3; + $$ = $1; } | music_embedded_backup BACKUP lyric_element_music { @@ -1057,23 +1058,23 @@ music_embedded: ; music_embedded_backup: - embedded_scm_closed + embedded_scm { if (scm_is_eq ($1, SCM_UNSPECIFIED)) - MYBACKUP (SCM_ARG, $1, @1); + $$ = $1; else if (Music *m = unsmob_music ($1)) { if (m->is_mus_type ("post-event")) { parser->parser_error (@1, _ ("unexpected post-event")); - MYBACKUP (SCM_ARG, SCM_UNSPECIFIED, @1); + $$ = SCM_UNSPECIFIED; } else - MYBACKUP (SCM_ARG, $1, @1); + $$ = $1; } else if (parser->lexer_->is_lyric_state () && Text_interface::is_markup ($1)) MYBACKUP (LYRIC_ELEMENT, $1, @1); else { @$.warning (_ ("Ignoring non-music expression")); - MYBACKUP (SCM_ARG, SCM_UNSPECIFIED, @1); + $$ = $1; } } ; @@ -1885,14 +1886,14 @@ complex_music: ; complex_music_prefix: - CONTEXT simple_string optional_id optional_context_mod { + CONTEXT symbol optional_id optional_context_mod { Context_mod *ctxmod = unsmob_context_mod ($4); SCM mods = SCM_EOL; if (ctxmod) mods = ctxmod->get_mods (); $$ = START_MAKE_SYNTAX ("context-specification", $2, $3, mods, SCM_BOOL_F); } - | NEWCONTEXT simple_string optional_id optional_context_mod { + | NEWCONTEXT symbol optional_id optional_context_mod { Context_mod *ctxmod = unsmob_context_mod ($4); SCM mods = SCM_EOL; if (ctxmod) @@ -2032,13 +2033,11 @@ property_path: ; property_operation: - STRING '=' scalar { - $$ = scm_list_3 (ly_symbol2scm ("assign"), - scm_string_to_symbol ($1), $3); + symbol '=' scalar { + $$ = scm_list_3 (ly_symbol2scm ("assign"), $1, $3); } - | UNSET simple_string { - $$ = scm_list_2 (ly_symbol2scm ("unset"), - scm_string_to_symbol ($2)); + | UNSET symbol { + $$ = scm_list_2 (ly_symbol2scm ("unset"), $2); } | OVERRIDE property_path '=' scalar { if (scm_ilength ($2) < 2) { @@ -2288,17 +2287,6 @@ string: $$ = $1; } | full_markup - | string '+' string { - if (!scm_is_string ($1)) { - parser->parser_error (@1, (_ ("simple string expected"))); - $1 = scm_string (SCM_EOL); - } - if (!scm_is_string ($3)) { - parser->parser_error (@3, (_ ("simple string expected"))); - $3 = scm_string (SCM_EOL); - } - $$ = scm_string_append (scm_list_2 ($1, $3)); - } ; simple_string: STRING { @@ -2315,6 +2303,26 @@ simple_string: STRING { } ; +symbol: + STRING { + $$ = scm_string_to_symbol ($1); + } + | embedded_scm_bare + { + // This is a bit of overkill but makes the same + // routine responsible for all symbol interpretations. + $$ = try_string_variants (ly_lily_module_constant ("symbol?"), + $1); + if (SCM_UNBNDP ($$)) + { + parser->parser_error (@1, (_ ("symbol expected"))); + // Generate a unique symbol in case it is used + // for an assignment or similar + $$ = scm_make_symbol (ly_string2scm ("undefined")); + } + } + ; + scalar: embedded_scm_arg | SCM_IDENTIFIER @@ -2484,40 +2492,10 @@ command_element: command_event { $$ = $1; } - | E_BRACKET_OPEN { - Music *m = MY_MAKE_MUSIC ("LigatureEvent", @$); - m->set_property ("span-direction", scm_from_int (START)); - $$ = m->unprotect(); - } - | E_BRACKET_CLOSE { - Music *m = MY_MAKE_MUSIC ("LigatureEvent", @$); - m->set_property ("span-direction", scm_from_int (STOP)); - $$ = m->unprotect (); - } - | E_BACKSLASH { - $$ = MAKE_SYNTAX ("voice-separator", @$); - } - | '|' { - SCM pipe = parser->lexer_->lookup_identifier ("pipeSymbol"); - - Music *m = unsmob_music (pipe); - if (m) - { - m = m->clone (); - m->set_spot (@$); - $$ = m->unprotect (); - } - else - $$ = MAKE_SYNTAX ("bar-check", @$); - - } ; command_event: - E_TILDE { - $$ = MY_MAKE_MUSIC ("PesOrFlexaEvent", @$)->unprotect (); - } - | tempo_event { + tempo_event { $$ = $1; } ; @@ -2614,55 +2592,8 @@ string_number_event: } ; -direction_less_char: - '[' { - $$ = ly_symbol2scm ("bracketOpenSymbol"); - } - | ']' { - $$ = ly_symbol2scm ("bracketCloseSymbol"); - } - | '~' { - $$ = ly_symbol2scm ("tildeSymbol"); - } - | '(' { - $$ = ly_symbol2scm ("parenthesisOpenSymbol"); - } - | ')' { - $$ = ly_symbol2scm ("parenthesisCloseSymbol"); - } - | E_EXCLAMATION { - $$ = ly_symbol2scm ("escapedExclamationSymbol"); - } - | E_OPEN { - $$ = ly_symbol2scm ("escapedParenthesisOpenSymbol"); - } - | E_CLOSE { - $$ = ly_symbol2scm ("escapedParenthesisCloseSymbol"); - } - | E_ANGLE_CLOSE { - $$ = ly_symbol2scm ("escapedBiggerSymbol"); - } - | E_ANGLE_OPEN { - $$ = ly_symbol2scm ("escapedSmallerSymbol"); - } - ; - direction_less_event: - direction_less_char { - SCM predefd = parser->lexer_->lookup_identifier_symbol ($1); - Music *m = 0; - if (unsmob_music (predefd)) - { - m = unsmob_music (predefd)->clone (); - m->set_spot (@$); - } - else - { - m = MY_MAKE_MUSIC ("Music", @$); - } - $$ = m->unprotect (); - } - | string_number_event + string_number_event | EVENT_IDENTIFIER { $$ = $1; } @@ -2800,8 +2731,8 @@ script_abbreviation: | '-' { $$ = scm_from_locale_string ("Dash"); } - | '|' { - $$ = scm_from_locale_string ("Bar"); + | '!' { + $$ = scm_from_locale_string ("Bang"); } | ANGLE_CLOSE { $$ = scm_from_locale_string ("Larger"); @@ -2958,38 +2889,23 @@ bass_figure: } | bass_figure figured_bass_modification { Music *m = unsmob_music ($1); - if ($2 == ly_symbol2scm ("plus")) - { - m->set_property ("augmented", SCM_BOOL_T); - } - else if ($2 == ly_symbol2scm ("slash")) - { - m->set_property ("diminished", SCM_BOOL_T); - } - else if ($2 == ly_symbol2scm ("exclamation")) - { - m->set_property ("no-continuation", SCM_BOOL_T); - } - else if ($2 == ly_symbol2scm ("backslash")) - { - m->set_property ("augmented-slash", SCM_BOOL_T); - } + m->set_property ($2, SCM_BOOL_T); } ; figured_bass_modification: E_PLUS { - $$ = ly_symbol2scm ("plus"); + $$ = ly_symbol2scm ("augmented"); } | E_EXCLAMATION { - $$ = ly_symbol2scm ("exclamation"); + $$ = ly_symbol2scm ("no-continuation"); } | '/' { - $$ = ly_symbol2scm ("slash"); + $$ = ly_symbol2scm ("diminished"); } | E_BACKSLASH { - $$ = ly_symbol2scm ("backslash"); + $$ = ly_symbol2scm ("augmented-slash"); } ; @@ -3188,7 +3104,7 @@ tempo_range: UNSIGNED { $$ = $1; } - | UNSIGNED '~' UNSIGNED { + | UNSIGNED '-' UNSIGNED { $$ = scm_cons ($1, $3); } ;