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