Conformance Levels

TON defines conformance levels to ensure consistent implementation across different parsers.

Level 1: Basic Parsing

  • Parse basic object structure
  • Support string, number, boolean literals
  • Handle single-line comments
  • Basic error reporting

Level 2: Complete Literals

  • All Level 1 features
  • null and undefined values
  • Hexadecimal and binary numbers
  • Scientific notation

Level 3: Advanced Types

  • All Level 2 features
  • GUID support (both formats)
  • Date/time parsing (ISO 8601)
  • Multi-line comments

Level 4: Collections

  • All Level 3 features
  • Array parsing and nesting
  • Mixed-type arrays
  • Empty arrays

Level 5: Multi-line Strings

  • All Level 4 features
  • Triple-quoted strings
  • Intelligent indentation processing
  • Both single and double triple quotes

Level 6: Type System

  • All Level 5 features
  • Class types for objects
  • Type hints ($, %, &, ^)
  • Property name prefixes (@)

Level 7: Enums

  • All Level 6 features
  • Enum parsing (|value|)
  • EnumSet support
  • Index and name references

Level 8: Schema Support

  • All Level 7 features
  • Parse schema definitions
  • Basic type validation
  • Required field checking

Level 9: Path-Based Validation

  • All Level 8 features
  • Deep path traversal (/path/to/property)
  • Nested property validation
  • Array element validation

Level 10: Complete Implementation

  • All Level 9 features
  • All validation rules
  • Default value processing
  • Error recovery
  • Streaming support

Testing Conformance

Each level includes a test suite to verify compliance:

// level1-test.ton
{
    string = "value",
    number = 123,
    boolean = true
}

// level5-test.ton
{
    multiline = """
    This tests
    multi-line string
    processing
    """
}

// level9-test.ton
{(user)
    details = {
        profile = {
            name = "Test"
        }
    }
}

#! {(user)
    /details/profile/name = string(required)
}