[racket] How to extend the syntax-checker?

From: Daniel Brady (dabrady at umail.iu.edu)
Date: Fri May 30 16:50:38 EDT 2014

Oh, nice! I didn't realize that, thanks.

After playing around with it, I realized it doesn't do everything I would
like it to do, however. For a couple of the macros that I provide in my
#lang language, I would like to provide some syntax rules such that Check
Syntax throws an error when a program breaks those rules. Is this possible?

For instance, say I have a macro in my language which provides a new form,
but a form that is only intended to be used with other macros and functions
provided by my language. That is to say, I would like to raise a syntax
error if the programmer tries to use procedures/macros not defined in my
language module *inside* a use of my macro, like this:

(restricted-begin  ; A form of begin whose body I would like to restrict to
expressions in my language.
  (one-of-my-features '(1 2 3))
  (car '(1 2 3)))  ; <-- since I do not define car in my language module,
disallow its use.

Basically, I have some special forms whose bodies I would like to restrict
to containing only features of my language, and not of standard Racket, in
effect preventing the intermingling of my language features and those of
Racket.

I just realized that if this is at all possible, I would run into an issue
on the first line of that macro's body, where I use quote. Is it also
possible, given the possibility of the above, for me to allow certain
Racket features while restricting others, instead of just placing a blanket
syntax rejection of all things Racket?


On Fri, May 30, 2014 at 11:39 AM, Matthias Felleisen <matthias at ccs.neu.edu>
wrote:

>
> On May 29, 2014, at 11:49 PM, Daniel Brady <dabrady at umail.iu.edu> wrote:
>
> > Hi everyone,
> >
> > I just finished creating a small #lang language, and now I would like to
> start creating some static debugging tools for it. The first thing on my
> list is a basic syntax checker. I consulted the DrRacket documentation on
> creating tools and plugins, but honestly it went a bit over my head: this
> is my first foray into extending anything, and I don't really know where to
> start.
> >
> > So my question(s) boils down to this: how can I provide syntax checking
> for my little #lang language? My little language really just provides some
> new syntactic forms, and is built directly on top of Racket, so there's
> nothing fancy I need to do with this: I just need to provide some new rules
> to the built-in syntax checker so that it also recognizes my extensions.
> How can I do this?
>
>
> If that's all there is, DrRacket provides Check Syntax automatically for
> your language. Part of the goal of the project is to specialize the IDE to
> new languages automatically. (No we're not there yet in general.)
>
> -- Matthias
>
>


-- 
*SEE YOU SPACE COWBOY...*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20140530/b675a780/attachment-0001.html>

Posted on the users mailing list.