Rûn Lexical Structure
How a Rûn file is cut into lines, words, numbers and text. Event scripts and programs follow different rules, so each rule says which it belongs to.
Files
A script is a UTF-8 text file ending in .run. Event scripts live in assets/events, programs in assets/scripts. The file's name, without .run, is the script's name: assets/events/barn_door.run is the event barn_door. Names are matched without regard to case.
Lines and statements
- Event scripts
- One verb per line. A line is never continued onto the next. Indentation with spaces puts a line inside the
if,else,whileorrepeatabove it; two spaces is usual. A tab indents too, to the next multiple of four columns. - Programs
- A statement ends at the end of its line or at a
;. Semicolons are allowed and never needed. Inside( )and[ ]a line break is ignored, so a long call or list may be spread over several lines. Indentation means nothing; braces{ }group statements.
number a = 1; number b = 2; print(a + b)
print(
"arguments",
"may",
"span lines"
)3
arguments may span linesComments
- Event scripts
- A line whose first character is
#is a comment. A#after a verb is not: it becomes part of what the verb says. - Programs
//and#run to the end of the line;/* ... */may cover several lines.
# a hash comment
// a slash comment
/* a comment
over two lines */
print("only this line runs") // a comment after a statementonly this line runsNames
A name starts with a letter or _ and goes on with letters, digits and _. Every name in Rûn is matched without regard to case: variables, functions, sections, verbs, keywords, types and engine objects. Count, count and COUNT are one variable.
Number Score = 3
PRINT(score)
IF (SCORE == 3) Print("case does not matter")3
case does not matterIn an event script a variable name holds at most 23 characters. In a program a name holds at most 31 characters as a variable and 63 as a function.
Keywords
Programs reserve if, else, for, while, on, return, New, using, true and false. The words before and after start a rule block only at the top of a file and only in front of a name and (; anywhere else they are ordinary names. Type words (number, text, toggle, and their other spellings int, float, string, bool) start a declaration when a name and = follow them.
Event scripts have no reserved words: the first word of a line is its verb.
Numbers
Numbers are written in decimal: 3, 0.25, .5, 1e3 (1000). A minus sign in front is an operator, so -4 is the number 4 made negative. Every number is a 32-bit floating point number; whole numbers up to 16777216 are exact. See Rûn Values and Types.
print(1e3, 2.5e-3, .5, 16777216, 16777217)1000 0.0025 0.5 16777216 16777216Text
- Programs
- Text is written between double quotes:
"Old Sign". It ends at the next"and must close on the same line. There are no escape sequences: a backslash is kept as written, and a double quote cannot be put inside text. A piece of text holds at most 159 bytes; a letter outside English (such asû) takes two or three of them. - Event scripts
- Text needs no quotes: the rest of the line after the verb's other words is the text.
say Cold night, traveler.says exactly that. Words in{curly braces}are filled in with live values (see Line Scripts).
print("Rûn keeps a \ as written")
print("a" + "b" + 3)Rûn keeps a \ as written
ab3print("she said "hello"")this call never closesThe text ends at the second ", so the parser meets the word hello where it expected ) or ,.
Operators and punctuation
Programs use these symbols: + - * / %, < > <= >= == !=, && || !, = (to set, and to compare inside a condition), ( ) { } [ ], . and ,. A single & or | means && or ||. Event script conditions use + - * /, = == != < > <= >= and the words and, or and not. See Rûn Expressions and Operators.