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

Side by Side Diff: lily/parser.yy

Issue 557410043: Special-case syntax error of duration before octave marks (Closed)
Patch Set: Created 4 years, 1 month 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 /* -*- mode: c++; c-file-style: "linux"; indent-tabs-mode: t -*- */ 1 /* -*- mode: c++; c-file-style: "linux"; indent-tabs-mode: t -*- */
2 /* 2 /*
3 This file is part of LilyPond, the GNU music typesetter. 3 This file is part of LilyPond, the GNU music typesetter.
4 4
5 Copyright (C) 1997--2020 Han-Wen Nienhuys <hanwen@xs4all.nl> 5 Copyright (C) 1997--2020 Han-Wen Nienhuys <hanwen@xs4all.nl>
6 Jan Nieuwenhuizen <janneke@gnu.org> 6 Jan Nieuwenhuizen <janneke@gnu.org>
7 7
8 LilyPond is free software: you can redistribute it and/or modify 8 LilyPond is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by 9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or 10 the Free Software Foundation, either version 3 of the License, or
(...skipping 3276 matching lines...) Expand 10 before | Expand all | Expand 10 after
3287 3287
3288 quotes: 3288 quotes:
3289 /* empty */ 3289 /* empty */
3290 { 3290 {
3291 $$ = SCM_INUM0; 3291 $$ = SCM_INUM0;
3292 } 3292 }
3293 | sub_quotes 3293 | sub_quotes
3294 | sup_quotes 3294 | sup_quotes
3295 ; 3295 ;
3296 3296
3297 stray_quotes:
3298 sub_quotes
3299 | sup_quotes
3300 ;
3301
3297 sup_quotes: 3302 sup_quotes:
3298 '\'' { 3303 '\'' {
3299 $$ = scm_from_int (1); 3304 $$ = scm_from_int (1);
3300 } 3305 }
3301 | sup_quotes '\'' { 3306 | sup_quotes '\'' {
3302 $$ = scm_oneplus ($1); 3307 $$ = scm_oneplus ($1);
3303 } 3308 }
3304 ; 3309 ;
3305 3310
3306 sub_quotes: 3311 sub_quotes:
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
3654 if (to_boolean ($3)) 3659 if (to_boolean ($3))
3655 n->set_property ("cautionary", SCM_BOOL_T); 3660 n->set_property ("cautionary", SCM_BOOL_T);
3656 if (to_boolean ($2) || to_boolean ($3)) 3661 if (to_boolean ($2) || to_boolean ($3))
3657 n->set_property ("force-accidental", SCM_BOOL_T) ; 3662 n->set_property ("force-accidental", SCM_BOOL_T) ;
3658 if (scm_is_pair ($7)) 3663 if (scm_is_pair ($7))
3659 n->set_property ("articulations", 3664 n->set_property ("articulations",
3660 scm_reverse_x ($7, SCM_EOL)); 3665 scm_reverse_x ($7, SCM_EOL));
3661 $$ = n->unprotect (); 3666 $$ = n->unprotect ();
3662 } 3667 }
3663 } %prec ':' 3668 } %prec ':'
3669 // Next rule is a frequent note entry error, like c4''
3670 //
3671 // It is quite unlikely that an octave check precedes a
3672 // duration, but we have to keep it in the rule in order not
3673 // to force the parser into early decisions before actually
3674 // seeing a stray quote. So we try to best interpret that
3675 // case as well, even though it's not a likely error case.
3676 | pitch exclamations questions octave_check duration stray_quotes option al_rest post_events {
hanwenn 2020/02/12 06:45:08 why can't this case be folded in to the preceding
dak 2020/02/12 10:38:16 Astute observation. We print out the grammar in t
3677 if (!parser->lexer_->is_note_state ())
3678 parser->parser_error (@1, _ ("have to be in Note mode fo r notes"));
3679 {
3680 Music *n = 0;
3681 if (scm_is_true ($7))
3682 n = MY_MAKE_MUSIC ("RestEvent", @$);
3683 else
3684 n = MY_MAKE_MUSIC ("NoteEvent", @$);
3685
3686 if (scm_is_number ($4))
3687 {
3688 int q = scm_to_int ($4) + scm_to_int ($6);
3689 n->set_property ("absolute-octave", scm_from_int (q-1));
3690 } else
3691 $1 = unsmob<Pitch> ($1)->transposed
3692 (Pitch (scm_to_int ($6), 0)).smobbed_cop y ();
3693
3694 n->set_property ("pitch", $1);
3695 n->set_property ("duration", $5);
3696
3697 if (to_boolean ($3))
3698 n->set_property ("cautionary", SCM_BOOL_T);
3699 if (to_boolean ($2) || to_boolean ($3))
3700 n->set_property ("force-accidental", SCM_BOOL_T) ;
3701 if (scm_is_pair ($8))
3702 n->set_property ("articulations",
3703 scm_reverse_x ($8, SCM_EOL));
3704 $$ = n->unprotect ();
3705 }
3706 parser->parser_error (@6, _ ("octave marks must precede duration "));
hanwenn 2020/02/12 06:45:08 add a comment that we sholudn't drop this error, e
dak 2020/02/12 10:38:16 Accepting that "syntax" would give me a rash. I h
3707 } %prec ':'
3664 | new_chord post_events { 3708 | new_chord post_events {
3665 if (!parser->lexer_->is_chord_state ()) 3709 if (!parser->lexer_->is_chord_state ())
3666 parser->parser_error (@1, _ ("have to be in Chord mode f or chords")); 3710 parser->parser_error (@1, _ ("have to be in Chord mode f or chords"));
3667 if (scm_is_pair ($2)) { 3711 if (scm_is_pair ($2)) {
3668 if (unsmob<Pitch> ($1)) 3712 if (unsmob<Pitch> ($1))
3669 $1 = make_chord_elements (@1, 3713 $1 = make_chord_elements (@1,
3670 $1, 3714 $1,
3671 parser->default_durati on_.smobbed_copy (), 3715 parser->default_durati on_.smobbed_copy (),
3672 SCM_EOL); 3716 SCM_EOL);
3673 3717
(...skipping 1083 matching lines...) Expand 10 before | Expand all | Expand 10 after
4757 Lily_lexer *lex = parser->lexer_; 4801 Lily_lexer *lex = parser->lexer_;
4758 4802
4759 lex->lexval_ = s; 4803 lex->lexval_ = s;
4760 lex->lexloc_ = loc; 4804 lex->lexloc_ = loc;
4761 int tok = lex->pop_extra_token (); 4805 int tok = lex->pop_extra_token ();
4762 if (tok >= 0) 4806 if (tok >= 0)
4763 return tok; 4807 return tok;
4764 lex->prepare_for_next_token (); 4808 lex->prepare_for_next_token ();
4765 return lex->yylex (); 4809 return lex->yylex ();
4766 } 4810 }
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