diff --git a/syntaxes/sentinel.tmGrammar.json b/syntaxes/sentinel.tmGrammar.json index b772c53..8f8698f 100644 --- a/syntaxes/sentinel.tmGrammar.json +++ b/syntaxes/sentinel.tmGrammar.json @@ -52,8 +52,7 @@ "include": "#string_literals" }, { - "name": "support.function.builtin.sentinel", - "match": "\\b(append|delete|error|keys|length|print|range|values|int|float|string|bool)\\b" + "include": "#functions" } ], "repository": { @@ -90,6 +89,18 @@ } } }, + "functions": { + "match": "\\b(append|compare|delete|error|keys|length|print|range|values|int|float|string|bool)(\\b\\s*\\()", + "captures": { + "1": { + "name": "support.function.builtin.sentinel" + }, + "2": { + "name": "" + } + + } + }, "hash_line_comments": { "name": "comment.line.number-sign.sentinel", "begin": "#", diff --git a/tests/snapshot/sentinel/functions.sentinel.snap b/tests/snapshot/sentinel/functions.sentinel.snap index 8a31db5..eba6357 100644 --- a/tests/snapshot/sentinel/functions.sentinel.snap +++ b/tests/snapshot/sentinel/functions.sentinel.snap @@ -77,7 +77,8 @@ > print(a) // 42 #^^^^ source.sentinel # ^^^^^ source.sentinel support.function.builtin.sentinel -# ^^^^ source.sentinel +# ^ source.sentinel +# ^^^ source.sentinel # ^^ source.sentinel comment.line.double-slash.sentinel punctuation.definition.comment.sentinel # ^^^ source.sentinel comment.line.double-slash.sentinel > return undefined @@ -90,7 +91,8 @@ > >print(a) // undefined #^^^^^ source.sentinel support.function.builtin.sentinel -# ^^^^ source.sentinel +# ^ source.sentinel +# ^^^ source.sentinel # ^^ source.sentinel comment.line.double-slash.sentinel punctuation.definition.comment.sentinel # ^^^^^^^^^^ source.sentinel comment.line.double-slash.sentinel > diff --git a/tests/snapshot/sentinel/inbuilt_funcs.sentinel b/tests/snapshot/sentinel/inbuilt_funcs.sentinel new file mode 100644 index 0000000..17408ae --- /dev/null +++ b/tests/snapshot/sentinel/inbuilt_funcs.sentinel @@ -0,0 +1,53 @@ +# https://developer.hashicorp.com/sentinel/docs/functions + +append (foo, bar) +append = "baz" +something = append + +compare (foo, bar) +compare = "baz" +something = compare + +delete (foo, bar) +delete = "baz" +something = delete + +error (foo, bar) +error = "baz" +something = error + +keys (foo, bar) +keys = "baz" +something = keys + +length (foo, bar) +length = "baz" +something = length + +print (foo, bar) +print = "baz" +something = print + +range (foo, bar) +range = "baz" +something = range + +values (foo, bar) +values = "baz" +something = values + +int (foo, bar) +int = "baz" +something = int + +float (foo, bar) +float = "baz" +something = float + +string (foo, bar) +string = "baz" +something = string + +bool (foo, bar) +bool = "baz" +something = bool diff --git a/tests/snapshot/sentinel/inbuilt_funcs.sentinel.snap b/tests/snapshot/sentinel/inbuilt_funcs.sentinel.snap new file mode 100644 index 0000000..5f268af --- /dev/null +++ b/tests/snapshot/sentinel/inbuilt_funcs.sentinel.snap @@ -0,0 +1,212 @@ +># https://developer.hashicorp.com/sentinel/docs/functions +#^ source.sentinel comment.line.number-sign.sentinel punctuation.definition.comment.sentinel +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.sentinel comment.line.number-sign.sentinel +> +>append (foo, bar) +#^^^^^^ source.sentinel support.function.builtin.sentinel +# ^^^ source.sentinel +# ^^^^^^^^^^ source.sentinel +>append = "baz" +#^^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +>something = append +#^^^^^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^^^^^^^^ source.sentinel +> +>compare (foo, bar) +#^^^^^^^ source.sentinel support.function.builtin.sentinel +# ^^^ source.sentinel +# ^^^^^^^^^^ source.sentinel +>compare = "baz" +#^^^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +>something = compare +#^^^^^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^^^^^^^^^ source.sentinel +> +>delete (foo, bar) +#^^^^^^ source.sentinel support.function.builtin.sentinel +# ^^^ source.sentinel +# ^^^^^^^^^^ source.sentinel +>delete = "baz" +#^^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +>something = delete +#^^^^^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^^^^^^^^ source.sentinel +> +>error (foo, bar) +#^^^^^ source.sentinel support.function.builtin.sentinel +# ^^^ source.sentinel +# ^^^^^^^^^^ source.sentinel +>error = "baz" +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +>something = error +#^^^^^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^^^^^^^ source.sentinel +> +>keys (foo, bar) +#^^^^ source.sentinel support.function.builtin.sentinel +# ^^^ source.sentinel +# ^^^^^^^^^^ source.sentinel +>keys = "baz" +#^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +>something = keys +#^^^^^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^^^^^^ source.sentinel +> +>length (foo, bar) +#^^^^^^ source.sentinel support.function.builtin.sentinel +# ^^^ source.sentinel +# ^^^^^^^^^^ source.sentinel +>length = "baz" +#^^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +>something = length +#^^^^^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^^^^^^^^ source.sentinel +> +>print (foo, bar) +#^^^^^ source.sentinel support.function.builtin.sentinel +# ^^^ source.sentinel +# ^^^^^^^^^^ source.sentinel +>print = "baz" +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +>something = print +#^^^^^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^^^^^^^ source.sentinel +> +>range (foo, bar) +#^^^^^ source.sentinel support.function.builtin.sentinel +# ^^^ source.sentinel +# ^^^^^^^^^^ source.sentinel +>range = "baz" +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +>something = range +#^^^^^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^^^^^^^ source.sentinel +> +>values (foo, bar) +#^^^^^^ source.sentinel support.function.builtin.sentinel +# ^^^ source.sentinel +# ^^^^^^^^^^ source.sentinel +>values = "baz" +#^^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +>something = values +#^^^^^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^^^^^^^^ source.sentinel +> +>int (foo, bar) +#^^^ source.sentinel support.function.builtin.sentinel +# ^^^ source.sentinel +# ^^^^^^^^^^ source.sentinel +>int = "baz" +#^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +>something = int +#^^^^^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^^^^^ source.sentinel +> +>float (foo, bar) +#^^^^^ source.sentinel support.function.builtin.sentinel +# ^^^ source.sentinel +# ^^^^^^^^^^ source.sentinel +>float = "baz" +#^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +>something = float +#^^^^^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^^^^^^^ source.sentinel +> +>string (foo, bar) +#^^^^^^ source.sentinel support.function.builtin.sentinel +# ^^^ source.sentinel +# ^^^^^^^^^^ source.sentinel +>string = "baz" +#^^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +>something = string +#^^^^^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^^^^^^^^ source.sentinel +> +>bool (foo, bar) +#^^^^ source.sentinel support.function.builtin.sentinel +# ^^^ source.sentinel +# ^^^^^^^^^^ source.sentinel +>bool = "baz" +#^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^ source.sentinel +# ^ source.sentinel string.quoted.double.untitled +# ^^^ source.sentinel string.quoted.double.untitled +# ^ source.sentinel string.quoted.double.untitled +>something = bool +#^^^^^^^^^^ source.sentinel +# ^ source.sentinel keyword.operator.symbol.sentinel +# ^^^^^^ source.sentinel +> \ No newline at end of file diff --git a/tests/snapshot/sentinel/lists.sentinel.snap b/tests/snapshot/sentinel/lists.sentinel.snap index 5d34016..a8b3be9 100644 --- a/tests/snapshot/sentinel/lists.sentinel.snap +++ b/tests/snapshot/sentinel/lists.sentinel.snap @@ -47,7 +47,8 @@ # ^ source.sentinel keyword.operator.symbol.sentinel # ^ source.sentinel # ^^^^^^ source.sentinel support.function.builtin.sentinel -# ^^ source.sentinel +# ^ source.sentinel +# ^ source.sentinel # ^ source.sentinel constant.numeric.number.sentinel # ^ source.sentinel # ^ source.sentinel constant.numeric.number.sentinel @@ -61,7 +62,8 @@ # ^ source.sentinel keyword.operator.symbol.sentinel # ^ source.sentinel # ^^^^^^ source.sentinel support.function.builtin.sentinel -# ^^ source.sentinel +# ^ source.sentinel +# ^ source.sentinel # ^ source.sentinel constant.numeric.number.sentinel # ^ source.sentinel # ^ source.sentinel constant.numeric.number.sentinel @@ -77,7 +79,8 @@ # ^ source.sentinel keyword.operator.symbol.sentinel # ^ source.sentinel # ^^^^^^ source.sentinel support.function.builtin.sentinel -# ^^ source.sentinel +# ^ source.sentinel +# ^ source.sentinel # ^ source.sentinel constant.numeric.number.sentinel # ^ source.sentinel # ^ source.sentinel constant.numeric.number.sentinel diff --git a/tests/snapshot/sentinel/logging_errors.sentinel.snap b/tests/snapshot/sentinel/logging_errors.sentinel.snap index 4c6cb42..7f6fc1e 100644 --- a/tests/snapshot/sentinel/logging_errors.sentinel.snap +++ b/tests/snapshot/sentinel/logging_errors.sentinel.snap @@ -50,7 +50,8 @@ # ^^^ source.sentinel >print(one_is_zero) // false #^^^^^ source.sentinel support.function.builtin.sentinel -# ^^^^^^^^^^^^^^ source.sentinel +# ^ source.sentinel +# ^^^^^^^^^^^^^ source.sentinel # ^^ source.sentinel comment.line.double-slash.sentinel punctuation.definition.comment.sentinel # ^^^^^^ source.sentinel comment.line.double-slash.sentinel > \ No newline at end of file diff --git a/tests/snapshot/sentinel/loops.sentinel.snap b/tests/snapshot/sentinel/loops.sentinel.snap index 251bdf9..8cb85e1 100644 --- a/tests/snapshot/sentinel/loops.sentinel.snap +++ b/tests/snapshot/sentinel/loops.sentinel.snap @@ -22,7 +22,8 @@ > append(list, name) #^^^^ source.sentinel # ^^^^^^ source.sentinel support.function.builtin.sentinel -# ^^^^^^^^^^^^^ source.sentinel +# ^ source.sentinel +# ^^^^^^^^^^^^ source.sentinel >} #^^ source.sentinel > diff --git a/tests/snapshot/sentinel/maps.sentinel.snap b/tests/snapshot/sentinel/maps.sentinel.snap index 97df993..6f702ad 100644 --- a/tests/snapshot/sentinel/maps.sentinel.snap +++ b/tests/snapshot/sentinel/maps.sentinel.snap @@ -181,12 +181,14 @@ # ^^^ source.sentinel >keys(data) // ["b", "a"] #^^^^ source.sentinel support.function.builtin.sentinel -# ^^^^^^^^^^^^^ source.sentinel +# ^ source.sentinel +# ^^^^^^^^^^^^ source.sentinel # ^^ source.sentinel comment.line.double-slash.sentinel punctuation.definition.comment.sentinel # ^^^^^^^^^^^ source.sentinel comment.line.double-slash.sentinel >values(data) // [2, 3] #^^^^^^ source.sentinel support.function.builtin.sentinel -# ^^^^^^^^^^^ source.sentinel +# ^ source.sentinel +# ^^^^^^^^^^ source.sentinel # ^^ source.sentinel comment.line.double-slash.sentinel punctuation.definition.comment.sentinel # ^^^^^^^ source.sentinel comment.line.double-slash.sentinel > diff --git a/tests/snapshot/sentinel/variables.sentinel.snap b/tests/snapshot/sentinel/variables.sentinel.snap index 89d8c9f..5f9ff5f 100644 --- a/tests/snapshot/sentinel/variables.sentinel.snap +++ b/tests/snapshot/sentinel/variables.sentinel.snap @@ -57,7 +57,8 @@ # ^ source.sentinel keyword.operator.symbol.sentinel # ^ source.sentinel # ^^^ source.sentinel support.function.builtin.sentinel -# ^^^^^^ source.sentinel +# ^ source.sentinel +# ^^^^^ source.sentinel # ^^ source.sentinel comment.line.double-slash.sentinel punctuation.definition.comment.sentinel # ^^^^^^ source.sentinel comment.line.double-slash.sentinel >a = float(s) // a = 1.1 @@ -65,7 +66,8 @@ # ^ source.sentinel keyword.operator.symbol.sentinel # ^ source.sentinel # ^^^^^ source.sentinel support.function.builtin.sentinel -# ^^^^ source.sentinel +# ^ source.sentinel +# ^^^ source.sentinel # ^^ source.sentinel comment.line.double-slash.sentinel punctuation.definition.comment.sentinel # ^^^^^^^^ source.sentinel comment.line.double-slash.sentinel > @@ -79,7 +81,8 @@ # ^ source.sentinel keyword.operator.symbol.sentinel # ^ source.sentinel # ^^^^^^ source.sentinel support.function.builtin.sentinel -# ^^^^ source.sentinel +# ^ source.sentinel +# ^^^ source.sentinel # ^^ source.sentinel comment.line.double-slash.sentinel punctuation.definition.comment.sentinel # ^^^^^^^^ source.sentinel comment.line.double-slash.sentinel > \ No newline at end of file