Skip to main content

Specifications

This section contains the formal specifications and technical documentation for the Ora smart contract language.

Language Specifications

Grammar

Complete BNF and EBNF grammar specifications for the Ora language, including:

  • Formal syntax rules
  • Operator precedence
  • Language constructs
  • Reserved keywords
  • Memory region annotations

MLIR Integration

Comprehensive documentation of Ora's MLIR lowering system, covering:

  • LLVM MLIR integration
  • Type mapping strategies
  • Memory region semantics
  • Expression and statement lowering
  • Pass management and optimization

Formal Verification

Z3 SMT solver integration for mathematical proof of contract properties:

  • Preconditions and postconditions (requires, ensures)
  • Contract and loop invariants
  • Quantified expressions (forall, exists)
  • Ghost code for specification
  • Verification condition generation

API Documentation

Complete API reference for the Ora compiler:

  • CLI commands and flags
  • Library interfaces
  • Compilation pipeline
  • Error handling
  • Performance benchmarks

State Analysis

Automatic storage access tracking and optimization:

  • Function property detection (stateless, readonly, state-modifying)
  • Dead store detection (contract-level analysis)
  • Missing validation warnings
  • Constructor-specific checks
  • Gas optimization insights

Implementation Status

Each specification includes implementation status indicators:

  • Complete: Feature is fully implemented and tested (79% success rate - 76/96 examples)
  • 🚧 In Progress: Partially implemented, actively being developed
  • 📋 Planned: Designed but not yet started

Current Status Summary

ComponentStatusNotes
Lexer✅ CompleteAll tokens, trivia support
Parser✅ Complete79% success rate (76/96 examples)
Type System✅ CompleteFull type checking and validation
Semantics✅ CompleteRegion and error validation
MLIR✅ Complete81 operations, lowering and optimization
State Analysis✅ CompleteAutomatic tracking & warnings
Structs✅ CompleteDeclaration, instantiation, field operations
Enums✅ CompleteDeclaration with explicit values
Control Flow✅ Completeif/else, switch statements
Arithmetic✅ CompleteAll operations (add, sub, mul, div, rem, power)
Memory Ops✅ Completemload, mstore, mload8, mstore8
Transient Storage✅ Completetload, tstore operations
Maps✅ CompleteMap get/store operations
sensei-ir Backend🚧 In ProgressLowering to sensei-ir (SIR) in development
For Loops🚧 In ProgressCapture syntax in development
Error Handling🚧 In ProgressTry-catch improvements needed
Type Inference🚧 In ProgressCurrently requires explicit types
Standard Lib🚧 In ProgressBasic utilities
Z3 Verification🚧 In ProgressGrammar & AST complete, VC generation in progress

Contributing

These specifications are living documents that evolve with the language. Contributions are welcome:

  1. Grammar improvements: Help refine language syntax
  2. HIR enhancements: Extend the intermediate representation
  3. Verification advances: Improve formal verification capabilities
  4. API extensions: Add new compiler features

Quick Navigation

  • New to Ora? Start with the Grammar specification
  • Writing contracts? Check out State Analysis for automatic optimization
  • Formal verification? See the Formal Verification guide for Z3 integration
  • Compiler development? Explore MLIR Integration and API docs
  • Language implementation? All specifications work together

These specifications provide the foundation for understanding and extending the Ora language.