/Develop/Projects/Vcc/ |
|
k1.spdns.de / Develop / Projects / Vcc / |
intro | invocation | preprocessor | types | functions | operators | instructions
Vicci is a compiler for a C-style language with some functionality of C++ and some additional concepts. As i have realized lately, it's actually more a Java-style language.
The compiler is developed to create machine code for my home-built CPU project.
The current version creates and executes a virtual machine code ("bytecode") for all 3 CPUs supported by Mac OSX (PPC, i386, i386x64).
The assembler backend may be rewritten to support any other CPU.
Vicci can be used to compile applications, as a script interpreter (TODO) and interactively like a shell (TODO).
Programs can be started by their source if the first line is "#!/usr/bin/vicci" (or what applies), just like scripts.
make: maintains program versions depending on command line options and target cpu.
updates programs when vicci, sources and header modification dates changed.
compiler (frontend)
assembler (backend)
linker for the built-in interpreter
built-in bytecode interpreter
"C"-style syntax with more rational operator hierarchy.
"Basic"-style text string operations.
Procedure names can be overloaded and procedures are choosen with a 'score' scheme.
Structs and arrays are always dynamically allocated with defined ownership.
Pointers are possible but rarely needed.
Procedures, scopes, type definitions and constants may be local and nested.
Structs may be subclassed and have member functions.
header files are only included once (though multiple is possible).
Data members and member functions are always accessed with '.', there is no '->'.
Index '[]' does not work on pointers!
Assignment operators return void.
Function pointer syntax is less awkward.
Sequence of program initialization is predictable.
Sequence of operator and procedure argument of evaluation is predictable.
Syntax as of 2011-05-04
#include "stdc.h"
print("Hello Vicci!\n")
float fak(float n)
{
return n<=1 ? 1 : fak(n-1)*n
}
Create 503 threads and pass a token 50 mio times from thread to thread. Print number of final receiver of token.
see shootout.alioth.debian.org/u32/benchmark.php?test=threadring&lang=all
#include "stdc.h"
uint token = 1 + numval uint(args[1])
sema[503] s
sema done
void fu(int i)
{
sema¢ a = s[i]
sema¢ e = s[++i%503]
do
{
a.request()
while --token
e.release()
}
print(""+i+"\n")
done.release()
}
int i
do { spawn fu(i) while ++i<503 }
s[0].release()
done.request()
Print the lyrics of "99 Bottles of Beer on the Wall"
see www.99-bottles-of-beer.net.
Slightly drunk, Nordish version.
This programme was compiled to a microcode instruction for the K1-16/16 CPU. (Nov. 2014)
The total size was 199 bytes of 24 bit. The sober British version would have been 4 bytes longer.
#include "FD.h"
#define sing(gröl) o.putstr(gröl)
str bob(int øl)
{
return ((øl>0?numstr(øl):charstr(øl?'N':'n')+"o more") + " boddle" + (øl-1?"s":"")) + " of øl"
}
str bobo(int øl)
{
return bob(øl) + " on the wåll"
}
void sing_99_bottles_of_beer(FD¢ o, int øl)
{
do
{
sing(bobo(øl-!øl) + ", " + bob(øl) + '.'+'\n')
if øl>0 sing("Take one down and pass it aroun, " + bobo(--øl) + ".\n\n")
else { sing("Goto the store and buy some more, " + bobo(99) + '.'+'\n'); exit }
}
}
Name | Letzte Änderung | Länge | |||
---|---|---|---|---|---|
lib-Z80-Rop/ | 2020-11-30 15:50 | 21 | |||
lib-Z80-Vss/ | 2017-11-12 09:55 | 452 | |||
lib/ | 2019-10-30 17:02 | 3 | |||
Libraries/ | 2019-10-30 17:11 | 6 | |||
OSX-Qt40/ | 2019-10-30 17:02 | 5 | |||
OSX/ | 2020-09-05 12:54 | 6 | |||
Source/ | 2019-10-30 17:02 | 11 | |||
Tests/ | 2019-10-30 17:02 | 9 | |||
LICENSE | 2019-10-30 17:25 | 1323 | |||
README.md | 2019-10-30 17:25 | 288 | |||
TODO.txt | 2020-10-18 12:42 | 340 |