esseks/monicelli — pull request #16 by massix (2014-12-06 17:46:31+00:00)
Title: Added options for input and output files.

Hello,
in order to have mcc feel like a real compiler, some program options have to be parsed.
I've added a facility to do it, in a simple and portable way (among UNIX systems, not sure about Windows though) and started testing using the "-i" and "-o" flags.
Everything is working fine so far.

### Both input and output provided
```
# massi at napi.home in ~/developer/monicelli on git:feature/options x [18:38:57]
$ ./mcc -i examples/float.mc -o float.cpp
META: Test all possible numerical forms (integer and float)

# massi at napi.home in ~/developer/monicelli on git:feature/options x [18:41:40]
$ cat float.cpp
#include
#include
#include

int main() {
std::cout << (2) << std::endl;
std::cout << (-2) << std::endl;
std::cout << (2) << std::endl;
std::cout << (0.232) << std::endl;
std::cout << (-2) << std::endl;
std::cout << (-0.2233) << std::endl;
std::cout << (2) << std::endl;
std::cout << (2.233e-23) << std::endl;
}
```

### Only input (output on stdout by default)
```
# massi at napi.home in ~/developer/monicelli on git:feature/options x [18:41:43]
$ ./mcc -i examples/float.mc
META: Test all possible numerical forms (integer and float)
#include
#include
#include

int main() {
std::cout << (2) << std::endl;
std::cout << (-2) << std::endl;
std::cout << (2) << std::endl;
std::cout << (0.232) << std::endl;
std::cout << (-2) << std::endl;
std::cout << (-0.2233) << std::endl;
std::cout << (2) << std::endl;
std::cout << (2.233e-23) << std::endl;
}
```

### Only output (input on stdin by default)
```
# massi at napi.home in ~/developer/monicelli on git:feature/options x [18:43:13]
$ cat examples/float.mc| ./mcc -o float.cpp
META: Test all possible numerical forms (integer and float)

# massi at napi.home in ~/developer/monicelli on git:feature/options x [18:43:15]
$ cat float.cpp
#include
#include
#include

int main() {
std::cout << (2) << std::endl;
std::cout << (-2) << std::endl;
std::cout << (2) << std::endl;
std::cout << (0.232) << std::endl;
std::cout << (-2) << std::endl;
std::cout << (-0.2233) << std::endl;
std::cout << (2) << std::endl;
std::cout << (2.233e-23) << std::endl;
}
```

Let me know if something feels weird (the parsing might be a little bit *too* basic?).
Adding a `--help` option should be easy enough, just by tweaking the Option class in order to accept a boolean value and pretty printing the descriptions of all the options.