X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fparser.yy;h=ddccd416581b9ff75667d7815a334e6804d12b90;hb=5d84bfad4626892bcffd05adcced53c8a2329047;hp=8c9c468ca474f4a4fc0adb64758d09b7e5fd08eb;hpb=f9056caac3bda31437ed004d775fbae14ca61bf3;p=lilypond.git diff --git a/lily/parser.yy b/lily/parser.yy index 8c9c468ca4..ddccd41658 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -375,7 +375,7 @@ If we give names, Bison complains. %token STRING %token SYMBOL_LIST %token TONICNAME_PITCH -%token WORD +%token SYMBOL %left '-' '+' @@ -672,7 +672,13 @@ header_block: */ assignment_id: STRING - | WORD + { + $$ = scm_string_to_symbol ($1); + } + | SYMBOL + { + $$ = scm_string_to_symbol ($1); + } ; assignment: @@ -681,15 +687,29 @@ assignment: $$ = SCM_UNSPECIFIED; } | assignment_id '.' property_path '=' identifier_init { - SCM path = scm_cons (scm_string_to_symbol ($1), $3); + SCM path = scm_cons ($1, $3); parser->lexer_->set_identifier (path, $5); $$ = SCM_UNSPECIFIED; } | assignment_id ',' property_path '=' identifier_init { - SCM path = scm_cons (scm_string_to_symbol ($1), $3); + SCM path = scm_cons ($1, $3); parser->lexer_->set_identifier (path, $5); $$ = SCM_UNSPECIFIED; } + | markup_mode_word '=' identifier_init + { + if (scm_is_false (Lily::markup_function_p ($3))) + { + parser->parser_error (@3, _ ("Not a markup function")); + } else { + scm_primitive_eval + (scm_list_3 + (Lily::define_markup_command, + scm_string_to_symbol ($1), + ly_quote_scm ($3))); + } + $$ = SCM_UNSPECIFIED; + } ; @@ -1768,7 +1788,7 @@ symbol_list_element: symbol_list_part_bare: - WORD + SYMBOL { $$ = try_word_variants (Lily::key_list_p, $1); if (SCM_UNBNDP ($$)) { @@ -1934,7 +1954,7 @@ function_arglist_nonbackup_reparse: else MYREPARSE (@4, $2, SCM_ARG, $4); } - | EXPECT_OPTIONAL EXPECT_SCM function_arglist_nonbackup WORD + | EXPECT_OPTIONAL EXPECT_SCM function_arglist_nonbackup SYMBOL { $$ = $3; SCM res = try_word_variants ($2, $4); @@ -2204,7 +2224,7 @@ function_arglist_backup: MYBACKUP (STRING, $4, @4); } } - | EXPECT_OPTIONAL EXPECT_SCM function_arglist_backup WORD + | EXPECT_OPTIONAL EXPECT_SCM function_arglist_backup SYMBOL { SCM res = try_word_variants ($2, $4); if (!SCM_UNBNDP (res)) @@ -2445,7 +2465,7 @@ function_arglist_common_reparse: // know the predicate to be false. MYREPARSE (@3, $1, SCM_ARG, $3); } - | EXPECT_SCM function_arglist_optional WORD + | EXPECT_SCM function_arglist_optional SYMBOL { $$ = $2; SCM res = try_word_variants ($1, $3); @@ -2773,7 +2793,7 @@ context_mod: | context_def_mod STRING { $$ = scm_list_2 ($1, $2); } - | context_def_mod WORD { + | context_def_mod SYMBOL { $$ = scm_list_2 ($1, $2); } | context_def_mod embedded_scm @@ -2918,13 +2938,13 @@ music_property_def: string: STRING - | WORD + | SYMBOL | full_markup ; text: STRING - | WORD + | SYMBOL | full_markup | embedded_scm_bare { @@ -2938,7 +2958,7 @@ text: ; simple_string: STRING - | WORD + | SYMBOL | embedded_scm_bare { if (scm_is_string ($1)) { @@ -2954,7 +2974,7 @@ symbol: STRING { $$ = scm_string_to_symbol ($1); } - | WORD + | SYMBOL { if (!is_regular_identifier ($1, false)) parser->parser_error (@1, (_ ("symbol expected"))); @@ -3341,7 +3361,7 @@ gen_text_def: make_simple_markup ($1)); $$ = t->unprotect (); } - | WORD { + | SYMBOL { // Flag a warning? could be unintentional Music *t = MY_MAKE_MUSIC ("TextScriptEvent", @$); t->set_property ("text", @@ -3488,7 +3508,7 @@ tremolo_type: bass_number: UNSIGNED | STRING - | WORD + | SYMBOL | full_markup | embedded_scm_bare { @@ -3675,7 +3695,7 @@ lyric_element: parser->parser_error (@1, _ ("markup outside of text script or \\lyricmode")); $$ = $1; } - | WORD { + | SYMBOL { if (!parser->lexer_->is_lyric_state ()) parser->parser_error (@1, _f ("not a note name: %s", ly_scm2string ($1))); $$ = $1; @@ -3893,11 +3913,33 @@ markup_mode: } ; +// Sort-of ugly: We need this as markup of its own as well as in +// markup function assignments, without triggering lookahead or the +// '=' for assignments will be parsed in markup mode and not +// recognized. Worse: the next token following something like +// \markup "string" would be parsed in markup mode as well. +// +// So we make a single production here that's used either in markup or +// in assignment. + +markup_mode_word: + markup_mode markup_word + { + $$ = $2; + parser->lexer_->pop_state (); + } + ; + + full_markup: markup_mode markup_top { $$ = $2; parser->lexer_->pop_state (); } + | markup_mode_word + { + $$ = make_simple_markup ($1); + } ; partial_markup: @@ -3917,7 +3959,7 @@ markup_top: $$ = scm_car (MAKE_SYNTAX (composed_markup_list, @2, $1, scm_list_1 ($2))); } - | simple_markup { + | simple_markup_noword { $$ = $1; } ; @@ -4064,14 +4106,21 @@ markup_head_1_list: } ; +markup_word: + STRING + | SYMBOL + ; + simple_markup: - STRING { - $$ = make_simple_markup ($1); - } - | WORD { + markup_word + { $$ = make_simple_markup ($1); } - | SCORE { + | simple_markup_noword + ; + +simple_markup_noword: + SCORE { parser->lexer_->push_note_state (Lily::pitchnames); } '{' score_body '}' { Score *sc = unsmob ($4);