Discussion:
How to extract the scheme parser from the source?
Xing Su
2013-07-30 10:44:44 UTC
Permalink
Hi everyone!

I'm trying to implement a enhanced r5rs scheme system. Cause the
enhancement is small, say, only a new data type and some operations on
it will be added, working on a existing scheme implementation fits me
better than working from scratch and I've chosen scheme48 as my basis.

The new datatype will bring new syntax, so the first step is making the
scheme48's parser recognize the new syntax. I have not read through the
source code of scheme48 before and I want a quick start.

My questions are:
1. Is scheme48's scheme parser written in Scheme or C?
2. Which file in the source tree should I concentrate on if I want to
add a new syntax?

Any help is appreciated!
Jonathan Rees
2013-07-30 17:08:27 UTC
Permalink
scheme/rts/read.scm
Post by Xing Su
Hi everyone!
I'm trying to implement a enhanced r5rs scheme system. Cause the
enhancement is small, say, only a new data type and some operations on
it will be added, working on a existing scheme implementation fits me
better than working from scratch and I've chosen scheme48 as my basis.
The new datatype will bring new syntax, so the first step is making the
scheme48's parser recognize the new syntax. I have not read through the
source code of scheme48 before and I want a quick start.
1. Is scheme48's scheme parser written in Scheme or C?
2. Which file in the source tree should I concentrate on if I want to
add a new syntax?
Any help is appreciated!
Will Noble
2013-08-02 08:44:22 UTC
Permalink
Oops. I didn't see this message and re-answered the question. Sorry about
that!
Post by Jonathan Rees
scheme/rts/read.scm
Will Noble
2013-08-02 04:18:39 UTC
Permalink
Hi Xing,

You can find Scheme 48's (very nice) reader in scheme/rts/read.scm.

Theoretically, you can even choose which reader to use from Scheme 48's module
system using the undocumented macro DEFINE-READER. I've never used it,
though. Does someone have experience with DEFINE-READER?

Best,
Will
Post by Xing Su
Hi everyone!
I'm trying to implement a enhanced r5rs scheme system. Cause the
enhancement is small, say, only a new data type and some operations on
it will be added, working on a existing scheme implementation fits me
better than working from scratch and I've chosen scheme48 as my basis.
The new datatype will bring new syntax, so the first step is making the
scheme48's parser recognize the new syntax. I have not read through the
source code of scheme48 before and I want a quick start.
1. Is scheme48's scheme parser written in Scheme or C?
2. Which file in the source tree should I concentrate on if I want to
add a new syntax?
Any help is appreciated!
Michael Sperber
2013-08-02 06:31:44 UTC
Permalink
Post by Will Noble
You can find Scheme 48's (very nice) reader in scheme/rts/read.scm.
Theoretically, you can even choose which reader to use from Scheme 48's module
system using the undocumented macro DEFINE-READER. I've never used it,
though. Does someone have experience with DEFINE-READER?
Sure. There's even a

,set-reader

command in the REPL. Among other things, it can be used to switch to
the R6RS reader in scheme/r6rs/reader.scm.
--
Regards,
Mike
Will Noble
2013-08-02 07:42:44 UTC
Permalink
Hi Make,

Olin Shivers claims, in http://www.scsh.net/docu/post/modules.html,
"there's an extra clause in the DEFINE-STRUCTURE form that lets you specify
the parser function used to parse the files named in the FILES clause".

Can you really do this? I can't seem to locate the code that would implement
this functionality.

Best,
Will
Post by Michael Sperber
Sure. There's even a
,set-reader
command in the REPL. Among other things, it can be used to switch to
the R6RS reader in scheme/r6rs/reader.scm.
--
Regards,
Mike
Michael Sperber
2013-08-02 08:06:54 UTC
Permalink
Post by Will Noble
Olin Shivers claims, in http://www.scsh.net/docu/post/modules.html,
"there's an extra clause in the DEFINE-STRUCTURE form that lets you specify
the parser function used to parse the files named in the FILES clause".
Can you really do this? I can't seem to locate the code that would implement
this functionality.
This functionality was recently re-introduced in Scheme 48 1.9. It sits
mostly in scheme/bcomp/scan-package.scm. Look for
"set-package-reader!". In short, you can specify a

(reader <expr>)

clause in a `define-structure' form where <expr> is evaluated in the
`for-syntax' environment of the underlying package.
--
Regards,
Mike
Will Noble
2013-08-02 08:28:43 UTC
Permalink
Cool stuff. Thanks!
Post by Michael Sperber
This functionality was recently re-introduced in Scheme 48 1.9. It sits
mostly in scheme/bcomp/scan-package.scm. Look for
"set-package-reader!". In short, you can specify a
(reader <expr>)
clause in a `define-structure' form where <expr> is evaluated in the
`for-syntax' environment of the underlying package.
Continue reading on narkive:
Search results for 'How to extract the scheme parser from the source?' (Questions and Answers)
43
replies
Do they have a yahoo Answers where you live?
started 2006-09-14 15:54:56 UTC
polls & surveys
Loading...