44 lines
843 B
Text
44 lines
843 B
Text
include("std.print")
|
|
|
|
# external print implementation ex ##
|
|
print ( fmt : (compexpr | string) , values : any ... ) : void {
|
|
|
|
last_n : int = 0
|
|
|
|
for (values) -> (value : any) {
|
|
|
|
n : int = str_finds( fmt , "%" , last_n )
|
|
|
|
static_assert( n != INT_MAX, "Number of format arguments does not match passed values!" )
|
|
|
|
putstr( stdout, fmt[last_n : n] )
|
|
|
|
switch (value) {
|
|
default : break
|
|
case (int) : putstr( stdout, to_str_from_int( int(value) ) )
|
|
case (float) : putstr( stdout, to_str_from_float( int(value) ) )
|
|
}
|
|
|
|
last_n = n
|
|
}
|
|
}
|
|
######################################
|
|
|
|
|
|
|
|
test_func ( x : int , y : int ) : int {
|
|
return ( x * y );
|
|
};
|
|
|
|
print( "test_func(%, %) = %" , 2, 3, test_func(2,3) );
|
|
|
|
x : int = 12345;
|
|
|
|
if ( x > 0 ) {
|
|
print( "as expected; x = %\n" , x )
|
|
}
|
|
|
|
main ( argc : int , argv : string[_] ) : int {
|
|
|
|
return (0);
|
|
}
|