From 9aa123ca0db164320e768d62741e95f093ef930b Mon Sep 17 00:00:00 2001 From: Elliot Fontaine <92150839+elliotfontaine@users.noreply.github.com> Date: Sun, 29 Sep 2024 15:12:10 +0200 Subject: [PATCH] feat: expose fields in task parameter, output and intercycle annotation --- grammar.js | 26 +++++++++++++++++++------- test/corpus/satellite-short.txt | 2 +- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/grammar.js b/grammar.js index 61d3b48..d7566ab 100644 --- a/grammar.js +++ b/grammar.js @@ -168,7 +168,7 @@ module.exports = grammar({ seq( field("brackets_open", "[["), optional(field("name", $.nametag)), - repeat($.task_parameter), + repeat(field("parameter", $.task_parameter)), field("brackets_close", "]]"), $._line_return, optional(repeat(choice($.setting, $._line_return))), @@ -251,8 +251,16 @@ module.exports = grammar({ token.immediate("<"), optional( choice( - seq($.nametag, repeat(seq(token.immediate(","), $.nametag))), - seq($.nametag, optional(seq(token.immediate("="), $.nametag))), + seq( + field("name", $.nametag), + repeat(seq(token.immediate(","), field("name", $.nametag))), + ), + seq( + field("name", $.nametag), + optional( + seq(token.immediate("="), field("selection", $.nametag)), + ), + ), ), ), token.immediate(">"), @@ -261,14 +269,18 @@ module.exports = grammar({ task_output: ($) => choice( seq( - seq(token.immediate(":"), $.nametag), - optional(token.immediate("?")), + seq(token.immediate(":"), field("name", $.nametag)), + optional(field("optional_annotation", token.immediate("?"))), ), - token.immediate("?"), + field("optional_annotation", token.immediate("?")), ), intercycle_annotation: ($) => - seq(token.immediate("["), optional($.recurrence), token.immediate("]")), + seq( + token.immediate("["), + optional(field("recurrence", $.recurrence)), + token.immediate("]"), + ), setting: ($) => seq( diff --git a/test/corpus/satellite-short.txt b/test/corpus/satellite-short.txt index c27b1d9..8e1481f 100644 --- a/test/corpus/satellite-short.txt +++ b/test/corpus/satellite-short.txt @@ -101,7 +101,7 @@ satellite short (graph_task name: (nametag) intercycle: (intercycle_annotation - (recurrence))) + recurrence: (recurrence))) (graph_arrow) (graph_task name: (nametag))