Open App ← quinnsavitt.com

Synta — Language Reference

This is a compact, technical specification for the three artifacts Synta supports: bracketed trees (constituency notation), .synta (flat, line-oriented), and .syt (styling language executed at render time). The reference is precise rather than tutorial-style; examples are included for every construct.

Summary


1. Bracketed notation (grammar & semantics)

1.1 Grammar (informal)

Tree    := Node | Term
Node    := '[' Label (Child)* ']'
Term    := Token | '(' Phrase ')'
Label   := IDENT ('_' SUB)? ('{' INDEX '}')? ('->' INDEX)?
Token   := IDENT ('_' SUB)? ('{' INDEX '}')? ('->' INDEX)?
Phrase  := any characters except unbalanced parentheses (can contain spaces)

1.2 Features

1.3 Examples

[S [NP{1} This] [VP [V is] [NP [D a] [N_wug{2}]]]]

// multiword terminal
[NP (New York)_LOC{4}]

// arrow hint
[S [NP{1} He->2] [VP ...]]

1.4 Notes & limitations


2. .synta — flat, line-oriented format

2.1 Line types

2.2 Formal rules

2.3 Example

* D This
* V is
* D a
* N wug
3|4 NP
2|5 VP
1|6 S
1->3 {trace}

2.4 Conversion considerations


3. .syt — styling language (complete reference)

Purpose: run arbitrary styling code against the renderer scene before the canvas draw pass. The language is indentation-sensitive and intentionally small but expressive.

3.1 Lexical tokens

3.2 Statements

3.3 Expressions (summary)

Supports precedence-aware expressions: unary (-, not), binary (+, -, *, /, %, **), comparisons (==, !=, <, <=, >, >=), logical and/or, membership in/not in, and has for property checks.

3.4 Comprehensions

List comprehensions using the syntax [var in Collection where predicate] produce a filtered list.

3.5 Built-in runtime objects

On execution the interpreter receives a scene object with these properties (names are case-sensitive):

3.6 Object shapes (common fields)

Fields commonly present on scene objects (not exhaustive):

Node/Term object:
  Type: 'Node' | 'Term'
  Id: string
  Visible: boolean
  Parent: reference | null
  Children: array
  Text: string
  TextSize: number
  Font: string
  Color: css | [r,g,b]
  X, Y, _x, _y: numeric positions

Line object:
  Type:'Line', Id: string, Parent: node, Child: node, Width, Color, Style

Arrow object:
  Type:'Arrow', Id: string, From: node, To: node, Width, Color, Style, Label, Visible

3.7 Property semantics

3.8 Built-in helper functions

len(x)       // length of list or string
type(x)      // returns 'list','null','number','string', etc.
range(a,b)   // integer ranges
min/max/abs
int/float/str/bool
rgb(r,g,b)   // returns [r,g,b] tuple used by renderer

3.9 Error model

Runtime errors (undefined variables, invalid indices, type errors, invalid assignments) are raised as exceptions. The UI surfaces interpreter errors in the errors panel.


4. Common SYT patterns & examples

4.1 Color nodes by label

for each n in Nodes:
    if n.label == "NP":
        n.Color = rgb(10,180,120)
    elif n.label == "VP":
        n.Color = rgb(10,120,180)

4.2 Hide unlabeled arrows

for each a in Arrows:
    if not a.Label:
        a.Visible = false

4.3 Increase spacing

Tree.MinHorizontalSpacing = 160
Tree.MinVerticalSpacing = 240

5. Export, conversion & validation