Twinkies Language Documentation
Welcome to the comprehensive documentation for the Twinkies programming language! This documentation covers all aspects of the language, from basic syntax to advanced features.
Table of Contents
- Installation - How to install Twinkies from source
- Language Overview - Introduction to Twinkies
- Syntax and Basics - Basic syntax, keywords, and language structure
- Type System - All data types, type conversions, and type checking
- Functions - Function declarations, parameters, overloading, and recursion
- Control Flow - If/else, while loops, break, continue, and return
- Arrays and Strings - Array operations, string manipulation, and bounds checking
- Modules - Module system, header files, and includes
- Foreign Function Interface - Calling external libraries and functions
- Inline Assembly - Embedding assembly code in Twinkies programs
- Examples Guide - Comprehensive guide to all example programs
- Quick Reference - Quick lookup for syntax and features
What is Twinkies?
Twinkies is a statically-typed, C-like programming language that compiles to C or assembly code. It features:
- Static type checking with helpful error messages
- C-like syntax that's familiar and easy to learn
- Automatic array bounds checking (compile-time and runtime)
- Foreign Function Interface (FFI) for calling external libraries
- Inline assembly support with GCC-style syntax
- Module system with header files for code organization
- Function overloading based on parameter types
- Multiple output formats - transpile to C or compile to assembly
Getting Started
The simplest Twinkies program:
func main() -> int {
print("Hello, World!");
return 0;
}
Language Keywords
Twinkies has 25 keywords:
Control Flow & Declarations:
func,let,if,else,while,break,continue,return,print,extern,from
Type Keywords:
int,int8,int16,int32,int64,bool,float,double,string
Literal Keywords:
true,false,null
Other:
asm,volatile
File Extensions
.tl- Twinkies source files.tlh- Twinkies header files (for modules)
Compiler Usage
# Compile to C (default)
./compiler input.tl -o output.c
# Compile to assembly
./compiler input.tl -o output.s --asm
# Enable module system
./compiler main.tl -o main.c math.tl string.tl --modules
# Debug options
./compiler input.tl -o output.c --debug --verbose --tokens --ast --ir
Next Steps
Start with Language Overview for a gentle introduction, or jump to Syntax and Basics to dive right in!
