diff options
Diffstat (limited to '')
-rw-r--r-- | pkgs/by-name/tr/tree-sitter-yts/grammar.js | 24 |
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/], }); |