Skip to content
La3 Docs
Browse docs

Syntax and Lexing

Tokens, comments, semicolons, identifiers, literals, and precedence rules.

Comments and newlines

La3 keeps comments simple and lets newlines end statements when the expression is already complete.

This keeps short examples readable while still allowing explicit separators when two expressions share a line.

  • // is a line comment.
  • /* ... */ covers longer explanatory blocks.
  • /// documentation comments are meant for Markdown prose.
// Single-line comment

let x = 1
let y = 2

let a = 1; let b = 2

Identifiers and keywords

The lexer distinguishes names, types, modules, and constants with casing conventions instead of extra syntax.

  • snake_case for variables, functions, and modules.
  • PascalCase for types, structs, enums, and interfaces.
  • SCREAMING_SNAKE_CASE for constants.
  • Reserved keywords include control flow, declarations, concurrency, and ownership markers.

Literals

Numeric bases, suffixes, strings, chars, booleans, and nil all have explicit forms.

  • Unsuffixed integers default to i32.
  • Unsuffixed floats default to f64.
  • nil is the single absence value and has its own type.
  • char holds exactly one Unicode scalar value.
let port = 443
let ratio = 3.14
let mask = 0xff
let empty = nil

Operators

Arithmetic, comparison, logical, optional, bitwise, and assignment operators each keep one meaning.

  • / truncates toward zero for integers.
  • % keeps the sign of the left operand.
  • ** yields f64.
  • ?? and ?. act on bare optionals.
  • as is the explicit numeric cast operator.