LinuxScript (stylized name - linuxscript) is a simple programming language based on Linux x86_64 system calls.
linuxscript compiler (lsc) is small tool to translate
code written in linuxscript to assembly. This compiler is early stage
and for now is really small, but contains all tools used to generate
assembly.
Assembler and Linker are not delivered, because, as UNIX
Philosophy says - "do one thing and do it well". Why build in assembler
and linker, where you can get nasm from your package manager, and you
probably already have linker delivered with your distro.
Example code that just will run and do nothing:
# Example comment
main(void)
{
}
This example code can be compiled with lsc, but also any C compiler.
lsc compilation command:
$ lsc < code.ls > code.asm &&
nasm -felf32 -o code.o code.asm &&
ld -o code code.o
Other example, for now not working, but syntax like this
is planned:
# Simple "hello, world" program
main(void)
{
write(1, "hello, world", 11);
}
Another example, this time more futuristic
also planned, but not for now:
# Simple "hello, world" program in higher-level way
# Here will be probably some "include" of higher level lib
main(void)
{
print("Hello, world!");
}
And last example - higher level, but cross-compilable with C
# Simple "hello, world" program in higher-level way
#include <stdio.h>
#define print puts
main(void)
{
print("Hello, world!");
}
For now, lsc is in early stage, and it is only tool delivered with
linuxscript tools, don't even try to use it in production stage.
Things to do:
X] Main fileX] FunctionsX] StatementsX] Expressions
Clone: git clone git://git.kocotian.pl/ls.git
Stagit webpage: https://git.kocotian.pl/ls