spydr06 / cspydr Goto Github PK
View Code? Open in Web Editor NEWA static typed low-level compiled programming language inspired by Rust and C
License: MIT License
A static typed low-level compiled programming language inspired by Rust and C
License: MIT License
cURL implementation broken because of that.
-> Types defined in namespace curl
in curl.csp are not getting detected in the same namespace curl
in easy.csp
Compiler error:
easy.csp:42:35 => [type]: undefined data type `CURL`
42 | fn curl_easy_setopt(curl: &CURL, option: curl::CURLoption, args: ...): CURLcode;
|
so we can talk share ideas etc.
Hello.
Firstly, congratulations on developing such an appealing language.
My question is rather straightforward, I suppose: What is the plan for CSpydr? What are its goals? What does it aim to achieve and what issues does it seek to mitigate?
As the creator, how far do you intend to take your creation?
Thank you, and best wishes. I certainly look forward to exploring the language further.
Currently only alias export directive possible is if you call it individually outside a namescope and if not inside an extern "C" {}
scope:
[export("MyFunction")]
extern "C" fn my_function(): i32;
I think it would be great if you could include the export directive to be part of a the extern scope like this:
[link("mylib")]
namespace lib {
extern "C" {
[export("MyFunction")]
fn my_function(): i32;
}
}
Meaning extern
in the fn get_screen_width(): i32;
is unnecessary and allows for bundling all imports in one scope for cleaner code (imo.)
Currently attempting this would give the following error:
=> [syntax]: expect function or variable declaration
7 | [export("MyFunction")]
| ^-here
I've encountered an odd behaviour with floats and printf where the output returned is not the value you've provided:
We have the following code:
import "std.csp";
fn main(): i32 {
using std::io;
macro PI { 3.14159265358979323846 }
let pi: f32 = 1.2;
let num: i32 = 55;
printf("%i\n", num);
printf("%f\n", PI!);
printf("%f\n", pi);
<- 0;
}
The output is:
55
3.0000000000
1.0000000000
Does CSpydr not use the same formatting rule as C? Is there something done wrong in this example or there is a deeper underlying problem causing this? As you can see, the integer is printed out fine.
Is it possible to package the VSC editor as VSIX please for ease of installation?
I've just tested it and it packaged ok, but does mention that LICENSE.txt is missing.
I've also pushed PR to slightly fix the installation for current version.
Thanks!
This code segfaults:
bar([1, 2, 3] |> $[0] + $[1]);
This doesn't:
foo();
bar([1, 2, 3] |> $[0] + $[1]);
I wanted to mess about creating a CSpydr binding to Raylib which seems to work when using [link("raylib")]
as recommended.
When building the executable it seems to work and linker finds the shared lib, however. When trying to run the binary we're met with error:
./main: error while loading shared libraries: libraylib.so.450: cannot open shared object file: No such file or directory
While the shared libs are also present in the same dir as the executable.
Am I missing something here?
Error when building, looks like paths are wrong?
8 | #include <json-c/json_object.h>
| ^~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [src/compiler/CMakeFiles/libcspc.dir/build.make:104: src/compiler/CMakeFiles/libcspc.dir/ast/ast_json.c.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:1293: src/compiler/CMakeFiles/libcspc.dir/all] Error 2
make: *** [Makefile:156: all] Error 2
Apologies for a vague subject, unsure how to properly form it in words.
What I mean by this suggestion is to provide an ability to create CSpydr internal function names as an alias to what is being linked with a C library.
e.g.
extern "C" fn cFunctionNameA(): int32;
extern "C" fn cFunctionNameB(): int32;
The name matches exactly the same as it does in the C code, but it would be great to give the user an ability to also provide their own internal CSpydr name e.g.:
fn c_function_nameA() @extern "C" cFunctionNameA(): int32;
fn c_function_nameB() @extern "C" cFunctionNameB(): int32;
I'm most certain there would be some ways to make it look pretty, but it would be great if it was possible to do so.
Correct me if I'm wrong and this already exists?
Draft on how interfaces will be implemented:
import "std.csp";
type Foo: interface {
fn foo(self: &Foo): i32
};
type Bar: struct {
x: i32
};
# how to implement Foo for Bar?
fn main(): i32 {
let bar = Bar::{0};
(&bar: &Foo).foo();
<- 0;
}
The main question is: how should the syntax for implementing Foo
for Bar
look like?
As the issue title describes.
Bug must be located in here:
static char* get_full_import_path(char* origin, Token_T* import_file);
(preprocessor.c:144
)
Based on commit 5993a2d should we assume LLVM is no longer required? If yes, could it be possible to update the INSTALL.md guide to reflect this?
Currently, Arrays in CSpydr get treated exactly like their C counterparts. Meaning only the data gets stored in memory.
+-----------------+---------+---------+---------+---------+-------...
| length (8 byte) | indices (variable size determined by the data type)
+-----------------+---------+---------+---------+---------+-------...
Change to the index operator x[]
Add a simple offset of 8 bytes when an array type is detected. Interaction with pointers will not be changed to keep compatibility with C.
Change of the len
keyword:
The len
keyword will now be able to get the first 8 bytes - the length of the array directly and is no longer bound to constant arrays
Development is going to happen in the new-arrays
Is there any reason behind this? I think it might be conflicting if we have two different imports where the macros share the same name (low possibility, but still worth thinking over it.)
What would happen if library A & library B both have a macro named PI and not under a namespace? Which macro would be called?
Is there any possibility to allow adding macros in namespaces and allowing them to be called e.g.
namespace my_namespace {
macro PI { 3.14159265358979323846 }
}
....
fn main(): i32 {
using std::io;
printf("%f\n", my_namespace::PI!);
<- 0;
}
Work in progress CSpydr Gtk4 bindings. I know I'm not a smart enough to contribute "important" code but a gui library is something I really think is nice to have in CSpydr. Coming soon.
Video preview
Screencast from 06-04-2023 14:58:55.webm
it would be fun!
I see you're also working on a different language and few other repo's that would indicate other interests. Are there plans to focus on this language or move onto something else? IMO the language has a potential, but it's difficult to consider interest in it if it's going to be thrown on a shelf of unwanted projects.
Unsure why, but CSpydr is failing to build on Ubuntu while all dependencies are met:
./configure
checking host system type... linux-gnu
checking for C compiler... /usr/bin/gcc
checking whether the C compiler works... yes
checking for linker... /usr/bin/gcc
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config directory... /usr/share/pkgconfig
checking for bear... found.
checking for git... found.
checking for install... found.
checking for find... found.
checking for mkdir... found.
checking for rm... found.
checking for sed... found.
checking for libpkgconf... found.
checking for json-c... found.
checking for acutest... found.
removing existing /home/ishimachi/Repositories/cspydr/config.mk file... done.
generating /home/ishimachi/Repositories/cspydr/config.mk file... done.
generated configuration:
# Auto-generated by `configure`
CC := /usr/bin/gcc
LD := /usr/bin/gcc
CFLAGS := -fPIC -flto -Wall -Wextra -Wno-unused-parameter -DDEFAULT_STD_PATH="\"/usr/local/share/cspydr/std\"" -I/usr/include/pkgconf -I/usr/include/json-c
LDFLAGS := -lm -lpkgconf -ljson-c
INSTALL := /usr/bin/install
FIND := /usr/bin/find
MKDIR := /usr/bin/mkdir
RM := /usr/bin/rm
SED := /usr/bin/sed
BEAR := /usr/bin/bear
PREFIX := /usr/local
EXEC_PREFIX := /usr/local
BUILD_PREFIX := /home/ishimachi/Repositories/cspydr/build
BIN_PREFIX := /home/ishimachi/Repositories/cspydr/build/bin
PKG_CONFIG_DIR := /usr/share/pkgconfig
SRC_DIR := /home/ishimachi/Repositories/cspydr/src
CSPC_DEFAULT_STD_PATH := /usr/local/share/cspydr/std
VERSION := 0.1.1
VERSION_X := 0
VERSION_Y := 1
VERSION_Z := 1
GIT_HASH := cad5936
done.
Error logs:
make
make -C /home/ishimachi/Repositories/cspydr/src/compiler LIBCSPC=/home/ishimachi/Repositories/cspydr/build/bin/libcspc.o CSPC=/home/ishimachi/Repositories/cspydr/build/bin/cspc /home/ishimachi/Repositories/cspydr/build/bin/libcspc.o
make[1]: Entering directory '/home/ishimachi/Repositories/cspydr/src/compiler'
make[1]: '/home/ishimachi/Repositories/cspydr/build/bin/libcspc.o' is up to date.
make[1]: Leaving directory '/home/ishimachi/Repositories/cspydr/src/compiler'
make -C /home/ishimachi/Repositories/cspydr/src/compiler LIBCSPC=/home/ishimachi/Repositories/cspydr/build/bin/libcspc.o CSPC=/home/ishimachi/Repositories/cspydr/build/bin/cspc /home/ishimachi/Repositories/cspydr/build/bin/cspc
make[1]: Entering directory '/home/ishimachi/Repositories/cspydr/src/compiler'
/usr/bin/gcc -lm -lpkgconf -ljson-c /home/ishimachi/Repositories/cspydr/build/compiler/./context.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./version.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./parser/typechecker.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./parser/directives.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./parser/utils.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./parser/queue.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./parser/parser.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./parser/validator.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./debugger/breakpoint.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./debugger/register.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./debugger/debugger.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./main.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./c_parser/c_lexer.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./c_parser/c_parser.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./preprocessor/preprocessor.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./preprocessor/stdmacros.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./ast/ast_iterator.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./ast/ast_json.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./ast/types.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./ast/ast.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./memory/allocator.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./toolchain.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./timer/timer.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./interpreter/stack.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./interpreter/interpreter.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./interpreter/value.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./platform/win32/win32_platform.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./platform/pkg_config.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./platform/linux/linux_platform.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./error/error.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./error/panic.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./error/default.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./codegen/asm/asm_codegen.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./codegen/asm/relocation.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./codegen/asm/linker.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./codegen/codegen_utils.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./codegen/transpiler/keywords.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./codegen/transpiler/c_codegen.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./hashmap.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./optimizer/constexpr.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./optimizer/optimizer.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./lexer/token.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./lexer/lexer.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./config.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./list.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./io/io.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./io/file.c.o /home/ishimachi/Repositories/cspydr/build/compiler/./util.c.o -o /home/ishimachi/Repositories/cspydr/build/bin/cspc
/usr/bin/ld: /tmp/ccf7MyUz.ltrans0.ltrans.o: in function `align_type':
<artificial>:(.text+0x14b41): undefined reference to `log'
/usr/bin/ld: <artificial>:(.text+0x14b66): undefined reference to `floor'
/usr/bin/ld: <artificial>:(.text+0x14b81): undefined reference to `pow'
/usr/bin/ld: <artificial>:(.text+0x14bbb): undefined reference to `log'
/usr/bin/ld: <artificial>:(.text+0x14be0): undefined reference to `floor'
/usr/bin/ld: <artificial>:(.text+0x14bfb): undefined reference to `pow'
/usr/bin/ld: <artificial>:(.text+0x14c22): undefined reference to `log'
/usr/bin/ld: <artificial>:(.text+0x14c47): undefined reference to `floor'
/usr/bin/ld: <artificial>:(.text+0x14c62): undefined reference to `pow'
/usr/bin/ld: <artificial>:(.text+0x14c95): undefined reference to `log'
/usr/bin/ld: <artificial>:(.text+0x14cba): undefined reference to `floor'
/usr/bin/ld: <artificial>:(.text+0x14cd5): undefined reference to `pow'
/usr/bin/ld: /tmp/ccf7MyUz.ltrans0.ltrans.o: in function `get_type_align':
<artificial>:(.text+0x15364): undefined reference to `log'
/usr/bin/ld: <artificial>:(.text+0x15389): undefined reference to `floor'
/usr/bin/ld: <artificial>:(.text+0x153a4): undefined reference to `pow'
/usr/bin/ld: <artificial>:(.text+0x153de): undefined reference to `log'
/usr/bin/ld: <artificial>:(.text+0x15403): undefined reference to `floor'
/usr/bin/ld: <artificial>:(.text+0x1541e): undefined reference to `pow'
/usr/bin/ld: <artificial>:(.text+0x15445): undefined reference to `log'
/usr/bin/ld: <artificial>:(.text+0x1546a): undefined reference to `floor'
/usr/bin/ld: <artificial>:(.text+0x15485): undefined reference to `pow'
/usr/bin/ld: <artificial>:(.text+0x154b8): undefined reference to `log'
/usr/bin/ld: <artificial>:(.text+0x154dd): undefined reference to `floor'
/usr/bin/ld: <artificial>:(.text+0x154f8): undefined reference to `pow'
/usr/bin/ld: /tmp/ccf7MyUz.ltrans0.ltrans.o: in function `ast_to_json':
<artificial>:(.text+0x1d779): undefined reference to `json_object_to_json_string_ext'
/usr/bin/ld: <artificial>:(.text+0x1d7ae): undefined reference to `json_object_put'
/usr/bin/ld: /tmp/ccf7MyUz.ltrans0.ltrans.o: in function `gen_str':
<artificial>:(.text+0x1d7d4): undefined reference to `json_object_new_string'
/usr/bin/ld: <artificial>:(.text+0x1d7db): undefined reference to `json_object_new_null'
/usr/bin/ld: /tmp/ccf7MyUz.ltrans0.ltrans.o: in function `gen_i32':
<artificial>:(.text+0x1d7f6): undefined reference to `json_object_new_int'
/usr/bin/ld: /tmp/ccf7MyUz.ltrans0.ltrans.o: in function `gen_i64':
<artificial>:(.text+0x1d814): undefined reference to `json_object_new_int64'
/usr/bin/ld: /tmp/ccf7MyUz.ltrans0.ltrans.o: in function `gen_bool':
<artificial>:(.text+0x1d832): undefined reference to `json_object_new_boolean'
/usr/bin/ld: /tmp/ccf7MyUz.ltrans0.ltrans.o: in function `gen_list':
<artificial>:(.text+0x1d854): undefined reference to `json_object_new_null'
/usr/bin/ld: <artificial>:(.text+0x1d85b): undefined reference to `json_object_new_array'
/usr/bin/ld: <artificial>:(.text+0x1d89a): undefined reference to `json_object_array_add'
/usr/bin/ld: /tmp/ccf7MyUz.ltrans0.ltrans.o: in function `gen_tok':
<artificial>:(.text+0x1d8ce): undefined reference to `json_object_new_null'
/usr/bin/ld: <artificial>:(.text+0x1d8d8): undefined reference to `json_object_new_object'
/usr/bin/ld: <artificial>:(.text+0x1d914): undefined reference to `json_object_object_add'
/usr/bin/ld: <artificial>:(.text+0x1d947): undefined reference to `json_object_object_add'
/usr/bin/ld: <artificial>:(.text+0x1d97c): undefined reference to `json_object_object_add'
/usr/bin/ld: <artificial>:(.text+0x1d9a6): undefined reference to `json_object_object_add'
/usr/bin/ld: <artificial>:(.text+0x1d9de): undefined reference to `json_object_object_add'
/usr/bin/ld: /tmp/ccf7MyUz.ltrans0.ltrans.o: in function `gen_srcfile':
<artificial>:(.text+0x1da00): undefined reference to `json_object_new_null'
/usr/bin/ld: <artificial>:(.text+0x1da07): undefined reference to `json_object_new_object'
/usr/bin/ld: <artificial>:(.text+0x1da35): undefined reference to `json_object_object_add'
/usr/bin/ld: <artificial>:(.text+0x1da5c): undefined reference to `json_object_object_add'
/usr/bin/ld: /tmp/ccf7MyUz.ltrans0.ltrans.o: in function `gen_ast_identifier':
<artificial>:(.text+0x1da7e): undefined reference to `json_object_new_null'
/usr/bin/ld: <artificial>:(.text+0x1da88): undefined reference to `json_object_new_object'
/usr/bin/ld: <artificial>:(.text+0x1dac0): undefined reference to `json_object_object_add'
/usr/bin/ld: <artificial>:(.text+0x1daf8): undefined reference to `json_object_object_add'
/usr/bin/ld: <artificial>:(.text+0x1db2e): undefined reference to `json_object_object_add'
/usr/bin/ld: <artificial>:(.text+0x1db65): undefined reference to `json_object_object_add'
/usr/bin/ld: /tmp/ccf7MyUz.ltrans0.ltrans.o: in function `gen_namespace_start':
<artificial>:(.text+0x1dbce): undefined reference to `json_object_new_object'
/usr/bin/ld: /tmp/ccf7MyUz.ltrans0.ltrans.o: in function `gen_ast_prog':
<artificial>:(.text+0x1dc2c): undefined reference to `json_object_new_object'
/usr/bin/ld: <artificial>:(.text+0x1dc61): undefined reference to `json_object_object_add'
/usr/bin/ld: <artificial>:(.text+0x1dc90): undefined reference to `json_object_object_add'
/usr/bin/ld: <artificial>:(.text+0x1dcc9): undefined reference to `json_object_object_add'
/usr/bin/ld: /tmp/ccf7MyUz.ltrans0.ltrans.o: in function `pkg_config':
<artificial>:(.text+0x293d7): undefined reference to `pkgconf_cross_personality_default'
/usr/bin/ld: <artificial>:(.text+0x29421): undefined reference to `pkgconf_client_new'
/usr/bin/ld: <artificial>:(.text+0x2942a): undefined reference to `pkgconf_cross_personality_default'
/usr/bin/ld: <artificial>:(.text+0x2943c): undefined reference to `pkgconf_client_dir_list_build'
/usr/bin/ld: <artificial>:(.text+0x29452): undefined reference to `pkgconf_pkg_find'
/usr/bin/ld: <artificial>:(.text+0x294b3): undefined reference to `pkgconf_pkg_libs'
/usr/bin/ld: <artificial>:(.text+0x294e8): undefined reference to `pkgconf_error'
/usr/bin/ld: <artificial>:(.text+0x295d9): undefined reference to `pkgconf_fragment_free'
/usr/bin/ld: <artificial>:(.text+0x295ec): undefined reference to `pkgconf_pkg_free'
/usr/bin/ld: <artificial>:(.text+0x295f8): undefined reference to `pkgconf_client_free'
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:10: /home/ishimachi/Repositories/cspydr/build/bin/cspc] Error 1
make[1]: Leaving directory '/home/ishimachi/Repositories/cspydr/src/compiler'
make: *** [Makefile:25: cspc] Error 2
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.