Skip to content

Syntax & structure

Program structure

A Munos script executes from the top of the file downward. There is no main function and no explicit entry point.

munos
var score = 0
print(score)

Top-level statements run in source order. Top-level var declarations are script-wide globals. function, event, struct, and client / server declarations are not executed in place — they're registered (see Functions, Events, and Client & server).

Statements

A statement is one of:

  • a var or const declaration
  • an assignment (x = …)
  • a function call (foo(…))
  • an if / while / for
  • break, continue, or return
  • a top-level function, event, struct, client, or server declaration

A bare expression is not a statement. Lines like 6 + 6, x == y, or !flag don't form a valid program. Only function calls — which can have side effects — are an expression form that can stand alone.

Line termination

Statements are terminated by newlines. There are no required semicolons — one statement per line.

munos
var x = 1
var y = 2
foo()

A semicolon ; is an optional, equivalent separator that lets several statements share a line. Redundant ones (leading, trailing, doubled) are harmless.

munos
var x = 1; var y = 2; foo()

The one place ; is mandatory and means something different is the for header, where it separates the init/condition/step clauses.

Multi-line continuation

Because a bare expression can't be a statement, a line that isn't yet a complete statement automatically continues onto the next. No backslash or wrapping parentheses needed.

munos
total = a + b +
        c + d          // trailing operator → continues

var total =
        a + b          // newline after '=' → continues

The general rule: a line that parses as a complete statement ends at its newline; one that doesn't is glued to the next line until the parse completes.

Brace placement

A block's opening { may sit on the same line or the next — both same-line and Allman styles work, since a { in block position is unambiguous.

munos
if x > 10 { foo() }

if x > 10
{
    foo()
}

Comments

munos
// line comment, runs to end of line
var x = 5    // inline

/* block comment
   spanning lines */

Block comments do not nest.

Part of the MultiNostalgia project.