Skip to content
This repository was archived by the owner on Jun 18, 2026. It is now read-only.

Commit 5b09e6c

Browse files
Update homepage with human-written primer
1 parent bb32fa6 commit 5b09e6c

6 files changed

Lines changed: 1971 additions & 1831 deletions

File tree

crates/tree-sitter-styx/grammar.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ module.exports = grammar({
3535
[$.attributes],
3636
// Object body can be newline or comma separated
3737
[$._newline_separated, $._comma_separated],
38+
// Entry key path: can't tell if next expr is another key or the value
39+
[$.entry],
3840
],
3941

4042
rules: {
@@ -43,14 +45,19 @@ module.exports = grammar({
4345
document: ($) =>
4446
seq(repeat($._newline), repeat(seq(optional($.doc_comment), $.entry, repeat($._newline)))),
4547

46-
// Entry: key followed by optional value
48+
// Entry: key path followed by optional value
4749
// - key only = implicit unit value
4850
// - key + value = explicit value
51+
// - key key ... value = nested key path (N-1 keys, 1 value)
52+
//
53+
// Per r[entry.structure] and r[entry.keypath]:
54+
// When an entry has N atoms (N > 2), the first N-1 atoms form keys
55+
// and only the last atom is the value.
4956
entry: ($) =>
5057
prec.right(
5158
choice(
52-
// Key with value(s)
53-
seq(field("key", $.expr), field("value", $.expr), repeat(field("value", $.expr))),
59+
// Key with value(s) - first N-1 are keys, last is value
60+
seq(field("key", $.expr), repeat(field("key", $.expr)), field("value", $.expr)),
5461
// Key only (implicit unit value)
5562
field("key", $.expr),
5663
),

crates/tree-sitter-styx/src/grammar.json

Lines changed: 12 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/tree-sitter-styx/src/node-types.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)