Skip to content

Lexical Structure

Nilakan source is organized as lines of Python-like statements. Indentation is significant inside blocks.

Category Keywords
Definitions and blocks def, init, pragma, while, if, elif, else, return, try, catch
Imports import, from, as
Booleans True, False
Operators and, or, not, in

print is a reserved built-in procedure name, not a keyword. The pragma family is acc_prime; its mode names are sequential, convergent, monotone_convergent, idempotent, confluent, and associative_commutative. Syntax highlighting recognizes each name. Currently only sequential has executable semantics; the other modes report NLK3013.

Line comments start with # and continue to the end of the line. The first recognized comment delimiter wins. Once a line comment starts, later ### text on that line remains part of the line comment and cannot open a block comment.

# This is a comment.
x = 1 # This is also a comment.
Run in playground

Block comments are delimited with ###.

###
This block is ignored by the lexer.
###
x = 1
Run in playground

Block comments can appear inline. An unterminated block comment is a syntax error. Comment delimiters inside string literals are preserved as string content.

Strings may use single quotes, double quotes, triple single quotes, or triple double quotes. Nilakan decodes exactly \n, \r, \t, \\, \', and \". Any other backslash escape is SyntaxError/NLK1005; Nilakan never silently drops an unknown backslash. Triple-quoted strings can span lines; a backslash followed by a physical newline removes that newline. Escaped quote characters inside a triple-quoted literal do not start its closing delimiter.

name = "Nilakan"
message = 'hello'
long = """multiple
lines"""
escaped = "a\nb"
Run in playground

Nilakan does not currently support hexadecimal, Unicode-name, octal, raw-string, or bytes-literal escapes. Write the Unicode character directly when practical.

Number literals are decimal integers or decimal fractions. Exponents are not implemented.

count = 3
ratio = 0.5
Run in playground

Identifiers match this shape:

[A-Za-z_][A-Za-z0-9_]*

A primed identifier adds one or more trailing apostrophes and names a future state layer in a commit loop.

Fragment — primed assignments require matching loop depth
value = 1
value' = value + 1
value'' = value' + 1

Spaces define indentation. Tabs are rejected.

Semicolons separate statements on the same line.

x = 1; y = 2; print(x + y)
Run in playground

Newlines are ignored inside (), [], and {}. A newline before . also continues a method chain. Line and block comments may appear between chained method calls.

xs = [
1,
2,
3,
]
ys = xs
.append(4)
.reverse()
Run in playground

Tabs in indentation are syntax errors. Indentation must return to a previous indentation level when a block closes.

Step slices such as xs[0:4:2] are not implemented. A standalone {} is a dict, not a set; use set() for an empty set.

items = ["a", "b"]
updated = items
.append("c")
.reverse()
print(updated)
Run in playground