lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Location of Parser? (and EPIC journey through source code)


From: Starling
Subject: Re: Location of Parser? (and EPIC journey through source code)
Date: Wed, 03 Jul 2002 06:05:32 -0700
User-agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7

Jan Nieuwenhuizen <address@hidden> writes:

> Starling <address@hidden> writes:
> 
> What about lily/parser.yy?  You may also want to have a peek at the
> lexer, which is in lily/lexer.ll.

Ooh!  Thanks.  That'll teach me to ls lily/*.c*  :)

...although it's not quite as simple as looking at those files.  I
think what's going on is the phrase '\repeat' matches the pattern
KEYWORD (\\{WORD}) which calls the function scan_escaped_word().  Here
there's no way to tell exactly what will happen, so I went function by
function finally lighting on 'lookup_keyword'.

In my-lily-lexer.cc, lookup_keyword calls a member function of
keytable_p_, which is defined in my-lily-lexer.h as type
'Keyword_table' which is implemented in 'keywords.cc'.  There, the
lookup function goes through (wait for it...) a table! and returns the
token associated with the string that matches.  Here I was confused
because there's no actual way to create string:token pairs.
Thankfully, once again in my-lily-lexer.cc, I found a table of
string:token pairs globally allocated.  In that table,
my-lily-lexer.cc, line 80, was the phrase {"repeat", REPEAT}.  That
meant when it read the string "repeat" it would return from
lookup_table the token REPEAT, which was interpreted in parser.yy to
execute code to generate a Repeated_music object.

I dunno, kinda confusing.  I had to rely on grep and praying a bit too
much to find all that.  It might be nice to mention near the
definition of Keyword_ent that all keywords are defined in 
my-lily-lexer.cc.  It would also be nice to mention exactly what
'notes' 'identifiers' and 'keywords' are near the definition of
scan_bare_word.  I I'm still not sure what an identifier is.  *shrug*
C'est la vie.  Nice job on the binary search, and masterful use of
Bison/Flex!


Starling

-- 

"Somewhere deep beneath the earth, demons are ice-skating." -- M U R A S A M E



reply via email to

[Prev in Thread] Current Thread [Next in Thread]