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

Delta Between Two Patch Sets: lily/parser.yy

Issue 5298050: Allow more argument types, interpret optional argument predicates syntactically. (Closed)
Left Patch Set: Created 12 years, 5 months ago
Right Patch Set: Fix confusing toplevel behavior by too permissive \addlyrics Created 12 years, 5 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:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « lily/lexer.ll ('k') | scm/ly-syntax-constructors.scm » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 1066 matching lines...) Expand 10 before | Expand all | Expand 10 after
1077 1077
1078 braced_music_list: 1078 braced_music_list:
1079 '{' music_list '}' 1079 '{' music_list '}'
1080 { 1080 {
1081 $$ = scm_reverse_x ($2, SCM_EOL); 1081 $$ = scm_reverse_x ($2, SCM_EOL);
1082 } 1082 }
1083 ; 1083 ;
1084 1084
1085 music: 1085 music:
1086 simple_music 1086 simple_music
1087 » | composite_music 1087 » | composite_music %prec FUNCTION_ARGUMENTS
1088 ; 1088 ;
1089 1089
1090 1090
1091 repeated_music: 1091 repeated_music:
1092 REPEAT simple_string unsigned_number music 1092 REPEAT simple_string unsigned_number music
1093 { 1093 {
1094 $$ = MAKE_SYNTAX ("repeat", @$, $2, $3, $4, SCM_EOL); 1094 $$ = MAKE_SYNTAX ("repeat", @$, $2, $3, $4, SCM_EOL);
1095 } 1095 }
1096 | REPEAT simple_string unsigned_number music ALTERNATIVE braced_music_li st 1096 | REPEAT simple_string unsigned_number music ALTERNATIVE braced_music_li st
1097 { 1097 {
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
1191 /* An argument list. If a function \foo expects scm scm music, then the lexer ex pands \foo into the token sequence: 1191 /* An argument list. If a function \foo expects scm scm music, then the lexer ex pands \foo into the token sequence:
1192 MUSIC_FUNCTION EXPECT_MUSIC EXPECT_SCM EXPECT_SCM EXPECT_NO_MORE_ARGS 1192 MUSIC_FUNCTION EXPECT_MUSIC EXPECT_SCM EXPECT_SCM EXPECT_NO_MORE_ARGS
1193 and this rule returns the reversed list of arguments. */ 1193 and this rule returns the reversed list of arguments. */
1194 1194
1195 1195
1196 function_arglist: 1196 function_arglist:
1197 function_arglist_bare 1197 function_arglist_bare
1198 | EXPECT_MUSIC function_arglist_optional music 1198 | EXPECT_MUSIC function_arglist_optional music
1199 { 1199 {
1200 $$ = scm_cons ($3, $2); 1200 $$ = scm_cons ($3, $2);
1201 » } %prec FUNCTION_ARGUMENTS 1201 » }
1202 | EXPECT_SCM function_arglist_optional embedded_scm_arg 1202 | EXPECT_SCM function_arglist_optional embedded_scm_arg
1203 { 1203 {
1204 $$ = check_scheme_arg (PARSER, @3, SCM_UNDEFINED, $3, $2, $1); 1204 $$ = check_scheme_arg (PARSER, @3, SCM_UNDEFINED, $3, $2, $1);
1205 } 1205 }
1206 ; 1206 ;
1207 1207
1208 function_arglist_optional: 1208 function_arglist_optional:
1209 function_arglist_keep %prec FUNCTION_ARGUMENTS 1209 function_arglist_keep %prec FUNCTION_ARGUMENTS
1210 | EXPECT_OPTIONAL EXPECT_MUSIC function_arglist_optional 1210 | EXPECT_OPTIONAL EXPECT_MUSIC function_arglist_optional
1211 { 1211 {
1212 $$ = scm_cons (loc_on_music (@3, $1), $3); 1212 $$ = scm_cons (loc_on_music (@3, $1), $3);
1213 } 1213 }
1214 | EXPECT_OPTIONAL EXPECT_PITCH function_arglist_optional 1214 | EXPECT_OPTIONAL EXPECT_PITCH function_arglist_optional
1215 { 1215 {
1216 $$ = scm_cons ($1, $3); 1216 $$ = scm_cons ($1, $3);
1217 } 1217 }
1218 | EXPECT_OPTIONAL EXPECT_DURATION function_arglist_optional 1218 | EXPECT_OPTIONAL EXPECT_DURATION function_arglist_optional
1219 { 1219 {
1220 $$ = scm_cons ($1, $3); 1220 $$ = scm_cons ($1, $3);
1221 } 1221 }
1222 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_optional 1222 | EXPECT_OPTIONAL EXPECT_SCM function_arglist_optional
1223 { 1223 {
1224 » » $$ = scm_cons ($1, $3); 1224 » » $$ = scm_cons (loc_on_music (@3, $1), $3);
1225 } 1225 }
1226 ; 1226 ;
1227 1227
1228 function_arglist_keep: 1228 function_arglist_keep:
1229 EXPECT_OPTIONAL EXPECT_PITCH function_arglist_keep pitch_also_in_chords { 1229 EXPECT_OPTIONAL EXPECT_PITCH function_arglist_keep pitch_also_in_chords {
1230 $$ = scm_cons ($4, $3); 1230 $$ = scm_cons ($4, $3);
1231 } 1231 }
1232 | EXPECT_OPTIONAL EXPECT_DURATION function_arglist_closed_keep duration_ length { 1232 | EXPECT_OPTIONAL EXPECT_DURATION function_arglist_closed_keep duration_ length {
1233 $$ = scm_cons ($4, $3); 1233 $$ = scm_cons ($4, $3);
1234 } 1234 }
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
1354 } 1354 }
1355 ; 1355 ;
1356 1356
1357 complex_music: 1357 complex_music:
1358 music_function_call 1358 music_function_call
1359 | repeated_music { $$ = $1; } 1359 | repeated_music { $$ = $1; }
1360 | re_rhythmed_music { $$ = $1; } 1360 | re_rhythmed_music { $$ = $1; }
1361 | complex_music_prefix music 1361 | complex_music_prefix music
1362 { 1362 {
1363 $$ = FINISH_MAKE_SYNTAX ($1, @$, $2); 1363 $$ = FINISH_MAKE_SYNTAX ($1, @$, $2);
1364 » } %prec FUNCTION_ARGUMENTS 1364 » }
1365 ; 1365 ;
1366 1366
1367 complex_music_prefix: 1367 complex_music_prefix:
1368 CONTEXT simple_string optional_id optional_context_mod { 1368 CONTEXT simple_string optional_id optional_context_mod {
1369 Context_mod *ctxmod = unsmob_context_mod ($4); 1369 Context_mod *ctxmod = unsmob_context_mod ($4);
1370 SCM mods = SCM_EOL; 1370 SCM mods = SCM_EOL;
1371 if (ctxmod) 1371 if (ctxmod)
1372 mods = ctxmod->get_mods (); 1372 mods = ctxmod->get_mods ();
1373 $$ = START_MAKE_SYNTAX ("context-specification", $2, $3, mods, S CM_BOOL_F); 1373 $$ = START_MAKE_SYNTAX ("context-specification", $2, $3, mods, S CM_BOOL_F);
1374 } 1374 }
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
1464 } 1464 }
1465 | LYRICS 1465 | LYRICS
1466 { PARSER->lexer_->push_lyric_state (); 1466 { PARSER->lexer_->push_lyric_state ();
1467 $$ = ly_symbol2scm ("Lyrics"); 1467 $$ = ly_symbol2scm ("Lyrics");
1468 } 1468 }
1469 ; 1469 ;
1470 1470
1471 new_lyrics: 1471 new_lyrics:
1472 ADDLYRICS { PARSER->lexer_->push_lyric_state (); } 1472 ADDLYRICS { PARSER->lexer_->push_lyric_state (); }
1473 /*cont */ 1473 /*cont */
1474 » music { 1474 » composite_music {
1475 /* Can also use music at the expensive of two S/Rs similar to 1475 /* Can also use music at the expensive of two S/Rs similar to
1476 \repeat \alternative */ 1476 \repeat \alternative */
1477 PARSER->lexer_->pop_state (); 1477 PARSER->lexer_->pop_state ();
1478 1478
1479 $$ = scm_cons ($3, SCM_EOL); 1479 $$ = scm_cons ($3, SCM_EOL);
1480 } 1480 }
1481 | new_lyrics ADDLYRICS { 1481 | new_lyrics ADDLYRICS {
1482 PARSER->lexer_->push_lyric_state (); 1482 PARSER->lexer_->push_lyric_state ();
1483 » } music { 1483 » } composite_music {
1484 PARSER->lexer_->pop_state (); 1484 PARSER->lexer_->pop_state ();
1485 $$ = scm_cons ($4, $1); 1485 $$ = scm_cons ($4, $1);
1486 } 1486 }
1487 ; 1487 ;
1488 1488
1489 re_rhythmed_music: 1489 re_rhythmed_music:
1490 » music new_lyrics { 1490 » composite_music new_lyrics {
1491 $$ = MAKE_SYNTAX ("add-lyrics", @$, $1, scm_reverse_x ($2, SCM_E OL)); 1491 $$ = MAKE_SYNTAX ("add-lyrics", @$, $1, scm_reverse_x ($2, SCM_E OL));
1492 } %prec FUNCTION_ARGUMENTS 1492 } %prec FUNCTION_ARGUMENTS
1493 | LYRICSTO simple_string { 1493 | LYRICSTO simple_string {
1494 PARSER->lexer_->push_lyric_state (); 1494 PARSER->lexer_->push_lyric_state ();
1495 } music { 1495 } music {
1496 PARSER->lexer_->pop_state (); 1496 PARSER->lexer_->pop_state ();
1497 $$ = MAKE_SYNTAX ("lyric-combine", @$, $2, $4); 1497 $$ = MAKE_SYNTAX ("lyric-combine", @$, $2, $4);
1498 » } %prec FUNCTION_ARGUMENTS 1498 » }
1499 ; 1499 ;
1500 1500
1501 context_change: 1501 context_change:
1502 CHANGE STRING '=' STRING { 1502 CHANGE STRING '=' STRING {
1503 $$ = MAKE_SYNTAX ("context-change", @$, scm_string_to_symbol ($2 ), $4); 1503 $$ = MAKE_SYNTAX ("context-change", @$, scm_string_to_symbol ($2 ), $4);
1504 } 1504 }
1505 ; 1505 ;
1506 1506
1507 1507
1508 property_path_revved: 1508 property_path_revved:
(...skipping 1517 matching lines...) Expand 10 before | Expand all | Expand 10 after
3026 yylex (YYSTYPE *s, YYLTYPE *loc, void *v) 3026 yylex (YYSTYPE *s, YYLTYPE *loc, void *v)
3027 { 3027 {
3028 Lily_parser *pars = (Lily_parser*) v; 3028 Lily_parser *pars = (Lily_parser*) v;
3029 Lily_lexer *lex = pars->lexer_; 3029 Lily_lexer *lex = pars->lexer_;
3030 3030
3031 lex->lexval_ = (void*) s; 3031 lex->lexval_ = (void*) s;
3032 lex->lexloc_ = loc; 3032 lex->lexloc_ = loc;
3033 lex->prepare_for_next_token (); 3033 lex->prepare_for_next_token ();
3034 return lex->yylex (); 3034 return lex->yylex ();
3035 } 3035 }
LEFTRIGHT

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