This is the mail archive of the
guile@sourceware.cygnus.com
mailing list for the Guile project.
[Q] How to hook up the GUILE parser?
- To: guile at sourceware dot cygnus dot com
- Subject: [Q] How to hook up the GUILE parser?
- From: Han-Wen Nienhuys <hanwen at cs dot uu dot nl>
- Date: Sun, 17 Oct 1999 20:27:52 +0200 (CEST)
- Cc: jantien at xs4all dot nl
- Reply-To: hanwen at cs dot uu dot nl
Hi guys,
We're still advancing GUILE integration in LilyPond. For this purpose,
I want to parse arbitrary Scheme expressions that are embedded in our
input. I want the expressions to be embedded like this:
\notes {
c4
\property Voice.stemSettings = #(map sqr '(1 2 3))
c4
}
My idea was have a special character (the '#') for switching
the lexer in a separate mode; The rough sketch of my idea is this:
* Tokenizer finds a #. Tokenizer sets up a string-port (using the
input file, which completely in core), that starts where the
tokenizer found the # in the file
* Tokenizer calls read-and-eval! with said string-port.
read-and-eval!
processes one expression and returns the result.
* Tokenizer reads how many characters were read from the string-port
* Tokenizer switches into special mode `guzzle-characters'
and gulps as many characters from the input as were read from the
port.
* Tokenizer signals to parser "found token of type SCM".
Now my question: how do I set up a string port that does this, and how
do I read back the number of characters taken from the port?
Any other suggestions?
BTW, please CC replies, I'm not on the GUILE list.
--
Han-Wen Nienhuys, hanwen@cs.uu.nl ** GNU LilyPond - The Music Typesetter
http://www.cs.uu.nl/people/hanwen/lilypond/index.html