Esoteric Language Interpreter

What could I improve upon? I'm trying to make this as efficient as possible.
FYI: This is an esoteric language and I made it for fun. I haven't put much time into it (no more than 35 minutes), but I think I'm already done with it. :P

Yes, I know, it's sloppy. It normally wouldn't be like this but I tried to write it as quickly as possible because I was only given 45 minutes for Code-A-Thon.

oxc.txt:
1
2
3
4
-hello world;
:++++{-|}
-derpetta being raped;
:++{-|}


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <iostream>
#include <string>
#include <fstream>

int main(int argc, char *arg[]) {
    int counter = 0;
    std::string buffer, var;
    std::ifstream readFile(arg[1]);
    getline(readFile, buffer, '\0');
    readFile.close();
    for(int i = 0; buffer[i] != '\0'; ++i) {
        if(buffer[i-1] == '>') {
            while(buffer[i] != ';') {
                if(buffer[i] == '-') 
                    std::cout << var;
                else 
                    std::cout << buffer[i]; 
                ++i;
            } 
        }
        else if(buffer[i-1] == ':') {
            while(buffer[i] == '+') {
                ++counter; 
                ++i;
            }
            ++i;
        }
        if(buffer[i-1] == '{') {
            std::string output;
            while(buffer[i] != '}') {
                if(buffer[i] == '|') 
                    output+='\n';
                else if(buffer[i] == '-') 
                    output+=var;
                else 
                    output+=buffer[i]; ++i;
            }
            while(counter != 0) {
                std::cout << output;
                --counter;
            }
        }
        else if(buffer[i-1] == '-') {
            var = "";
            while(buffer[i] != ';') {
                var+=buffer[i]; 
                ++i;
            }
        }
        else if(buffer[i-1] == '|') {
            std::cout << '\n';
        }
    }
    return 0;
}
Last edited on
Topic archived. No new replies allowed.