Language Policy

Lexical Structure & Layout

Canonical grammar, semantics, constraints, and deferred boundaries for Lexical Structure & Layout.

The lexer treats Unicode identifiers as ordinary source, keeps keyword spelling in English, and preserves exact scalar sequences. Layout then decides whether a newline separates items or continues the current expression.

Policy

An identifier starts with a Unicode letter, underscore, or emoji and may continue with those characters or Unicode numbers. The single _ is reserved for wildcard and pipeline-placeholder roles. Reserved keywords cannot be rebound; loop, set, and map are contextual only at their exact grammar heads. Tokenization uses longest match, distinguishing ..., .., ..<, ?., and postfix ?.

Specified behavior

Strings are immutable Unicode scalar sequences with no implicit normalization. Double-quoted strings support the fixed escape set and {expression} interpolation. Triple-quoted strings use the closing delimiter indentation as an exact spaces/tabs prefix, reject inconsistent nonblank lines, and omit an immediate first newline. In separator contexts a newline ends a complete item unless delimiter mode or a leading/trailing continuation token keeps it open.

Constraints and loud decline

Integer and float literals are decimal; alternate bases and underscore separators are not canonical. Single-quoted strings and character literals are forbidden, block comments do not nest, and _ cannot be referenced as a value. A string cannot use s[i], s.length, or slice syntax. Canonical examples omit semicolons even though separator mode accepts them.

Deferred boundary

Grapheme-cluster operations, direct string slicing, implicit Unicode normalization, alternate numeric literal syntax, nested block comments, and new template tags are deferred. Scalar access is explicit through s.scalars() rather than hidden behind indexing.

Worked example

TOPAZ
function 인사하기(이름: string) -> string {
    let message = "안녕하세요, {이름}님!"
    return message
}

let 사용자 = "토파즈"
print(인사하기(사용자))