Skip to content

Commit

Permalink
style: format according to Prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
elliotfontaine committed Sep 25, 2024
1 parent ed562f7 commit d86807c
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 68 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
tree-sitter-cylc
================
# tree-sitter-cylc

<p align="center">
<img src="https://raw.githubusercontent.com/cylc/cylc-admin/master/docs/img/cylc-logo.svg" width="150" alt="Cylc Logo">
<img src="https://tree-sitter.github.io/tree-sitter/assets/images/tree-sitter-small.png" width="50" alt="Tree-Sitter Logo">
</p>

[Tree-Sitter](https://github.com/tree-sitter/tree-sitter) Grammar for [Cylc](https://github.com/cylc/cylc-flow)'s workflow configurations.
[Tree-Sitter](https://github.com/tree-sitter/tree-sitter) Grammar for [Cylc](https://github.com/cylc/cylc-flow)'s workflow configurations.
128 changes: 64 additions & 64 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ module.exports = grammar({
configuration_file: ($) =>
seq(
optional($.jinja2_shebang),
repeat(choice($.root_section, $.include_statement))
repeat(choice($.root_section, $.include_statement)),
),

// --------------------------- Terminal symbols ---------------------------
Expand Down Expand Up @@ -79,7 +79,7 @@ module.exports = grammar({
// with separators
field(
"date",
/[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|30|31)/
/[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|30|31)/,
),
"T",
optional(
Expand All @@ -89,8 +89,8 @@ module.exports = grammar({
choice(
/[0-9]{2}:[0-9]{2}:[0-9]{2}/,
/[0-9]{2}:[0-9]{2}/,
/[0-9]{2}/
)
/[0-9]{2}/,
),
),
optional(
// when time is present, optional timezone
Expand All @@ -99,19 +99,19 @@ module.exports = grammar({
seq(
choice("+", "-"),
token.immediate(
choice(/[0-9]{2}:[0-9]{2}/, /[0-9]{2}/)
)
)
)
)
)
)
choice(/[0-9]{2}:[0-9]{2}/, /[0-9]{2}/),
),
),
),
),
),
),
),
seq(
// without separators
field(
"date",
/[0-9]{4}(0[1-9]|1[0-2])(0[1-9]|[12][0-9]|30|31)/
/[0-9]{4}(0[1-9]|1[0-2])(0[1-9]|[12][0-9]|30|31)/,
),
"T",
optional(
Expand All @@ -123,17 +123,17 @@ module.exports = grammar({
seq(
choice("+", "-"),
token.immediate(
choice(/[0-9]{2}[0-9]{2}/, /[0-9]{2}/)
)
)
)
)
)
)
)
)
)
)
choice(/[0-9]{2}[0-9]{2}/, /[0-9]{2}/),
),
),
),
),
),
),
),
),
),
),
),

// ------------------------- Non-Terminal Symbols -------------------------
Expand All @@ -151,13 +151,13 @@ module.exports = grammar({
optional(
choice(
field("name", $.nametag),
field("name", alias("task parameters", $.nametag))
)
field("name", alias("task parameters", $.nametag)),
),
),
"]",
$._line_return,
optional(repeat($.setting)),
optional(repeat(choice($.subsection_1, $.graph_section)))
optional(repeat(choice($.subsection_1, $.graph_section))),
),

subsection_1: ($) =>
Expand All @@ -168,7 +168,7 @@ module.exports = grammar({
"]]",
$._line_return,
optional(repeat($.setting)),
optional(repeat($.subsection_2))
optional(repeat($.subsection_2)),
),

graph_section: ($) =>
Expand All @@ -177,7 +177,7 @@ module.exports = grammar({
field("name", alias("graph", $.nametag)),
"]]",
$._line_return,
optional(repeat($.recurrence))
optional(repeat($.recurrence)),
),

subsection_2: ($) =>
Expand All @@ -186,7 +186,7 @@ module.exports = grammar({
optional(field("name", $.nametag)),
"]]]",
$._line_return,
optional(repeat($.setting))
optional(repeat($.setting)),
),

setting: ($) =>
Expand All @@ -204,13 +204,13 @@ module.exports = grammar({
$.datetime,
$.number,
$.boolean,
$.unquoted_string
)
)
)
)
$.unquoted_string,
),
),
),
),
),
$._line_return
$._line_return,
),

