input code

classic Classic list List threaded Threaded
21 messages Options
12
Reply | Threaded
Open this post in threaded view
|

input code

Freeman Gilmore
Where could i find the code that would reads the input file just i.e. { cis'4 }?

Thank you,
ƒg
Reply | Threaded
Open this post in threaded view
|

Re: input code

Andrew Bernard
\include <filename> ?

What do you really want to do?

Andrew

On Thu, 12 Dec 2019 at 14:38, Freeman Gilmore <[hidden email]> wrote:
>
> Where could i find the code that would reads the input file just i.e. { cis'4 }?

Reply | Threaded
Open this post in threaded view
|

Re: input code

Noeck
In reply to this post by Freeman Gilmore
Hi,

I am not really familiar with the parser, but I think LilyPond uses
Bison¹ and the input syntax is defined in lilypond/lily/parser.yy

¹: https://www.gnu.org/software/bison/

Best,
Joram

Reply | Threaded
Open this post in threaded view
|

Re: input code

Andrew Bernard
I think we need to know what the OP wants to actually do first.
There's a dozen different possible ideas here.


Andrew

On Thu, 12 Dec 2019 at 18:35, Noeck <[hidden email]> wrote:

> I am not really familiar with the parser, but I think LilyPond uses
> Bison¹ and the input syntax is defined in lilypond/lily/parser.yy

Reply | Threaded
Open this post in threaded view
|

Re: input code

Freeman Gilmore
In reply to this post by Andrew Bernard


On Thu, Dec 12, 2019 at 2:26 AM Andrew Bernard <[hidden email]> wrote:
\include <filename> ?

What do you really want to do?
I would like to understand how it work, if i can.

Thank you,
ƒg 

Andrew

On Thu, 12 Dec 2019 at 14:38, Freeman Gilmore <[hidden email]> wrote:
>
> Where could i find the code that would reads the input file just i.e. { cis'4 }?
Reply | Threaded
Open this post in threaded view
|

Re: input code

Freeman Gilmore
In reply to this post by Noeck


On Thu, Dec 12, 2019 at 2:36 AM Noeck <[hidden email]> wrote:
Hi,

I am not really familiar with the parser, but I think LilyPond uses
Bison¹ and the input syntax is defined in lilypond/lily/parser.yy

¹: https://www.gnu.org/software/bison/
 
Thank you, i will check this.

ƒg


Best,
Joram

Reply | Threaded
Open this post in threaded view
|

Re: input code

Freeman Gilmore
In reply to this post by Andrew Bernard


On Thu, Dec 12, 2019 at 6:08 AM Andrew Bernard <[hidden email]> wrote:
I think we need to know what the OP wants to actually do first.
There's a dozen different possible ideas here.
 
There are 4 parts to  { cis'4 }; i would like to understand how the parts are  read in to the parser.  How is it divided, ans each read in to scheme ( as i understand it is converted to).

Thank you,
ƒg



Andrew

On Thu, 12 Dec 2019 at 18:35, Noeck <[hidden email]> wrote:

> I am not really familiar with the parser, but I think LilyPond uses
> Bison¹ and the input syntax is defined in lilypond/lily/parser.yy

Reply | Threaded
Open this post in threaded view
|

Re: input code

David Kastrup
Freeman Gilmore <[hidden email]> writes:

> On Thu, Dec 12, 2019 at 6:08 AM Andrew Bernard <[hidden email]>
> wrote:
>
>> I think we need to know what the OP wants to actually do first.
>> There's a dozen different possible ideas here.
>>
>
> There are 4 parts to  { cis'4 }; i would like to understand how the parts
> are  read in to the parser.  How is it divided, ans each read in to scheme
> ( as i understand it is converted to).

Try running LilyPond with -ddebug-parser .  The output is related to the
printed LilyPond grammar in the LilyPond Notation Reference appendices.

--
David Kastrup

Reply | Threaded
Open this post in threaded view
|

Re: input code

Robin Bannister-2
David Kastrup wrote:

> Try running LilyPond with -ddebug-parser .  The output is related to the
> printed LilyPond grammar in the LilyPond Notation Reference appendices.
>

That grammar appendix is still rather garbled.
Attached is a less confusing version for circa 2.19.80.


Cheers,
Robin

ly_grammar.txt (78K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: input code

Hans Åberg-2
In reply to this post by Freeman Gilmore

> On 12 Dec 2019, at 14:01, Freeman Gilmore <[hidden email]> wrote:
>
> I would like to understand how it work, if i can.

There is a lexer generated from a file lexer.ll by Flex, which divides the input stream into tokens, which are handed over to a parser generated from a file parser.yy by Bison.



Reply | Threaded
Open this post in threaded view
|

Re: input code

Freeman Gilmore


On Thu, Dec 12, 2019 at 3:01 PM Hans Åberg <[hidden email]> wrote:

> On 12 Dec 2019, at 14:01, Freeman Gilmore <[hidden email]> wrote:
>
> I would like to understand how it work, if i can.

There is a lexer generated from a file lexer.ll by Flex, which divides the input stream into tokens, which are handed over to a parser generated from a file parser.yy by Bison.


0k that helps.   The lexer looks like what i an looking for I think at this point; and from what you said.   I have the lexer.ll, parser.yy and ly_grammar.txt files.     Now I need to finger out what part of the lexer code reads the note event.

Thank you all,
ƒg
Reply | Threaded
Open this post in threaded view
|

Re: input code

Hans Åberg-2

> On 12 Dec 2019, at 22:32, Freeman Gilmore <[hidden email]> wrote:
>
>> On Thu, Dec 12, 2019 at 3:01 PM Hans Åberg <[hidden email]> wrote:
>>
>> > On 12 Dec 2019, at 14:01, Freeman Gilmore <[hidden email]> wrote:
>> >
>> > I would like to understand how it work, if i can.
>>
>> There is a lexer generated from a file lexer.ll by Flex, which divides the input stream into tokens, which are handed over to a parser generated from a file parser.yy by Bison.
>
> 0k that helps.   The lexer looks like what i an looking for I think at this point; and from what you said.   I have the lexer.ll, parser.yy and ly_grammar.txt files.     Now I need to finger out what part of the lexer code reads the note event.

Check out the Bison manual, which also has a C++ calculator example with sources in the distribution. One can generate a file .output from the .yy file which contains all processing of the grammar would it be needed. Use flex 2.5.37, because the C++ lexer in 2.6* is broken.


Reply | Threaded
Open this post in threaded view
|

Re: input code

Andrew Bernard
In reply to this post by Freeman Gilmore
Hi Freeman,

I still don't understand your aim here. Are you just trying to
understand the lilypond code or do you have some specific purpose or
application? It would help to know.

Andrew

On Fri, 13 Dec 2019 at 08:33, Freeman Gilmore <[hidden email]> wrote:

>
> 0k that helps.   The lexer looks like what i an looking for I think at this point; and from what you said.   I have the lexer.ll, parser.yy and ly_grammar.txt files.     Now I need to finger out what part of the lexer code reads the note event.

Reply | Threaded
Open this post in threaded view
|

Re: input code

Freeman Gilmore


On Thu, Dec 12, 2019 at 7:13 PM Andrew Bernard <[hidden email]> wrote:
Hi Freeman,

I still don't understand your aim here. Are you just trying to
understand the lilypond code or do you have some specific purpose or
application? It would help to know.

Andrew

Someday I may write a markup up for some accidentals.   This may help me understand what I am doing with markup.   For how I just want to know a little about how lexer reads the pitch, the octave. accidental and note size; and I may not be able to do that any way.   I know nothing about flex and just learned it existed today.    Also, I would like to see how the markup works around the accidental to place a string in it space.     I read some of Separating input language and formatter in GNU Lilypond, and found it interesting.   Looking for more details.

 

I do not need to know all this to learn how to write a markup; just like to understand a little about how it works around the accidental.      But I do need to learn more about scheme and markups.

Thank you,
ƒg

On Fri, 13 Dec 2019 at 08:33, Freeman Gilmore <[hidden email]> wrote:

>
> 0k that helps.   The lexer looks like what i an looking for I think at this point; and from what you said.   I have the lexer.ll, parser.yy and ly_grammar.txt files.     Now I need to finger out what part of the lexer code reads the note event.

Reply | Threaded
Open this post in threaded view
|

Re: input code

Freeman Gilmore
In reply to this post by Hans Åberg-2


On Thu, Dec 12, 2019 at 4:40 PM Hans Åberg <[hidden email]> wrote:

> On 12 Dec 2019, at 22:32, Freeman Gilmore <[hidden email]> wrote:
>
>> On Thu, Dec 12, 2019 at 3:01 PM Hans Åberg <[hidden email]> wrote:
>>
>> > On 12 Dec 2019, at 14:01, Freeman Gilmore <[hidden email]> wrote:
>> >
>> > I would like to understand how it work, if i can.
>>
>> There is a lexer generated from a file lexer.ll by Flex, which divides the input stream into tokens, which are handed over to a parser generated from a file parser.yy by Bison.
>
> 0k that helps.   The lexer looks like what i an looking for I think at this point; and from what you said.   I have the lexer.ll, parser.yy and ly_grammar.txt files.     Now I need to finger out what part of the lexer code reads the note event.

Check out the Bison manual, which also has a C++ calculator example with sources in the distribution. One can generate a file .output from the .yy file which contains all processing of the grammar would it be needed. Use flex 2.5.37, because the C++ lexer in 2.6* is broken.

I do not know if i can do this but I will look in to it.   Flex is new to me today.   .
Thank you,
ƒg  
Reply | Threaded
Open this post in threaded view
|

Re: input code

Aaron Hill
In reply to this post by Freeman Gilmore
On 2019-12-12 5:53 pm, Freeman Gilmore wrote:

> Someday I may write a markup up for some accidentals.   This may help
> me
> understand what I am doing with markup.   For how I just want to know a
> little about how lexer reads the pitch, the octave. accidental and note
> size; and I may not be able to do that any way.   I know nothing about
> flex
> and just learned it existed today.    Also, I would like to see how the
> markup works around the accidental to place a string in it space.     I
> read some of *Separating input language and formatter in GNU Lilypond,
> *and
> found it interesting.   Looking for more details.
>
> I do not need to know all this to learn how to write a markup; just
> like to
> understand a little about how it works around the accidental.      But
> I do
> need to learn more about scheme and markups.

While it is well beyond the scope of LilyPond itself, I would recommend
you look for a copy of Principles of Compiler Design [1], the so-called
"dragon book".

[1]: https://en.wikipedia.org/wiki/Principles_of_Compiler_Design

This book builds from the ground up a fairly complete picture of how
compilers work.  It is a very technical book, so do not expect to work
through it quickly.  However if you are truly interested in the
underlying details of lexical analyzers ("lexers") and parsers, then
this will be a great resource.

That said, I am uncertain how a better understanding of LilyPond's
parser would impact matters of accidentals and markup.  To me, it feels
like you may be digging too deeply here.  While I always support a
healthy amount of curiosity, it may prove more practical for you to
focus your attention on higher-level concerns.

When you talk of markup and accidentals, are you interested in
redesigning the look of an existing accidental or perhaps inventing a
new one?  To my knowledge, the only intersection with LilyPond's parser
would involve the naming of notes.  Take a look at
scm/define-note-names.scm for an example of how the existing languages
are defined.  This pattern can easily be extended to support other
alterations.

Of course, that still may be going further than you need to.  If you
simply need to replace the normal stencil for a specific Accidental, you
can do the following:

%%%%
\version "2.18.2"

{ \tweak Accidental.horizontal-skylines
     #ly:grob::horizontal-skylines-from-stencil
   \tweak Accidental.stencil #ly:text-interface::print
   \tweak Accidental.text \markup \vcenter \huge \bold "$"
   fis'1 }
%%%%

If such a replacement needs to happen on a global scale, then something
like the following may be useful:

%%%%
\version "2.18.2"

dollar = \markup \vcenter \huge \bold "$"

\layout { \context { \Voice
   \override Accidental.before-line-breaking = #(lambda (grob)
     (if (eqv? (ly:grob-property grob 'alteration) SHARP)
       (begin (ly:grob-set-property! grob 'horizontal-skylines
                ly:grob::horizontal-skylines-from-stencil)
              (ly:grob-set-property! grob 'text dollar)
              (ly:grob-set-property! grob 'stencil
                ly:text-interface::print))))
} }

{ e'4 fis' bes' gis' | fis'8 gisis' fis'2 r4 }
%%%%


-- Aaron Hill

Reply | Threaded
Open this post in threaded view
|

Re: input code

Freeman Gilmore


On Thu, Dec 12, 2019 at 10:20 PM Aaron Hill <[hidden email]> wrote:
On 2019-12-12 5:53 pm, Freeman Gilmore wrote:
> Someday I may write a markup up for some accidentals.   This may help
> me
> understand what I am doing with markup.   For how I just want to know a
> little about how lexer reads the pitch, the octave. accidental and note
> size; and I may not be able to do that any way.   I know nothing about
> flex
> and just learned it existed today.    Also, I would like to see how the
> markup works around the accidental to place a string in it space.     I
> read some of *Separating input language and formatter in GNU Lilypond,
> *and
> found it interesting.   Looking for more details.
>
> I do not need to know all this to learn how to write a markup; just
> like to
> understand a little about how it works around the accidental.      But
> I do
> need to learn more about scheme and markups.

While it is well beyond the scope of LilyPond itself, I would recommend
you look for a copy of Principles of Compiler Design [1], the so-called
"dragon book".

[1]: https://en.wikipedia.org/wiki/Principles_of_Compiler_Design

This book builds from the ground up a fairly complete picture of how
compilers work.  It is a very technical book, so do not expect to work
through it quickly.  However if you are truly interested in the
underlying details of lexical analyzers ("lexers") and parsers, then
this will be a great resource.

That said, I am uncertain how a better understanding of LilyPond's
parser would impact matters of accidentals and markup.  To me, it feels
like you may be digging too deeply here.  While I always support a
healthy amount of curiosity, it may prove more practical for you to
focus your attention on higher-level concerns.

When you talk of markup and accidentals, are you interested in
redesigning the look of an existing accidental or perhaps inventing a
new one?  To my knowledge, the only intersection with LilyPond's parser
would involve the naming of notes.  Take a look at
scm/define-note-names.scm for an example of how the existing languages
are defined.  This pattern can easily be extended to support other
alterations.

Aaron:

You made some good points.   I do get sidetracked with how thing work.    I know about the SCM.   And seeing it again did put together some of what I wanted to know.   I will study your second example; I have tried it.

Thank you,

fg


Of course, that still may be going further than you need to.  If you
simply need to replace the normal stencil for a specific Accidental, you
can do the following:

%%%%
\version "2.18.2"

{ \tweak Accidental.horizontal-skylines
     #ly:grob::horizontal-skylines-from-stencil
   \tweak Accidental.stencil #ly:text-interface::print
   \tweak Accidental.text \markup \vcenter \huge \bold "$"
   fis'1 }
%%%%

If such a replacement needs to happen on a global scale, then something
like the following may be useful:

%%%%
\version "2.18.2"

dollar = \markup \vcenter \huge \bold "$"

\layout { \context { \Voice
   \override Accidental.before-line-breaking = #(lambda (grob)
     (if (eqv? (ly:grob-property grob 'alteration) SHARP)
       (begin (ly:grob-set-property! grob 'horizontal-skylines
                ly:grob::horizontal-skylines-from-stencil)
              (ly:grob-set-property! grob 'text dollar)
              (ly:grob-set-property! grob 'stencil
                ly:text-interface::print))))
} }

{ e'4 fis' bes' gis' | fis'8 gisis' fis'2 r4 }
%%%%


-- Aaron Hill

Reply | Threaded
Open this post in threaded view
|

Re: input code

Hans Åberg-2
In reply to this post by Freeman Gilmore

> On 13 Dec 2019, at 03:00, Freeman Gilmore <[hidden email]> wrote:
>
>> On Thu, Dec 12, 2019 at 4:40 PM Hans Åberg <[hidden email]> wrote:
>>
>> > On 12 Dec 2019, at 22:32, Freeman Gilmore <[hidden email]> wrote:
>> >
>> >> On Thu, Dec 12, 2019 at 3:01 PM Hans Åberg <[hidden email]> wrote:
>> >>
>> >> > On 12 Dec 2019, at 14:01, Freeman Gilmore <[hidden email]> wrote:
>> >> >
>> >> > I would like to understand how it work, if i can.
>> >>
>> >> There is a lexer generated from a file lexer.ll by Flex, which divides the input stream into tokens, which are handed over to a parser generated from a file parser.yy by Bison.
>> >
>> > 0k that helps.   The lexer looks like what i an looking for I think at this point; and from what you said.   I have the lexer.ll, parser.yy and ly_grammar.txt files.     Now I need to finger out what part of the lexer code reads the note event.
>>
>> Check out the Bison manual, which also has a C++ calculator example with sources in the distribution. One can generate a file .output from the .yy file which contains all processing of the grammar would it be needed. Use flex 2.5.37, because the C++ lexer in 2.6* is broken.
>
> I do not know if i can do this but I will look in to it.   Flex is new to me today.   .

In the lexer.ll file, you might search for the rules with a “return” in them, as that is how the yylex function turns over the tokens to the parser. The Flex manual describes the rules syntax.


Reply | Threaded
Open this post in threaded view
|

Re: input code

Hans Åberg-2
In reply to this post by Freeman Gilmore

> On 13 Dec 2019, at 02:53, Freeman Gilmore <[hidden email]> wrote:
>
>> On Thu, Dec 12, 2019 at 7:13 PM Andrew Bernard <[hidden email]> wrote:
>> Hi Freeman,
>>
>> I still don't understand your aim here. Are you just trying to
>> understand the lilypond code or do you have some specific purpose or
>> application? It would help to know.
>>
>> Andrew
>
> Someday I may write a markup up for some accidentals.   This may help me understand what I am doing with markup.   For how I just want to know a little about how lexer reads the pitch, the octave. accidental and note size; and I may not be able to do that any way.   I know nothing about flex and just learned it existed today.    Also, I would like to see how the markup works around the accidental to place a string in it space.     I read some of Separating input language and formatter in GNU Lilypond, and found it interesting.   Looking for more details.
>  
> I do not need to know all this to learn how to write a markup; just like to understand a little about how it works around the accidental.      But I do need to learn more about scheme and markups.

LilyPond lack a way to indicate intervals, and accidentals are merely intervals of relative scale degree zero. A 5th has a relative scale degres 4, changes the position on the staff 4 steps, and similar for other intervals. The accidentals do not change the position on the staff.

In addition to ly:make-pitch, you might have ly:make-interval. Then one should be able to add and subtract intervals, add then to pitches, and the difference two pitches is an interval.

LilyPond already has the internals for that, I would think, but lacks a suitable API and input syntax.



Reply | Threaded
Open this post in threaded view
|

Re: input code

Freeman Gilmore


On Fri, Dec 13, 2019 at 4:25 AM Hans Åberg <[hidden email]> wrote:

> On 13 Dec 2019, at 02:53, Freeman Gilmore <[hidden email]> wrote:
>
>> On Thu, Dec 12, 2019 at 7:13 PM Andrew Bernard <[hidden email]> wrote:
>> Hi Freeman,
>>
>> I still don't understand your aim here. Are you just trying to
>> understand the lilypond code or do you have some specific purpose or
>> application? It would help to know.
>>
>> Andrew
>
> Someday I may write a markup up for some accidentals.   This may help me understand what I am doing with markup.   For how I just want to know a little about how lexer reads the pitch, the octave. accidental and note size; and I may not be able to do that any way.   I know nothing about flex and just learned it existed today.    Also, I would like to see how the markup works around the accidental to place a string in it space.     I read some of Separating input language and formatter in GNU Lilypond, and found it interesting.   Looking for more details.

> I do not need to know all this to learn how to write a markup; just like to understand a little about how it works around the accidental.      But I do need to learn more about scheme and markups.

LilyPond lack a way to indicate intervals,
I am aware of this part: 
and accidentals are merely intervals of relative scale degree zero. A 5th has a relative scale degres 4, changes the position on the staff 4 steps, and similar for other intervals. The accidentals do not change the position on the staff.

In addition to ly:make-pitch, you might have ly:make-interval. Then one should be able to add and subtract intervals, add then to pitches, and the difference two pitches is an interval.

I would have to write the function, ly:make-interval.   That would work for the common intervals, 2:3 and 4:5, in ET: but when you get up it the higher harmonic ratio intervals, different people define the intervals differently.   It can be referenced to ET or Pythagorean and the number or what notes used in your system.    For a simple example 4:7, (969¢) meantone is an Aug 6th in ET it is min 7th.   The ratio 8:11, (551¢) can go either way based on you reference.

Thank you,
ƒg

LilyPond already has the internals for that, I would think, but lacks a suitable API and input syntax.


12