Skip to content

Commit

Permalink
Allow 'panic' as a function application
Browse files Browse the repository at this point in the history
This matches the same syntax as 'todo'.

Closes #82
  • Loading branch information
the-mikedavis committed Mar 18, 2024
1 parent 2012f29 commit ed9d717
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
10 changes: 9 additions & 1 deletion grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,15 @@ module.exports = grammar({
)
),
panic: ($) =>
seq("panic", optional(seq("as", field("message", $._expression)))),
seq(
"panic",
optional(
choice(
seq("(", field("message", $.string), ")"),
seq("as", field("message", $._expression))
)
)
),
tuple: ($) => seq("#", "(", optional(series_of($._expression, ",")), ")"),
list: ($) =>
seq(
Expand Down
17 changes: 17 additions & 0 deletions test/corpus/expressions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,23 @@ panic as { "Hello, " <> "world!" }
(string
(quoted_content))))))

================================================================================
Todo and panic in function application style
================================================================================

todo("don't panic")
panic("aaaah!")

--------------------------------------------------------------------------------

(source_file
(todo
(string
(quoted_content)))
(panic
(string
(quoted_content))))

================================================================================
Nested field access
================================================================================
Expand Down

0 comments on commit ed9d717

Please sign in to comment.