N.O.N. v2.1 - Wishart Core

Full specification draft with deterministic parsing behavior for engine and tool integrations.

1) Scope

  • Indentation-driven object/list notation.
  • Engine-oriented literals: vectors, colors, references.
  • Meta keys via @ prefix for root descriptors.
  • Two parser modes: strict and lenient.

2) Lexical & Structural Rules

  • Canonical indent unit: 4 spaces.
  • Tabs are rejected in strict mode.
  • Keys use key: value; nested blocks use a trailing colon with no inline value.
  • Lists use dash items (- value) or inline arrays ([a, b]).
  • Comment lines start with # as the first non-space character.
@entity: npc_guard_01
@class: Guard
    name: "Royal Guard"
    level: 15
    stats:
        hp: 200
        dex: 12

3) Scalar Parsing Order

  • Booleans: true / false (case-insensitive).
  • Null: null or ~.
  • Integers/floats with optional sign.
  • Color literal: #RRGGBB.
  • Vector2/Vector3: (x, y) / (x, y, z).
  • Reference token: &id.
  • Quoted strings support \" escaping.
  • Everything else resolves to plain string.

4) Canonical JSON Bridge

Suggested bridge targets for consumers that do not parse N.O.N. directly:

  • Reference values map to { "$ref": "id" }.
  • Vectors map to { "x": n, "y": n, "z": n? }.
  • Meta keys map into _meta.
  • Color literal remains string by default.
{
  "_meta": { "entity": "npc_guard_01", "class": "Guard" },
  "name": "Royal Guard",
  "position": { "x": 120, "y": 0, "z": 45 },
  "target": { "$ref": "enemy_01" }
}

5) Strict vs Lenient Mode

  • Strict: tabs, mixed indent, malformed lines, and ambiguous blocks are fatal errors.
  • Lenient: attempts parse recovery and emits warnings where possible.
  • Both should report line and column for failures.

6) Test Matrix (Minimum Suite)

  • Indent and dedent correctness, mixed whitespace rejection.
  • Quoted/unquoted strings with colon, hash, and spaces.
  • Numeric, boolean, null, color, vector and reference literals.
  • Nested list/object combinations and inline arrays.
  • Round-trip behavior for N.O.N. -> JSON -> N.O.N.
Case 01: Basic key/value object
Case 02: Nested object with 4-space indent
Case 03: Dash list of scalars
Case 04: Dash list of objects
Case 05: Inline list parser
Case 06: Vector parsing
Case 07: Color literal parsing
Case 08: Reference token serialization
Case 09: Invalid mixed tab + spaces (strict fail)
Case 10: Invalid malformed key line (strict fail)

7) Parser API (non.js)

  • parseNon(text, options): parse to canonical JSON shape.
  • stringifyNon(value, options): format JSON as N.O.N.
  • nonToJson(text, options): alias of parseNon.
  • jsonToNon(value, options): alias of stringifyNon.

Download Draft

The full markdown draft is available in the project root.

Open v2.1 Draft File