Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(756)

Side by Side Diff: lily/parser.yy

Issue 5339043: parser.yy: allow postevents in function arguments in general (Closed)
Patch Set: Rebased on current dev/staging, ready for review. Created 12 years, 4 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 This file is part of LilyPond, the GNU music typesetter. 2 This file is part of LilyPond, the GNU music typesetter.
3 3
4 Copyright (C) 1997--2011 Han-Wen Nienhuys <hanwen@xs4all.nl> 4 Copyright (C) 1997--2011 Han-Wen Nienhuys <hanwen@xs4all.nl>
5 Jan Nieuwenhuizen <janneke@gnu.org> 5 Jan Nieuwenhuizen <janneke@gnu.org>
6 6
7 LilyPond is free software: you can redistribute it and/or modify 7 LilyPond is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by 8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or 9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version. 10 (at your option) any later version.
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 %type <scm> context_prop_spec 456 %type <scm> context_prop_spec
457 %type <scm> direction_less_char 457 %type <scm> direction_less_char
458 %type <scm> duration_length 458 %type <scm> duration_length
459 %type <scm> embedded_scm 459 %type <scm> embedded_scm
460 %type <scm> embedded_scm_arg 460 %type <scm> embedded_scm_arg
461 %type <scm> embedded_scm_arg_closed 461 %type <scm> embedded_scm_arg_closed
462 %type <scm> embedded_scm_bare 462 %type <scm> embedded_scm_bare
463 %type <scm> embedded_scm_bare_arg 463 %type <scm> embedded_scm_bare_arg
464 %type <scm> embedded_scm_closed 464 %type <scm> embedded_scm_closed
465 %type <scm> embedded_scm_chord_body 465 %type <scm> embedded_scm_chord_body
466 %type <scm> embedded_scm_event
467 %type <scm> event_function_event 466 %type <scm> event_function_event
468 %type <scm> figure_list 467 %type <scm> figure_list
469 %type <scm> figure_spec 468 %type <scm> figure_spec
470 %type <scm> fraction 469 %type <scm> fraction
471 %type <scm> full_markup 470 %type <scm> full_markup
472 %type <scm> full_markup_list 471 %type <scm> full_markup_list
473 %type <scm> function_arglist 472 %type <scm> function_arglist
474 %type <scm> function_arglist_optional 473 %type <scm> function_arglist_optional
475 %type <scm> function_arglist_backup 474 %type <scm> function_arglist_backup
476 %type <scm> function_arglist_nonbackup 475 %type <scm> function_arglist_nonbackup
(...skipping 22 matching lines...) Expand all
499 %type <scm> markup_command_list_arguments 498 %type <scm> markup_command_list_arguments
500 %type <scm> markup_command_basic_arguments 499 %type <scm> markup_command_basic_arguments
501 %type <scm> markup_head_1_item 500 %type <scm> markup_head_1_item
502 %type <scm> markup_head_1_list 501 %type <scm> markup_head_1_list
503 %type <scm> markup_list 502 %type <scm> markup_list
504 %type <scm> markup_top 503 %type <scm> markup_top
505 %type <scm> mode_changing_head 504 %type <scm> mode_changing_head
506 %type <scm> mode_changing_head_with_context 505 %type <scm> mode_changing_head_with_context
507 %type <scm> multiplied_duration 506 %type <scm> multiplied_duration
508 %type <scm> music_function_event 507 %type <scm> music_function_event
509 %type <scm> music_function_event_arglist
510 %type <scm> music_function_chord_body 508 %type <scm> music_function_chord_body
511 %type <scm> music_function_chord_body_arglist 509 %type <scm> music_function_chord_body_arglist
512 %type <scm> new_chord 510 %type <scm> new_chord
513 %type <scm> new_lyrics 511 %type <scm> new_lyrics
514 %type <scm> number_expression 512 %type <scm> number_expression
515 %type <scm> number_factor 513 %type <scm> number_factor
516 %type <scm> number_term 514 %type <scm> number_term
517 %type <scm> octave_check 515 %type <scm> octave_check
518 %type <scm> optional_context_mod 516 %type <scm> optional_context_mod
519 %type <scm> optional_id 517 %type <scm> optional_id
(...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after
1271 $$ = check_scheme_arg (PARSER, @4, $1, $4, $3, $2); 1269 $$ = check_scheme_arg (PARSER, @4, $1, $4, $3, $2);
1272 } 1270 }
1273 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_closed bare_number 1271 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_closed bare_number
1274 { 1272 {
1275 $$ = check_scheme_arg (PARSER, @4, $1, $4, $3, $2); 1273 $$ = check_scheme_arg (PARSER, @4, $1, $4, $3, $2);
1276 } 1274 }
1277 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_closed fraction 1275 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_closed fraction
1278 { 1276 {
1279 $$ = check_scheme_arg (PARSER, @4, $1, $4, $3, $2); 1277 $$ = check_scheme_arg (PARSER, @4, $1, $4, $3, $2);
1280 } 1278 }
1279 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_closed post_event
1280 {
1281 $$ = check_scheme_arg (PARSER, @4, $1, $4, $3, $2);
1282 }
1281 ; 1283 ;
1282 1284
1283 1285
1284 function_arglist_keep: 1286 function_arglist_keep:
1285 function_arglist_common 1287 function_arglist_common
1286 | function_arglist_backup 1288 | function_arglist_backup
1287 ; 1289 ;
1288 1290
1289 function_arglist_closed_keep: 1291 function_arglist_closed_keep:
1290 function_arglist_closed_common 1292 function_arglist_closed_common
1291 | function_arglist_backup 1293 | function_arglist_backup
1292 ; 1294 ;
1293 1295
1294 function_arglist_backup: 1296 function_arglist_backup:
1295 EXPECT_OPTIONAL EXPECT_SCM function_arglist_keep embedded_scm_arg_closed 1297 EXPECT_OPTIONAL EXPECT_SCM function_arglist_keep embedded_scm_arg_closed
1296 { 1298 {
1297 if (scm_is_true (scm_call_1 ($2, $4))) 1299 if (scm_is_true (scm_call_1 ($2, $4)))
1298 { 1300 {
1299 $$ = scm_cons ($4, $3); 1301 $$ = scm_cons ($4, $3);
1300 } else { 1302 } else {
1301 $$ = scm_cons (loc_on_music (@3, $1), $3); 1303 $$ = scm_cons (loc_on_music (@3, $1), $3);
1302 MYBACKUP (SCM_IDENTIFIER, $4, @4); 1304 MYBACKUP (SCM_IDENTIFIER, $4, @4);
1303 } 1305 }
1304 } 1306 }
1307 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_closed_keep post_event
1308 {
1309 if (scm_is_true (scm_call_1 ($2, $4)))
1310 {
1311 $$ = scm_cons ($4, $3);
1312 } else {
1313 $$ = scm_cons (loc_on_music (@3, $1), $3);
1314 MYBACKUP (EVENT_IDENTIFIER, $4, @4);
1315 }
1316 }
1305 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_keep lyric_element 1317 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_keep lyric_element
1306 { 1318 {
1307 // There is no point interpreting a lyrics string as 1319 // There is no point interpreting a lyrics string as
1308 // an event, since we don't allow music possibly 1320 // an event, since we don't allow music possibly
1309 // followed by durations or postevent into closed 1321 // followed by durations or postevent into closed
1310 // music, and we only accept closed music in optional 1322 // music, and we only accept closed music in optional
1311 // arguments at the moment. If this changes, more 1323 // arguments at the moment. If this changes, more
1312 // complex schemes might become interesting here as 1324 // complex schemes might become interesting here as
1313 // well: see how we do this at the mandatory argument 1325 // well: see how we do this at the mandatory argument
1314 // point. 1326 // point.
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
1406 | EXPECT_SCM function_arglist_closed_optional bare_number 1418 | EXPECT_SCM function_arglist_closed_optional bare_number
1407 { 1419 {
1408 $$ = check_scheme_arg (PARSER, @3, SCM_UNDEFINED, 1420 $$ = check_scheme_arg (PARSER, @3, SCM_UNDEFINED,
1409 $3, $2, $1); 1421 $3, $2, $1);
1410 } 1422 }
1411 | EXPECT_SCM function_arglist_closed_optional fraction 1423 | EXPECT_SCM function_arglist_closed_optional fraction
1412 { 1424 {
1413 $$ = check_scheme_arg (PARSER, @3, SCM_UNDEFINED, 1425 $$ = check_scheme_arg (PARSER, @3, SCM_UNDEFINED,
1414 $3, $2, $1); 1426 $3, $2, $1);
1415 } 1427 }
1428 | EXPECT_SCM function_arglist_closed_optional post_event
1429 {
1430 $$ = check_scheme_arg (PARSER, @3, SCM_UNDEFINED,
1431 $3, $2, $1);
1432 }
1416 | function_arglist_common_lyric 1433 | function_arglist_common_lyric
1417 ; 1434 ;
1418 1435
1419 function_arglist_common_lyric: 1436 function_arglist_common_lyric:
1420 EXPECT_SCM function_arglist_optional lyric_element 1437 EXPECT_SCM function_arglist_optional lyric_element
1421 { 1438 {
1422 // We check how the predicate thinks about a lyrics 1439 // We check how the predicate thinks about a lyrics
1423 // event or about a markup. If it accepts neither, we 1440 // event or about a markup. If it accepts neither, we
1424 // backup the original token. Otherwise we commit to 1441 // backup the original token. Otherwise we commit to
1425 // taking the token. Depending on what the predicate 1442 // taking the token. Depending on what the predicate
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1466 | EXPECT_SCM function_arglist_optional embedded_scm_arg_closed 1483 | EXPECT_SCM function_arglist_optional embedded_scm_arg_closed
1467 { 1484 {
1468 $$ = check_scheme_arg (PARSER, @3, SCM_UNDEFINED, 1485 $$ = check_scheme_arg (PARSER, @3, SCM_UNDEFINED,
1469 $3, $2, $1); 1486 $3, $2, $1);
1470 } 1487 }
1471 | EXPECT_SCM function_arglist_closed_optional bare_number_closed 1488 | EXPECT_SCM function_arglist_closed_optional bare_number_closed
1472 { 1489 {
1473 $$ = check_scheme_arg (PARSER, @3, SCM_UNDEFINED, 1490 $$ = check_scheme_arg (PARSER, @3, SCM_UNDEFINED,
1474 $3, $2, $1); 1491 $3, $2, $1);
1475 } 1492 }
1493 | EXPECT_SCM function_arglist_closed_optional post_event
1494 {
1495 $$ = check_scheme_arg (PARSER, @3, SCM_UNDEFINED,
1496 $3, $2, $1);
1497 }
1476 | EXPECT_SCM function_arglist_closed_optional FRACTION 1498 | EXPECT_SCM function_arglist_closed_optional FRACTION
1477 { 1499 {
1478 $$ = check_scheme_arg (PARSER, @3, SCM_UNDEFINED, 1500 $$ = check_scheme_arg (PARSER, @3, SCM_UNDEFINED,
1479 $3, $2, $1); 1501 $3, $2, $1);
1480 } 1502 }
1481 | EXPECT_SCM function_arglist_optional lyric_element 1503 | EXPECT_SCM function_arglist_optional lyric_element
1482 { 1504 {
1483 $$ = check_scheme_arg (PARSER, @3, SCM_UNDEFINED, 1505 $$ = check_scheme_arg (PARSER, @3, SCM_UNDEFINED,
1484 $3, $2, $1); 1506 $3, $2, $1);
1485 } 1507 }
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after
2005 | chord_body_element 2027 | chord_body_element
2006 ; 2028 ;
2007 2029
2008 music_function_chord_body: 2030 music_function_chord_body:
2009 MUSIC_FUNCTION music_function_chord_body_arglist { 2031 MUSIC_FUNCTION music_function_chord_body_arglist {
2010 $$ = MAKE_SYNTAX ("music-function", @$, 2032 $$ = MAKE_SYNTAX ("music-function", @$,
2011 $1, $2); 2033 $1, $2);
2012 } 2034 }
2013 ; 2035 ;
2014 2036
2015 /* We could accept a closed music argument before the post events 2037 // Event functions may only take closed arglists, otherwise it would
2016 * indicated by a trailing argument list. For symmetry with chord 2038 // not be clear whether a following postevent should be associated
2017 * bodies and in order to avoid too tricky and complex behavior, we 2039 // with the last argument of the event function or with the expression
2018 * refrain from doing so. 2040 // for which the function call acts itself as event.
2019 */
2020 music_function_event_arglist:
2021 » function_arglist_bare
2022 » | EXPECT_SCM music_function_event_arglist embedded_scm_event
2023 » {
2024 » » $$ = check_scheme_arg (PARSER, @3, SCM_UNDEFINED,
2025 » » » » $3, $2, $1);
2026 » }
2027 » ;
2028
2029 embedded_scm_event:
2030 » embedded_scm_bare_arg
2031 » | SCM_FUNCTION music_function_event_arglist {
2032 » » $$ = MAKE_SYNTAX ("music-function", @$,
2033 » » » » » $1, $2);
2034 » }
2035 » | bare_number
2036 » | fraction
2037 » | lyric_element
2038 » | post_event
2039 » ;
2040 2041
2041 music_function_event: 2042 music_function_event:
2042 » MUSIC_FUNCTION music_function_event_arglist { 2043 » MUSIC_FUNCTION function_arglist_closed {
2043 $$ = MAKE_SYNTAX ("music-function", @$, 2044 $$ = MAKE_SYNTAX ("music-function", @$,
2044 $1, $2); 2045 $1, $2);
2045 } 2046 }
2046 ; 2047 ;
2047 2048
2048 event_function_event: 2049 event_function_event:
2049 » EVENT_FUNCTION music_function_event_arglist { 2050 » EVENT_FUNCTION function_arglist_closed {
2050 $$ = MAKE_SYNTAX ("music-function", @$, 2051 $$ = MAKE_SYNTAX ("music-function", @$,
2051 $1, $2); 2052 $1, $2);
2052 } 2053 }
2053 ; 2054 ;
2054 2055
2055 command_element: 2056 command_element:
2056 command_event { 2057 command_event {
2057 $$ = $1; 2058 $$ = $1;
2058 } 2059 }
2059 | E_BRACKET_OPEN { 2060 | E_BRACKET_OPEN {
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
2311 pitch 2312 pitch
2312 | steno_tonic_pitch 2313 | steno_tonic_pitch
2313 ; 2314 ;
2314 2315
2315 gen_text_def: 2316 gen_text_def:
2316 full_markup { 2317 full_markup {
2317 Music *t = MY_MAKE_MUSIC ("TextScriptEvent", @$); 2318 Music *t = MY_MAKE_MUSIC ("TextScriptEvent", @$);
2318 t->set_property ("text", $1); 2319 t->set_property ("text", $1);
2319 $$ = t->unprotect (); 2320 $$ = t->unprotect ();
2320 } 2321 }
2321 » | string { 2322 » | simple_string {
2322 Music *t = MY_MAKE_MUSIC ("TextScriptEvent", @$); 2323 Music *t = MY_MAKE_MUSIC ("TextScriptEvent", @$);
2323 t->set_property ("text", 2324 t->set_property ("text",
2324 make_simple_markup ($1)); 2325 make_simple_markup ($1));
2325 $$ = t->unprotect (); 2326 $$ = t->unprotect ();
2326 } 2327 }
2327 ; 2328 ;
2328 2329
2329 fingering: 2330 fingering:
2330 UNSIGNED { 2331 UNSIGNED {
2331 Music *t = MY_MAKE_MUSIC ("FingeringEvent", @$); 2332 Music *t = MY_MAKE_MUSIC ("FingeringEvent", @$);
(...skipping 892 matching lines...) Expand 10 before | Expand all | Expand 10 after
3224 yylex (YYSTYPE *s, YYLTYPE *loc, void *v) 3225 yylex (YYSTYPE *s, YYLTYPE *loc, void *v)
3225 { 3226 {
3226 Lily_parser *pars = (Lily_parser*) v; 3227 Lily_parser *pars = (Lily_parser*) v;
3227 Lily_lexer *lex = pars->lexer_; 3228 Lily_lexer *lex = pars->lexer_;
3228 3229
3229 lex->lexval_ = (void*) s; 3230 lex->lexval_ = (void*) s;
3230 lex->lexloc_ = loc; 3231 lex->lexloc_ = loc;
3231 lex->prepare_for_next_token (); 3232 lex->prepare_for_next_token ();
3232 return lex->yylex (); 3233 return lex->yylex ();
3233 } 3234 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b