[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Learning LilyPond - Parser permissiveness
From: |
David Kastrup |
Subject: |
Re: Learning LilyPond - Parser permissiveness |
Date: |
Sat, 04 Jan 2014 10:32:13 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) |
Colin Tennyson <address@hidden> writes:
> I noticed that in some places there is remarkable freedom to exchange order
> and grouping of commands.
>
> Take the following nesting structure:
>
> addKey = { \key c \major \time 4/4 }
> instrOne = { \set Staff.instrumentName = #"Superius " }
> instrTwo = { \set Staff.instrumentName = #"Contratenor " }
>
> \score {
> \new StaffGroup
> <<
> \new Staff
> <<
> \new Voice = "staffOne" { \instrOne \addKey \staffOneNotes }
> \new Lyrics \lyricsto "staffOne" \staffOneWords
> \barSetup
> >>
> \new Staff
> <<
> \instrTwo \addKey \new Voice = "staffTwo" \staffTwoNotes
> \lyricsto "staffTwo" \new Lyrics \staffTwoWords
> \barSetup
> >>
> >>
> }
>
>
> \new Voice = "staffOne" { \instrOne \addKey \staffOneNotes }
> \new Lyrics \lyricsto "staffOne" \staffOneWords
>
> versus:
>
> \instrTwo \addKey \new Voice = "staffTwo" \staffTwoNotes
> \lyricsto "staffTwo" \new Lyrics \staffTwoWords
>
>
> Both are accepted by the parser, and they are rendered identically.
>
> I'm amazed that the parser is able to disambiguate the source code. There
> are no delimiters between the expressions. How does the parser figure out
> where one expression has ended, and the next one has begun?
<URL:http://lilypond.org/doc/v2.18/Documentation/contributor/lilypond-grammar>
--
David Kastrup