Skip to content

Language Syntax

Frank edited this page Jan 25, 2026 · 12 revisions

Language Syntax

CupidScript uses a C-like surface syntax.

Comments

Supported comment forms:

// line comment

/* block comment */

Comments are skipped by the lexer alongside whitespace.

Tokens

Identifiers

  • Start: letter or _
  • Continue: letters, digits, _

Integers

Decimal-only integers:

0
12345

Strings

Double-quoted strings:

"hello"
"with \n escapes"
"quote: \""
"backslash: \\"

Escape handling (in runtime unescape):

  • \n, \t, \r, \", \\
  • Any unknown escape \x becomes literal x

Operators & Punctuation

Punctuation

( ) [ ] { } , ; .

Operators

Assignment:

  • =

Arithmetic:

  • + - * / %

Unary:

  • ! -

Comparison:

  • == != < <= > >=

Boolean:

  • && ||

Precedence (high to low)

  1. Primary: literals, identifiers, parenthesized (expr)
  2. Postfix: calls f(...), indexing a[b]
  3. Unary: !expr, -expr
  4. Multiplicative: * / %
  5. Additive: + -
  6. Comparison: < <= > >=
  7. Equality: == !=
  8. AND: &&
  9. OR: ||

Clone this wiki locally