multi-file-lang
7.7

multi-file-lang

source code: https://github.com/AlexKnauth/multi-file-lang

A #lang language for writing multiple files as one file.
Different files are separated by #file  followed by the file name. Each file is created with a path relative to the multi-file source file.
If a sub-file is not a #lang file (according to lang-file?), multi-file does not run it, but it is still created so that other files can read from it.
For example this file:
#lang multi-file
#file a.rkt
#lang racket/base
(provide x f)
(define x 3)
(define (f x) (string-append "hello" (make-string x #\!)))
(f 1)
#file b.rkt
#lang racket/base
(require "a.rkt")
x
(f x)
Would create the files a.rkt and b.rkt in the same directory as this file, and running this file would run both of them.
And this file:
#lang multi-file
#file a.rkt
#lang racket/base
(read-line (open-input-file "data/text.txt"))
#file data/text.txt
I'm not code, I'm just text in a text file.
Would create the file a.rkt in the same directory as this file, and the file data/text.txt relative to this file. Running this file would only run a.rkt because data/text.txt is not a #lang file or a module file.