Skip to main content

TSol Compiler (tsolc)

Sol — Embrace modularity, ease of use, and speed.

TSol is a lightweight scripting language that compiles to C. It gives you the raw performance of C with a cleaner, more modern syntax — and a module system that actually makes sense.


Why Sol?

C is fast. C is everywhere. But C is also verbose, error-prone, and lacks a sane way to organize code across files.

Sol fixes that.

  • Modular by design — get("path/to/module.sol") imports just work, including nested subdirectories
  • Familiar syntax — C-style types and control flow, minus the footguns
  • Zero-cost abstraction — transpiles to clean C, then compiles with clang or gcc
  • No build system headaches — one command compiles and runs

Install

pip install tsolc

Requires Python 3.10+ and a C compiler (clang, gcc, or cc).


Quick Start

hello.sol

main() out int
    string msg -> "Hello, World!"
    out("%s\n", msg)
    return 0
tsolc hello.sol --run

Language Features

Types

Sol C
int, float, double, char, bool Same
string char*
int8–int64, uint8–uint64 int8_t–int64_t, uint8_t–uint64_t
int[], float[], ... Pointer + compound literal

Variables & Assignment

int count -> 42
float pi -> 3.14
string name -> "Sol"
int[] nums -> [1, 2, 3, 4, 5]

Assignment uses -> to avoid confusion with ==:

count -> count + 1

Functions

pub square(int n) out int
    return n * n
  • pub marks the function as public (importable from other files)
  • out type specifies the return type; omit for void

Imports

get("std/math.sol")
get("utils/helpers.sol")

Paths are relative to the importing file. Subdirectories work naturally:

get("std/io/file.sol")
get("../shared/types.sol")

Imports are deduplicated automatically — no header guards needed.

Control Flow

Indentation-based blocks — no braces, no end keyword:

if (x > 0)
    out("positive\n")
elseif (x < 0)
    out("negative\n")
else
    out("zero\n")

for (int i -> 0; i < 10; i++)
    out("%d\n", i)

while (running)
    running -> false

Ternary / Guard Operator

string sign -> x > 0 ? "positive" : "negative"
int abs -> x < 0 ? -x : x

Console I/O

// Output
out("Hello, %s!\n", name)

// Input
string name
in(name)

Raw C Injection

Drop straight into C when you need it:

C -> "#include <math.h>"
C -> "double result = sqrt(2.0);"

Structs

struct Point
    float x
    float y

Project Structure Example

myproject/
├── main.sol
├── std/
│   └── math.sol
└── utils/
    └── string.sol

main.sol

get("std/math.sol")

main() out int
    int result -> pow(2, 10)
    out("2^10 = %d\n", result)
    return 0

CLI Usage

tsolc file.sol           # Compile only
tsolc file.sol --run     # Compile and run
tsolc file.sol --keep-c  # Keep the generated .c file

How It Works

  1. Parse — Sol source is tokenized and parsed into an AST (indentation-aware)
  2. Resolve — get() imports are recursively resolved and merged
  3. Generate — Clean C11 code is emitted (structs first, then forward declarations, then definitions)
  4. Compile — clang/gcc compiles the C to a native executable
  5. Run — The binary is executed (with ./ prefix and proper permissions on Unix)

License

MIT — see LICENSE for details.

Metadata

Release files for tsolc 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tsolc 1.1.0
File Size Uploaded Provenance Actions
tsolc-1.1.0.tar.gz 14.4 kB Without provenance Details for tsolc-1.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for tsolc 1.1.0
File Interpreter ABI Platform Actions
tsolc-1.1.0-py3-none-any.whl Python 3 none any Details for tsolc-1.1.0-py3-none-any.whl

Total release size: 26.9 kB

Release files / tsolc-1.1.0.tar.gz

Download URL tsolc-1.1.0.tar.gz
Size 14.4 kB
Tags Source
SHA-256 checksum
How to use checksums
14222a3729dbae278845f4c86057bf4018c65e8110d566f6f5fb5085032382b4
BLAKE2b-256 checksum
How to use checksums
f5f2b78bd3395451f35c9ad37b3a3b2a6fe622e35436bb96802f10421a3e56cb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.6

Release files / tsolc-1.1.0-py3-none-any.whl

Download URL tsolc-1.1.0-py3-none-any.whl
Size 12.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a3f4be8fd0f9e0f71a0343c55646fe7e6152b716bcbb31cc2d0efd6d12a2b414
BLAKE2b-256 checksum
How to use checksums
9a8bd1e1cab65536d11a0793abb767d069c146d7f6dcc8440720a7a29efadfca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.6

Security for tsolc 1.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page