Friday, November 7, 2025

Context Sensitive Grammar

Context Sensitive Grammar

Entanglement Engine Context Sensitive Grammar

Top-down · Blogger-safe · single file
Options (steps & speed)
Ready.
Outputstep 0
len 1
Tip: Context sensitivity comes from multi-token LHS (e.g., A B -> A x B). Use a preset and press Run.
About: Entanglement Engine

A compact emulator for Type-1, context-sensitive rewriting. This Simple Mode hides advanced controls so the poem is easy to run on Blogger.

Deterministic run: applies the leftmost applicable rule once per step. “Run” repeats until Max Steps or no rule applies.

Scripting Language — Quick Guide

1) Tokens

  • Input/output are space-separated tokens: e.g., A B x. Upper/lowercase have no special behavior.
  • The engine starts from the preset’s start string (shown in each example).

2) Rule Syntax

LHS -> RHS
  • One rule per line. The arrow is a literal ->.
  • Alternatives: separate multiple RHS options with | (each option is a separate rule).
  • Epsilon (empty): use a blank RHS or aliases , epsilon, eps, ε to delete the LHS.
  • Comments: anything after ; or // on a line is ignored.

3) Context Sensitivity

The LHS may be multiple tokens. A rule matches only when the entire LHS sequence occurs, so rewrites can depend on neighbors.

A B -> A x B
A x B -> A x x B

“Insert x between A and B” only triggers when A is immediately followed by B.

4) Execution Model

  • Step: apply one rewrite at the leftmost match; then print the string.
  • Run: repeat Step until Max Steps or no rules apply.
  • Deterministic: if multiple rules match at the same position, the earlier rule (higher in the list) fires.

5) Mini Cheat-Sheet

# basic form
A -> x y z

# multi-token LHS (context required)
A B -> A x B

# alternatives
S -> A S A | B S B | A A | B B

# epsilon (delete)
C B ->    ; removes the sequence "C B"

# comments
A B -> A x B   ; insert x between A and B

6) Tips

  • For strict Type-1 experiments, avoid contracting rules (don’t make RHS shorter than LHS).
  • Put more specific rules earlier if they compete with general ones.
  • Use short tokens for structural symbols (e.g., A, B, x), and words for terminal text if you like (AND, light, debt).