Návrh jazyka odvozeného z C a implementace nástrojů pro překlad
Loading...
Date
2025-06-10
Authors
Journal Title
Journal ISSN
Volume Title
Publisher
Abstract
Jazyk C zůstává klíčovým nástrojem, pokud se vyžaduje vysoký výkon a nízkoúrovňový přístup, avšak jeho efektivnímu využití v současných projektech brání omezení v systému sestavení, správě závislostí a nedostatečná podpora moderních programovacích technik. Tato diplomová práce představuje návrh a prototypovou implementaci procedurálního, staticky typovaného systémového programovacího jazyka, který vychází z filozofie C (jednoduchost, explicitnost, kontrola nad pamětí), ale snaží se adresovat jeho vybrané nedostatky.
Návrh jazyka klade důraz na čitelnost, přímou správu paměti a robustní vyhodnocování kódu v době překladu. Mezi klíčové vlastnosti patří vylepšený systém polí s typovanou délkou a hodnotovou sémantikou, zpracování UTF-8 řetězců jako polí, jmenné prostory, systém importu na úrovní AST nahrazující hlavičkové soubory a strukturovaná správa chyb založená na množinách chyb. Práce rozebírá motivaci a sémantiku těchto prvků a srovnává je s existujícími řešeními v jazycích C++, D, Zig a Odin.
Součástí práce je funkční prototyp překladače. Překladač využívá jazyk C jako mezijazyk a~pomocí vestavěné knihovny Tiny C Compiler generuje spustitelný kód. Výsledkem je ucelený návrh jazyka a nástroj demonstrující jeho proveditelnost a klíčové koncepty.
The C language remains a key tool where high performance and low-level access are required; however, its effective use in contemporary projects is hindered by limitations in build systems, dependency management, and insufficient support for modern programming techniques. This diploma thesis presents the design and prototype implementation of a procedural, statically-typed systems programming language that draws inspiration from the C language philosophy (simplicity, explicitness, memory control) but attempts to address its selected shortcomings. The language design emphasizes readability, direct memory management, and robust compile-time code evaluation. Key features include an improved, length-aware array system with value semantics, handling of UTF-8 strings as arrays, namespaces, an AST-level import system replacing header files, and structured error handling based on error sets. The thesis discusses the motivation and semantics of these elements and compares them with existing solutions in C++, D, Zig, and Odin. The work includes a functional prototype compiler. The compiler uses the C language as an intermediate language and generates executable code using the embedded Tiny C Compiler library (libtcc). The result is a cohesive language design and a tool demonstrating its feasibility and key concepts.
The C language remains a key tool where high performance and low-level access are required; however, its effective use in contemporary projects is hindered by limitations in build systems, dependency management, and insufficient support for modern programming techniques. This diploma thesis presents the design and prototype implementation of a procedural, statically-typed systems programming language that draws inspiration from the C language philosophy (simplicity, explicitness, memory control) but attempts to address its selected shortcomings. The language design emphasizes readability, direct memory management, and robust compile-time code evaluation. Key features include an improved, length-aware array system with value semantics, handling of UTF-8 strings as arrays, namespaces, an AST-level import system replacing header files, and structured error handling based on error sets. The thesis discusses the motivation and semantics of these elements and compares them with existing solutions in C++, D, Zig, and Odin. The work includes a functional prototype compiler. The compiler uses the C language as an intermediate language and generates executable code using the embedded Tiny C Compiler library (libtcc). The result is a cohesive language design and a tool demonstrating its feasibility and key concepts.
Description
Subject(s)
programovací jazyk, návrh jazyka, jazyk C, překladač, vyhodnocování v době překladu, správa chyb, jmenné prostory, Tiny C Compiler, C++