recurrence: ($) =>
Expand All @@ -222,37 +222,37 @@ module.exports = grammar({
choice(
//"\n", // Empty value
$.multiline_graphstring,
$.unquoted_graphstring
)
$.unquoted_graphstring,
),
),
$._line_return
$._line_return,
),

unquoted_graphstring: ($) =>
prec.left(
seq(repeat1(choice($.graph_logical, $.graph_task, $.graph_arrow)))
seq(repeat1(choice($.graph_logical, $.graph_task, $.graph_arrow))),
),

multiline_graphstring: ($) =>
choice(
seq(
alias('"""', $.multiline_string_open),
repeat($.unquoted_graphstring),
alias('"""', $.multiline_string_close)
alias('"""', $.multiline_string_close),
),
seq(
alias("'''", $.multiline_string_open),
repeat($.unquoted_graphstring),
alias("'''", $.multiline_string_close)
)
alias("'''", $.multiline_string_close),
),
),

graph_task: ($) =>
seq(
$.nametag,
optional($.task_parameter),
optional($.intercycle_annotation),
optional($.task_output)
optional($.task_output),
),

task_parameter: ($) =>
Expand All @@ -277,24 +277,24 @@ module.exports = grammar({
/"[^"]/, // Allow a single quote, not followed by another quote
/""[^"]/, // Allow one or two quotes inside the string
/\\\s*\n/, // Allow backslashes followed by optional spaces and a newline (for line continuation)
$._jinja2
)
$._jinja2,
),
),
$.string_content
$.string_content,
),
alias('"""', $.multiline_string_close)
alias('"""', $.multiline_string_close),
),
// Triple single quotes
seq(
alias("'''", $.multiline_string_open),
alias(
token(
repeat(choice(/[^'\\]/, /\\./, /'[^']/, /''[^']/, /\\\s*\n/))
repeat(choice(/[^'\\]/, /\\./, /'[^']/, /''[^']/, /\\\s*\n/)),
),
$.string_content
$.string_content,
),
alias("'''", $.multiline_string_close)
)
alias("'''", $.multiline_string_close),
),
),

quoted_string: ($) =>
Expand All @@ -308,23 +308,23 @@ module.exports = grammar({
choice(
/[^"\\\n]/, // Match any character except double quotes, backslashes, or newlines
/\\./, // Match escaped characters (e.g., \" or \')
/\\\n\s*/ // Match a backslash followed by a newline and optional spaces (line continuation)
)
/\\\n\s*/, // Match a backslash followed by a newline and optional spaces (line continuation)
),
),
$.string_content
$.string_content,
),
'"'
'"',
),
// Match single quotes
seq(
"'",
alias(
repeat(choice(/[^'\\\n]/, /\\./, /\\\n\s*/)),
$.string_content
$.string_content,
),
"'"
)
)
"'",
),
),
),

unquoted_string: ($) =>
Expand All @@ -336,13 +336,13 @@ module.exports = grammar({
repeat(
choice(
token.immediate(/[^"'#\n][^{#\n]*/),
$._jinja2
$._jinja2,
//repeat(choice(token.immediate(/[^"'#\s\n][^#\n]*/), $._jinja2))
)
)
),
),
),
$.string_content
)
$.string_content,
),
),

// TODO: COMPLETE ISO 8601 datetime
Expand Down
2 changes: 1 addition & 1 deletion src/node-types.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d86807c

Please sign in to comment.