about summary refs log tree commit diff stats
path: root/pkgs/by-name/tr/tree-sitter-yts/grammar.js
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2024-08-21 14:45:22 +0200
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2024-08-21 14:45:22 +0200
commit6a1da14f61d7aac091ad4e4231bfb007d6b62be8 (patch)
treebe556f144f40ce6ca4714e45567388fde13924c6 /pkgs/by-name/tr/tree-sitter-yts/grammar.js
parentfix(pkgs/yt): Improve `update` and `subs` immensely (diff)
downloadnixos-config-6a1da14f61d7aac091ad4e4231bfb007d6b62be8.tar.gz
nixos-config-6a1da14f61d7aac091ad4e4231bfb007d6b62be8.zip
fix(pkgs/tree-sitter-yts): Update grammar to new yt
Diffstat (limited to '')
-rw-r--r--pkgs/by-name/tr/tree-sitter-yts/grammar.js24
1 files changed, 20 insertions, 4 deletions
diff --git a/pkgs/by-name/tr/tree-sitter-yts/grammar.js b/pkgs/by-name/tr/tree-sitter-yts/grammar.js
index 655f6dea..27972419 100644
--- a/pkgs/by-name/tr/tree-sitter-yts/grammar.js
+++ b/pkgs/by-name/tr/tree-sitter-yts/grammar.js
@@ -4,17 +4,33 @@ module.exports = grammar({
   rules: {
     source_file: ($) => repeat(choice($.line, $.comment)),
     line: ($) =>
-      seq($.command, $.id, $.title, $.date, $.author, $.duration, $.url, "\n"),
+      seq($.command, repeat($.flag), $.id, $.title, $.date, $.author, $.duration, $.url, "\n"),
 
     command: ($) => choice("pick", "p", "watch", "w", "drop", "d", "url", "u"),
-    id: ($) => /[0-9]+/,
+    flag: ($) =>
+      choice(
+              /-\w [^\s]+/,
+              /-\w '[^']*'/,
+              /-\w "[^"]*"/,
+              /-\w=[^\s]+/,
+              /-\w='[^']*'/,
+              /-\w="[^"]*"/,
+
+              /--\w+ [^\s]+/,
+              /--\w+ '[^']*'/,
+              /--\w+ "[^"]*"/,
+              /--\w+=[^\s]+/,
+              /--\w+='[^']*'/,
+              /--\w+="[^"]*"/,
+              ),
+    id: ($) => /[a-z0-9]+/,
     title: ($) => seq($._q, /[^"]+/, $._q),
     date: ($) => seq($._q, /\d{4}-\d{2}-\d{2}/, $._q),
     author: ($) => seq($._q, /[^"]+/, $._q),
     duration: ($) =>
       seq(
         $._q,
-        seq("[", choice("No Duration", /\d+m \d+s/, /\d+h \d+m/), "]"),
+        seq(choice("[No Duration]", /\d+m \d+s/, /\d+h \d+m/)),
         $._q,
       ),
     url: ($) => seq($._q, /[^"]+/, $._q),
@@ -22,5 +38,5 @@ module.exports = grammar({
     _q: ($) => $.quote,
     quote: ($) => /"/,
   },
-  extras: ($) => [/\s/, /\\\r?\n/],
+  extras: ($) => [/\s/],
 });