consistent interfaces from multiple files

31 views
Skip to first unread message

Shriram Krishnamurthi

unread,
Sep 2, 2020, 10:23:03 AM9/2/20
to Racket Users
This may be a somewhat niche request, but hopefully it's just a special case of a common need.

I have multiple files, say V1 and V2, that each provide the same surface language constructs – e.g., #%app, some macros, some functions — but of course implemented in different ways. I also have additional files, say V21 and V22, that need to extend the common language of V1/2 in a consistent way (e.g., add a few more macros and functions that both V21 and V22 provide).

By default, I can only identify missing things through tests. I would like to statically ensure that I have provided the same interfaces, and ideally describe the delta between V21/22 and V1/2 (rather than copy the description of V1/2 into V21/22).

Essentially, I want to describe the grammar in one place, à la BNF, including the names of primitives and such. Note that I want a specification of the language, separate from its implementation (since I'd also like to generate a Web page giving that spec).

There's define-syntax-class for creating new classes for use in a syntax-parser. I suppose I could create a rather complex syntax class that represents the whole language; presumably I would then apply to this to the entire body through module-begin (and to REPL instructions via top-interaction)?

Has anyone done something like this and would care to share an example?

Thanks!

Shriram

Shriram Krishnamurthi

unread,
Sep 2, 2020, 1:14:04 PM9/2/20
to Racket Users
I realize I could have used `define-language` and `define-extended-language` and friends from Redex, except … `redex-match` works over terms, not over syntax objects. 

Of course I also can't write

(redex-match LANG NON-TERM (term (syntax->datum S)))

because TERM is a special form, so it doesn't evaluate.
Reply all
Reply to author
Forward
0 new messages