Semantic-Programming-Language

Semantic Programming Language Logo

Semantic Programming Language

A universal, matrix-driven programming language and compiler architecture based on canonical Semantic/UAST representations.

Unfortuanetly self hosting is still not reached, but it is close. The way to go to compile a project is the transpilation of .se into go or java and compiling it with their compiler.

Download

https://github.com/tarekwasfy01/Semantic-Programming-Language/releases/download/v1.0.0/Semantic.Programming.Language.zip

Pre Transpiled Modules

https://github.com/SemanticProgrammingLanguage?tab=repositories

Overview

Semantic Programming Language represents programs independently of their original source language.

Source code is lowered into a canonical SemanticProgram and Universal Abstract Syntax Tree (UAST). The same semantic representation can then be validated, transformed, executed, transpiled, or compiled into a native executable.

Source code
    ↓
Frontend
    ↓
SemanticProgram / UAST
    ↓
Semantic transformations and contracts
    ↓
Native backend
    ↓
Executable

The reference implementation and bootstrap compiler are provided by the Go package Code-Transpiler.

Go module:  github.com/tarekwasfy01/Code-Transpiler
Go package: codetranspiler
GUI:        Semantic Programming Language.exe
CLI:        sp / CodeTranspiler

Compiler source bundles

The Semantic representation of the compiler is divided into three source bundles:

File Purpose
src/semantic_frontend.se Source parsing, language detection and SemanticProgram construction
src/semantic_uast.se Canonical UAST, types, relations, effects and semantic contracts
src/semantic_backend.se Native lowering, runtime integration and executable generation

Together, they describe the compiler pipeline:

semantic_frontend.se
        ↓
semantic_uast.se
        ↓
semantic_backend.se
        ↓
Native executable

The files are stored through Git LFS because they contain the consolidated semantic representation of the compiler.

Native ecxecutable https://github.com/tarekwasfy01/Semantic-Programming-Language/releases/download/v1.0.0/Semantic.Programming.Language.zip

Self-hosting

Semantic uses a bootstrapped self-hosting architecture.

The Go implementation provides the initial compiler. Its compiler components can be translated into Semantic .se modules and processed by the same universal Semantic/UAST pipeline:

Go bootstrap compiler
        ↓
Semantic compiler sources
        ↓
Semantic frontend + UAST + backend
        ↓
Native compilation
        ↓
Next compiler generation

The canonical self-hosting condition is:

CompileSemantic(CompilerSemantic) → CompilerNative

The checked-in .se bundles provide the Semantic compiler representation. The current Windows GUI distribution is bootstrapped by the Go implementation and embeds verified copies of all three bundles.

GUI

Start the application without arguments:

& ".\Semantic Programming Language.exe"

The GUI provides access to:

CLI

The commands sp and CodeTranspiler are equivalent:

sp <command> [options]
CodeTranspiler <command> [options]

Compile Semantic source

sp compile input.se -o input.exe
sp compile input.sp -o input.exe
sp compile input.json -o input.exe

The longer executable name can be used identically:

CodeTranspiler compile input.se -o input.exe

Compile source code directly

sp compile -source go -target native-x86_64-windows input.go -o program.exe

Export Semantic source

sp semantic-export -source go input.go -format se -o program.se

Validate and inspect Semantic documents

sp semantic-validate program.se
sp semantic-info program.se
sp semantic-format program.se --readable -o readable.se
sp semantic-format program.se --compact -o compact.se

Transpile through Semantic/UAST

sp transpile -from python -to go input.py -o output.go
sp transpile -from c -to rust input.c -o output.rs
sp semantic-transpile -target cpp program.se -o output.cpp

Semantic Moduls

Experimental support for Semantic Modules. The Goal is to make packages from all implemented languages accesible by transpiling and decompiling packages from other languages.

CodeTranspiler.exe module import <source|module.se|module.spz>
CodeTranspiler.exe module import --language go <source.go>
CodeTranspiler.exe module list
CodeTranspiler.exe module info <cache-key>
CodeTranspiler.exe module verify <cache-key>
CodeTranspiler.exe module remove <cache-key>
CodeTranspiler.exe semantic module import <target>
CodeTranspiler.exe semantic module import --language go <target>
Manage Semantic Modules in %LOCALAPPDATA%\\Semantic\\Modules.

Execute a program

sp run -source python -target embedded input.py
sp run -from c -to go input.c

Verify the embedded compiler bundles

sp bundle-info
sp bundle-verify
sp bundle-extract extracted-bundles

Display all commands

sp help
CodeTranspiler help

Go package

Install the reference compiler package:

go get github.com/tarekwasfy01/Code-Transpiler

Import it in Go:

import codetranspiler "github.com/tarekwasfy01/Code-Transpiler"

The Go package provides the bootstrap frontend, canonical SemanticProgram/UAST model, transformation pipeline, target emitters, native backend, GUI and CLI.

Semantic representation

A Semantic program is modeled as a typed and attributed graph:

P = (V, E, T, A, C)

Where:

The canonical representation preserves information such as:

SFPC

SFPC means Semantic Fixed Point Compression.

SFPC is the transport and validation model for canonical SemanticProgram/UAST documents. It removes only information that can be reconstructed deterministically without changing program meaning.

For a semantic document D and its canonical form C(D):

Decode(Encode(C(D))) = C(D)

The encoded representation also reaches a byte-level fixed point:

Encode(Decode(Encode(C(D)))) = Encode(C(D))

This means that decoding and encoding an already canonical Semantic document produces the same canonical bytes.

For a program graph G:

F(G) = G_explicit ∪ derive(F(G))
closure(B) = G

where B is the smallest explicit basis. Grammar compression encodes a repeated production A → X₁…Xₙ once and uses references, reducing repeated cost from k·Σ|Xᵢ| to Σ|Xᵢ| + k·|ref(A)|. .spz compresses that canonical stream; decoding satisfies Decode(Encode(C(D))) ≡ C(D).

SFGC

SFGC means Semantic Fixed-Point Grammar Compression.

SFGC represents a canonical Semantic program through explicit facts, stable references, schema defaults and deterministic derivations.

Let:

The central contract is:

X(R(P)) ≡ N(P)
R(X(SE)) = SE

A compression rewrite is used only when it reduces the exact UTF-8 representation:

gain(rule, S) = |UTF8(S)| - |UTF8(rule(S))|

Only rewrites with gain > 0 are applied.

SFPC and SFGC do not introduce another intermediate representation. The canonical SemanticProgram/UAST remains the semantic source of truth.

Supported ecosystem

The Code-Transpiler ecosystem registers frontends and target emitters for:

Available routes and individual language features are capability-gated. Route availability does not imply complete equivalence for every language-specific feature.

File formats

Extension Description
.se Canonical readable Semantic representation
.sp Compatibility alias for Semantic source
.spz Compressed Semantic transport format
.semantic.json Semantic interchange and debugging format
.exe Native Windows executable output
.obj Native Windows object output
.bin Raw machine-code output
.asm Assembly output

Design principles

The Go bootstrap compiler, GUI, CLI and importable package are maintained in:

github.com/tarekwasfy01/Code-Transpiler

License

Semantic Programming Language is licensed under the terms provided in LICENSE.

Copyright (c) 2026 Tarek Wasfy