Reviewers: Reinhold,

Message:
On 2011/09/15 10:45:11, Reinhold wrote:
Also, does this work for cases like
   \relative c' c

Yes, it does.  Parameters following non-present optional parameters are
more restricted than those following present optional parameters.

While you can't write \myrelative c' instead of \myrelative { c' },
\myrelative c' c instead of \myrelative c' { c } works just fine since
you can't confuse it with \myrelative { c' } c.

Also, I suppose things like
   \myfunction [optional-pitch] pitch music
does not work due to the lookahead not looking too far, right?

Correct.  One could try to squeeze appropriate patterns into the syntax
as well, but the current Scheme requires already O(n^2) rules, and
extending the patterns to cover the generalizations of your example
would require O(n^3) rules.  Too much pain for the gain.



Description:
Implement optional music function arguments

This allows, say, to define a substitute for \relative that has an
optional pitch argument defaulting to f rather than c.

pitch = #(define-scheme-function (parser location pitch)
          (ly:pitch?) pitch)
myrelative = #(define-music-function (parser location pitch music)
               ((ly:pitch? #{ \pitch f #}) ly:music?)
               #{ \relative $pitch $music #})
\relative c' {c' d e f g a b c}
\relative {c' d e f g a b c}
\myrelative c' {c' d e f g a b c}
\myrelative {c' d e f g a b c}

The first uploaded patch is a separate commit with the following
description:

lexer.ll: Allow push_extra_token to take a Scheme value as well.

Please review this at http://codereview.appspot.com/5023044/

Affected files:
  M lily/include/lily-lexer.hh
  M lily/lexer.ll
  M lily/lily-lexer.cc
  M lily/parser.yy
  M scm/document-identifiers.scm
  M scm/lily.scm
  M scm/music-functions.scm



_______________________________________________
lilypond-devel mailing list
lilypond-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-devel

Reply via email to