Add 'as message' syntax for todo and panic (#64)

pull/844/head
Michael Davis 2023-08-27 19:10:26 +07:00 committed by GitHub
parent 8d712c03ab
commit 5035109688
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 4 deletions

@ -370,8 +370,18 @@ module.exports = grammar({
optional(field("arguments", $.arguments))
),
todo: ($) =>
seq("todo", optional(seq("(", field("message", $.string), ")"))),
panic: (_$) => seq("panic"),
seq(
"todo",
optional(
choice(
// DEPRECATED: The 'as' syntax was introduced in v0.30.
seq("(", field("message", $.string), ")"),
seq("as", field("message", $._expression))
)
)
),
panic: ($) =>
seq("panic", optional(seq("as", field("message", $._expression)))),
tuple: ($) => seq("#", "(", optional(series_of($._expression, ",")), ")"),
list: ($) =>
seq(

@ -239,10 +239,11 @@ fn funcall() {
myfun()
}
fn unfinished() {
todo("Finish me!")
todo as "Finish me!"
}
fn do_panic() {
panic
panic as "aaaah!"
}
fn tuple(x) {
#(x, 1)
@ -376,7 +377,10 @@ fn field_access(x) {
name: (identifier)
parameters: (function_parameters)
body: (function_body
(panic)))
(panic)
(panic
message: (string
(quoted_content)))))
(function
name: (identifier)
parameters: (function_parameters

@ -10,3 +10,7 @@ case "12345" {
-x
// ^ operator
// ^ variable
panic as "aaah!"
// <- keyword
// ^ keyword
// ^ string