By Frank Gerlach(frankgerlach.tai@gmx.de)
In the following, I will describe how to create your very first Sappeur program. Linux/POSIX environment will be used.
$ mkdir helloworld $ mkdir helloworld/output
$ cd helloworld $ cp ../gauss/String.a* . $ cp ../gauss/System.a* . $ cp ../gauss/callCompiler.sh .
$ vi compileorderContent:
String.ad, System.ad, AppMain.ad
$ vi AppMain.ad
Of course you can use any editor of your choice, including nano, emacs, notepad++ etc. Please do NOT use notepad. Encoding must be ASCII, no special characters such as umlauts.
Content:class Main { methods: int main(); };Now, implement the main method in a sappeur implementation (*.ai) file.
$ vi AppMain.aiContent:
int Main::main() { var PrintfClass pfc; pfc.fstr("Hello World !").pr(); return 1; }Explanation: You create an object of type PrintfClass. Then you call the format string method and finally call the pr() method to actually print to STDOUT.
$ ./callCompiler.shNote that it might be necessary to adapt this shell script to your Sappeur compiler installation.
$ cd output $ make -f Makefile -j 4 all
$ ./sprprog.exeNote that the executable name is a historic leftover from the windows world, where the compiler was first hosted. Despite the *.exe extension, this is a normal Linux/POSIX program. In most cases the program can be renamed easily. Also, you can change(and rename, to avoid overwrite) the Makefile to create a program name of your choice.
pi@rpigross:~/helloworld/output $ time ./sprprog.exe Hello World ! real 0m0,013s user 0m0,001s sys 0m0,012s