Skip to content

Welcome to HypnoScript

HypnoScript is a modern, esoteric programming language that combines hypnotic metaphors with a pragmatic Rust toolchain. The syntax resembles TypeScript but uses keywords like Focus, induce, observe or Relax to directly express hypnotic concepts.

What is HypnoScript?

The current runtime consists entirely of Rust crates and provides:

  • 🦀 Native Toolchain – Lexer, parser, static type checker, interpreter and WASM code generator are fully implemented in Rust.
  • 🎯 Hypnotic Syntax – Language constructs like deepFocus, snap, anchor or oscillate translate hypnotic imagery into code.
  • 🔒 Static Type System – The type checker knows numbers, strings, booleans, arrays, functions and sessions including visibility modifiers.
  • 📦 Standard Library – Math, string, array, file, statistics, system, time and validation builtins are available out of the box.
  • 🛠️ CLI for the Entire Workflow – A single binary (hypnoscript) offers run, lex, parse, check, compile-wasm, builtins and version.

The language is cross-platform (Windows/macOS/Linux) and generates native binaries as well as optional WebAssembly output.

Syntax Fundamentals

ConceptDescription
Focus { ... } RelaxEncloses every program (entry and exit point).
entrance { ... }Optional startup block for initialization or greeting.
finale { ... }Optional cleanup block that is guaranteed to run at the end.
induce / freezeDeclares variables (induce/implant) or constants (freeze).
observe / whisperOutput with or without newline. command highlights text emphatically.
if, while, loopControl structures with hypnotic operator synonyms (youAreFeelingVerySleepy, underMyControl, …).
suggestionFunction definition (global or within sessions).
sessionObject-oriented structures with fields (expose/conceal), constructors and static members.
anchor / oscillateStores values between calls or toggles booleans.
hyp
Focus {
    entrance {
        observe "Welcome to the trance";
    }

    induce counter: number = 0;
    while (counter goingDeeper 3) {
        observe "Depth: " + counter;
        counter = counter + 1;
    }

    suggestion hypnoticSum(values: number[]): number {
        awaken ArraySum(values);
    }

    observe "Sum: " + ToString(hypnoticSum([2, 4, 6]));
} Relax

Standard Library Overview

The builtins are organized into categories. A detailed reference can be found under Standard Library.

  • MathematicsSin, Cos, Tan, Sqrt, Pow, Factorial, Clamp, Gcd, Lcm, IsPrime, Fibonacci, …
  • StringsLength, ToUpper, ToLower, Trim, Reverse, Replace, Split, Substring, PadLeft, IsWhitespace, …
  • ArraysArrayLength, ArrayIsEmpty, ArraySum, ArrayAverage, ArraySlice, ArrayDistinct, …
  • FilesReadFile, WriteFile, AppendFile, ListDirectory, GetFileExtension, …
  • SystemGetOperatingSystem, GetUsername, GetArgs, Exit, GetCurrentDirectory, …
  • Time & DateCurrentTimestamp, CurrentDateTime, IsLeapYear, DayOfWeek, …
  • StatisticsMean, Median, Mode, StandardDeviation, Correlation, LinearRegression, …
  • ValidationIsValidEmail, MatchesPattern, IsInRange, IsNumeric, IsLowercase, …
  • Hypnotic Core FunctionsObserve, Whisper, Command, Drift, DeepTrance, HypnoticCountdown, TranceInduction, HypnoticVisualization.

Development Workflow

bash
# Read source, lex, parse, check and run
hypnoscript lex   examples/test.hyp
hypnoscript parse examples/test.hyp
hypnoscript check examples/test.hyp
hypnoscript run   examples/test.hyp

# Generate to WebAssembly (wat)
hypnoscript compile-wasm examples/test.hyp --output output.wat

# List all builtins
hypnoscript builtins

The interpreter executes programs deterministically. Type checking errors are reported but do not block execution – ideal for exploratory work.

Next Steps

Community & License

Released under the MIT License.