KScript is a custom-built, statically typed programming language with a C-like syntax. Designed and implemented from scratch in C++, KScript features support for:
- Variable declarations and types
- Arithmetic and logical operations
- Conditional statements and loops
- User-defined functions
- Custom bytecode execution via a lightweight interpreter
KScript was engineered with compiler principles in mind, following a structured architecture from lexical analysis to bytecode execution.
- C-like Syntax β Familiar and concise.
- Static Typing β Compile-time type checking.
- Control Flow β
if,while,for, and logical branching. - Functions β Custom functions with scoped variables.
- Modular Architecture β Clean separation of compiler components.
- Lexer β Tokenizes the source input into lexical units.
- Parser β Converts tokens into an Abstract Syntax Tree (AST).
- BNF Grammar β Formal grammar specification of the language.
- Interpreter β Custom stack-based bytecode interpreter for runtime execution.
KScript/
βββ include/ # Header files for each compiler component
β βββ AST.h
β βββ parser.h
β βββ lexer.h
β βββ visitor.h
βββ src/ # Implementation files
β βββ AST.cpp
β βββ parser.cpp
β βββ lexer.cpp
β βββ main.cpp
βββ examples/ # Sample .ks scripts
β βββ factorial.ks
βββ Makefile # Build script
βββ README.md # This file