sic

The sic programming language
Log | Files | Refs

commit 5d44d0efb28e5000f65fb31183b7bd4cd68cc872
Author: keyle <keyle@capsule.org>
Date:   Sat,  9 May 2026 13:43:36 +1000

init

Diffstat:
A.gitignore | 2++
Alanguage.sic | 62++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Amakefile | 2++
Asrc/main.c | 15+++++++++++++++
Asrc/utils.c | 21+++++++++++++++++++++
Asrc/utils.h | 3+++
6 files changed, 105 insertions(+), 0 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -0,0 +1,2 @@ +*.DS_Store +sicc diff --git a/language.sic b/language.sic @@ -0,0 +1,62 @@ +int ~age = 25 +dec height = 87.5 +str name = "George" + +int main { + str name = arg[0] + print(name) + return 0 +} + +def Human { + str name + dec height + int age +} + +opt<Human> test = none +opt<Human> jockey = get_jockey() + +match jockey { + some(x) => print(x.name); + none => print("no jockey"); +} + +for int i in [0:100] { + +} + +some<T> my_func() { + some +} + +str[] names = ["James", "Jake", "Janice"] + +for (str n in names) { + print(n) +} + +for names as n { + print(n) +} + +bool adult = age > 18 + +return "Henry" if adult is Human else "Dog" if adult is Dog else "Animal" + +if adult is Human { + return "Henry" +} else { + return "Dog" +} + +return adult is Human ? "Henry" : "Dog" + +float x = 12.5 +int y = 12 + +if cast(int, x) == y { + print("yay") +} + + diff --git a/makefile b/makefile @@ -0,0 +1,2 @@ +default: + cc -o sicc **/*.c diff --git a/src/main.c b/src/main.c @@ -0,0 +1,15 @@ +#include <stdio.h> +#include "utils.h" + +int main(int argc, char** args) { + char* filename = args[1]; + printf("hello, meh: %s\n", filename); + + char* contents = read_file(filename); + if (contents == NULL) return 1; + + printf("%s\n", contents); + // TODO load file + // TODO parse the content through a scanner + return 0; +} diff --git a/src/utils.c b/src/utils.c @@ -0,0 +1,21 @@ +#include <stdio.h> +#include <stdlib.h> + +char* read_file(const char* filename) { + FILE* fp = fopen(filename, "r"); + if (fp == NULL) { + // Handle file not found + return NULL; + } + + fseek(fp, 0, SEEK_END); + long fsize = ftell(fp); + fseek(fp, 0, SEEK_SET); + + char* source = malloc(fsize + 1); + fread(source, fsize, 1, fp); + fclose(fp); + + source[fsize] = 0; + return source; +} diff --git a/src/utils.h b/src/utils.h @@ -0,0 +1,3 @@ +#pragma once + +char* read_file(const char* filename);