Skip to main content

How TPScript works

TPScript is a small, self-contained compiler front-end that rewrites your gameplay source into Unreal C++.

The pipeline​

your_code.tps
│
▼
┌────────────────┐
│ Tokenizer │ LEXER - splits the text into tokens
└────────────────┘
│
▼
┌────────────────┐
│ Parser │ PARSER - builds an AST (classes, props, funcs…)
└────────────────┘
│
▼
┌────────────────┐
│ Emitter │ EMITTER - writes UCLASS/UPROPERTY/UFUNCTION C++
└────────────────┘
│
▼
┌────────────────┐
│ Regenerator │ Manages files, modules, manifests, stale-file cleanup
└────────────────┘
│
▼
AHelloWorld.h / AHelloWorld.cpp
  1. Lexer - the file is tokenized. TPScript understands identifiers, keywords, string literals (with escapes), character literals, numbers, and multi-character symbols. It deliberately treats << and >> as two tokens so deeply nested templates like TArray<TSubclassOf<AActor>> balance correctly.

  2. Parser - builds an abstract syntax tree. It recognizes top-level constructs (uclass, class ... extends, ustruct, uenum, interface, include, declare, log) and every member kind (prop, field, func, method, component, delegate, high-level edit/internal/when_begin, …).

  3. Emitter - walks the tree and emits idiomatic Unreal C++: #pragma once headers with #include "<Name>.generated.h", UCLASS()/UPROPERTY()/UFUNCTION() macros, constructors with CreateDefaultSubobject, override method bodies, delegate macros, and more.

  4. Regenerator - the editor-facing layer. It discovers modules via a .tpscript-manifest.json, writes generated files into the right Public//Private/ categories, creates module boilerplate when missing, and cleans up stale files on Regenerate All.

The "regenerate" model​

TPScript is not a hot-reload scripting layer. It generates real C++ that you then compile (with the built-in Compile button, Live Coding, or your IDE). This is what gives you full C++ performance and full Blueprint integration.

The workflow is intentionally mechanical:

Edit .tps → Regen This File → Compile → play.

You don't hand-edit generated C++. If you want to change behaviour, change the .tps and regenerate. That keeps mechanics consistent and reviewable.

Status markers​

When you regenerate, each file gets a status:

MarkerMeaning
[NEW]generated for the first time
[UPD]previously generated, updated
[==]unchanged, no diff
[DEL]old generated file removed (stale)
[+]auxiliary / added

Pure C++, no runtime​

The transpiler itself is a single pure-C++17 library (lexer, parser, model, emitter) with no Unreal dependencies. It runs inside the plugin's Runtime module. The only dependency on the engine is the regenerator wrapper that uses Projects, Json, JsonUtilities, Slate, and SlateCore for module discovery and the editor UI.

See Generated Code for what the output looks like in detail.