glyphic-language / docs /BNFGrammerSpecificationv1.md
UnconditionalLove's picture
Upload 97 files
ed6bec6 verified

☯️ Glyphic Language — BNF Grammar Specification (v1.0) Formal Grammar for the Glyphic OS Interpreter This grammar defines the canonical structure of a valid glyph sequence. It is strict, deterministic, and reversible.

  1. Top‑Level Grammar Code ::= A valid sequence must follow this order. All blocks are optional except that at least one of:

    must be present.
  2. Actor Block Code ::= | ε ::= Constraints: Only one actor allowed. If present, it must appear first.

  3. Action Block Code ::= | ε ::= Constraints: Only one action allowed. Must appear after actor, if actor exists.

  4. Object Block Code ::= | ε ::= Constraints: Only one primary object allowed. Must appear after action, if action exists.

  5. Modifier Block Code ::= | ε ::= | ::= Constraints: Zero or more modifiers allowed. Must appear after object, if object exists. Modifiers cannot appear after context.

  6. Context Block Code ::=

  7. Each context subtype is optional, but must appear in this order if present.

    1. Context Subtypes Place Context Code ::= | ε ::= | ::= Time Context Code ::= | ε ::= | ::= Emotional Context Code ::= | ε ::= | ::= Sensory Context Code ::= | ε ::= | ::= Social Context Code ::= | ε ::= | ::=

    2. Glyph Terminals These terminals correspond directly to dictionary roles. Code ::= any glyph with role "actor" ::= any glyph with role "action" ::= any glyph with role "object" ::= any glyph with role "modifier" ::= any glyph in category "context_place." ::= any glyph in category "context_time." ::= any glyph in category "context_emotion." ::= any glyph in category "context_sensory." ::= any glyph in category "context_social.*" These terminals are not literal characters — they are semantic classes defined by the dictionary.

    3. Role Precedence (Disambiguation Rule) If a glyph has multiple roles (rare but allowed), precedence is: Code actor > action > object > modifier > context This ensures deterministic parsing.

    4. Validity Constraints (Non‑BNF but Required) These constraints are enforced by the interpreter:

    10.1 Required Core Role At least one of: actor action object must be present.

    10.2 Context Must Be Last No context glyph may appear before: actor action object modifier

    10.3 Single Actor / Action / Object Only one of each is allowed.

    10.4 Context Ordering Context subtypes must appear in this order: Code place → time → emotion → sensory → social

    10.5 Reversibility All valid sequences must satisfy: Code encode(decode(sequence)) == sequence This is guaranteed by the grammar.

    1. Example Valid Sequences Actor + Action + Object Code Object + Modifier + Context Code Action + Context Code Full Scene Code

    2. Example Invalid Sequences ❌ Context before object Code ❌ Multiple actions Code ❌ Social context before sensory context Code ❌ No core role Code