For example, I'm building this Brainfuck interpreter. I want to add some people's programs as test cases. For example this program.

The program I want to add to my repository is MIT licensed in this case, but if possible I'd like to get an answer not specific to this license. My question is basically: /what is the conventional and correct way to make note of his license such that I can just take the file and put it in my repo? I know his license allows for it but I'm not sure what I should do. (I could copy his file, but what would be 'correct' way to note to which files it applies?)

An extra difficulty here is that it concerns brainfuck code, in which there are no normal comments. So I can't just take the license and put it at the top of the copied file either, which is what I would do otherwise.

  • Would something like this work? opensource.stackexchange.com/a/203/69
    – Zizouz212
    Commented Aug 16, 2016 at 19:06
  • 1
    @Zizouz212 What is recommended there is exactly what can't be done: To place the license in a comment. In brainfuck a comment is just 'whatever is not a valid instruction' but , and . are both valid instructions and in the license. But now that I think of it, I could do something like see LICENSE file for extra info. However, I wonder if I could just place it under my own license as in: This is the license ... for these files another license applies ...
    – Lara
    Commented Aug 16, 2016 at 19:34
  • It sounds like an awfully similar situation to licensing json files. Did you read the paragraph in my answer about how to license that?
    – Zizouz212
    Commented Aug 16, 2016 at 19:34
  • @Zizouz212 it recommends an extra file to contain the license itself. I guess I could do that, the only drawback being that very soon I'll have 10 different license files floating around, but maybe that can't be helped.
    – Lara
    Commented Aug 16, 2016 at 19:38
  • Yeah, that's definitely a drawback. Who knows, hopefully people have encountered something like this before, and may know a possible answer :) (Oh, also, each file doesn't need to have an associated license file. For every project that you use, one license file for the used project will suffice)
    – Zizouz212
    Commented Aug 16, 2016 at 19:39

2 Answers 2


One solution is to include the license files and mention them in comments:

This code is licensed under the MIT License
<code here>

Another brainfuck-specific solution is to include the license terms inside of a loop at the beginning of the program (which will not execute, because the value at the start of the tape is 0, so the loop will be skipped):

[This code is licensed under the MIT License. blah blah blah license terms, blah blah blah more license terms.]
<code here>

Alternatively, you can use an "umbrella" license file, which states the license(s) that each file is/are licensed under (assuming you have a directory in your repo containing all of the relevant licenses):

foo.bf and bar.bf are licensed under the [MIT License](Licenses/MIT).
baz.bf is licensed under the [Apache License](Licenses/Apache).

Finally, because you are using Git, you can use a submodule in your repository pointing towards the other repository, with its own licensing terms.

All of this is assuming that the licenses are compatible, of course.


You can always note the fact that, when the pointer points at a zero cell, the while loop skips its contents. So, if you know for a fact that the current cell is zero, you can include a comment like this:

[This is a "cat" program, which outputs all of its input.]
[This program expects 0 to be returned on end-of-input.]
[Do note that the brackets [have to be] balanced for this to work correctly.]

When worse comes to worse, and you do not know if the current cell is zero, you can resort to "restricted comments"--comments without any of +-<>,.[] in them. For example:

,       gets initial input char
[       starts a loop
 .       prints the previous input char
 ,       and gets new input
]       if the input is 0x00 then the loop closes and we reach EOF

If you must have your punctuation in there, you can always use "verbose punctuation":

This is a sentence COMMA but looks rather odd DOT

(I've seen this approach myself a few times, but I remember not where.)


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.