Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Language Reference

This section provides comprehensive reference material for the Y programming language, covering grammar, syntax rules, operator precedence, and complete type information.

Reference Sections

Grammar Reference

Complete syntax rules and grammar definitions for all Y language constructs. This includes the formal grammar used by the parser and examples of valid syntax patterns.

Operator Precedence

Detailed information about operator precedence and associativity, helping you understand how complex expressions are evaluated and how to use parentheses effectively.

Built-in Types

Comprehensive reference for all built-in types in Y, including their properties, methods, size requirements, and usage patterns.

Quick Reference

Basic Syntax

// Variable declaration
let variable_name: Type = value;
let mut mutable_var: Type = value;

// Function declaration
fn function_name(param: Type): ReturnType {
    expression_or_statements
}

// Struct declaration
struct StructName {
    field: Type;
}

// Instance methods
instance StructName {
    fn method_name(): ReturnType {
        implementation
    }
}

// Constants
const CONSTANT_NAME: Type = value;

// External declarations
declare external_function: (Type) -> Type;

Type System

  • Primitive Types: i64, u32, f64, bool, char, str
  • Array Types: &[ElementType]
  • Function Types: (ParamTypes) -> ReturnType
  • User Types: Custom structs

Control Flow

// Conditional expressions
if (condition) { value1 } else { value2 }

// Loops
while (condition) {
    statements
}

Operators

  • Arithmetic: +, -, *, /
  • Comparison: ==, !=, <, >, <=, >=
  • Assignment: =
  • Access: . (property access), [] (array indexing)

Language Characteristics

  • Expression-oriented: Most constructs evaluate to values
  • Static typing: All types known at compile time
  • Memory safe: No manual memory management required
  • Functional features: First-class functions, lambdas
  • Immutable by default: Variables are immutable unless marked mut

This reference section provides the authoritative information for understanding Y's syntax, semantics, and type system.