Skip to content
Thomas Byr edited this page Apr 18, 2022 · 1 revision

Welcome

Hello new Compiler bot users!

Compiler bot supports lots of different things, so bear with this quick guide for a moment to quickly get you up to speed.

First things first check out the bot's ;help command. For more specific help on a command you can execute ;help <cmd>.

1. Limitations

Keep in mind that we're working in discord. This means, of course, that we have many operating restraints. Here's a few of the big ones.

  • Complicated syntax for non-trivial compilations
  • Limited output length (limited to a couple hundred characters)
  • Single-file input only

2. Hello World

Here's an example with a compilation request for a hello world program in the python language.

Figure 2.1

;compile
```python
print("Hello world!")
```

Code Blocks

If you don't already know: ``` indicates the start and end of a code block, by putting the language immediately after the first set of them, discord will syntax-highlight your code.

Most of the time the compiler bot is able to identify what programming language you're using from this, but if you want to be specific you may specify it, too. That looks like the following.

Figure 2.2

;compile python
```
print("Hello world!")
```

If you ever mess up and your code doesn't compile, edit your original message and the bot will re-run it. Or if you give up just delete your message and the bot will delete theirs.

3. Other Languages & Compilers

Compiler supports many different languages with many different compilers. Lets take a look at how to view them.

3.1 Languages

If you want to see all of the languages compiler supports, type ;languages.

3.2 Compilers

If you want to see all compilers/interpreters you can use for any language, you can type ;compilers <language>. For example, ;compilers c++.

*Note: Keep in mind the bold text for each compiler type. If you want to use a specific compiler, then this bolded text must be specified instead of the language like in figure 2.2.

3.3 Assembly

Any language shown in the ;languages list that has an asterisks(*) can have it's assembly inspected. Instead of ;compile you will use ;asm, but its usage is the same.

3.4 Formatting

If someone ever posts code that is ill-formatted you may quote the message containing the codeblock and type ;format. See ;formats for all options, but the default (clang-format's WebKit) should work fine for most situations.

4. Advanced Usage

Now let's talk about some of the specifics of everything packed into the ;compile command. It's quite a complicated command, and it trips up many.

Below is going to be the outline for how parsing works, I will put all variables in <> and you should be able to understand the nuances of the grammar to execute more complicated compilations.

Figure 4.1

;compile <language/compiler> <compiler flags> | <one line stdin> < <url to request code from>
<command line arguments>
```
code
```

Or if you need multi-line stdin

Figure 4.2

;compile <language/compiler> <compiler flags> < <url to request code from>
<command line arguments>
```
stdin
```
```
code
```

Putting that all together, a request can look like:

Figure 4.3

;compile c++ -O3 -Wall -Werror | test2
test1
```cpp
#include <string>
#include <iostream>
int main(int argc, char** argv) {
  std::string str;
  std::getline(std::cin, str);
  std::cout << str << std::endl;
  std::cout << argv[1] << std::endl;
  return 0;
}
```

I encourage you to try this for yourself and see how it works, go ahead and copy what's above and paste it into a message, tinker as needed.