From cbc3f0bf1c22c926c8d174e06ce5d8fcd7d460e8 Mon Sep 17 00:00:00 2001 From: PgBiel <9021226+PgBiel@users.noreply.github.com> Date: Tue, 21 Jan 2025 15:33:16 -0300 Subject: [PATCH 1/2] update to tree-sitter-c3 0.2.3 --- extension.toml | 2 +- languages/c3/config.toml | 4 ++++ languages/c3/highlights.scm | 13 +++++++++++-- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/extension.toml b/extension.toml index 107774b..91898bc 100644 --- a/extension.toml +++ b/extension.toml @@ -12,4 +12,4 @@ language = "C3" [grammars.c3] repository = "https://github.com/c3lang/tree-sitter-c3" -commit = "790a0326833cd647e00d8dec01268aa1ec2e3bdb" +commit = "10a78fbf8d3095369d32bc99840487396d899899" diff --git a/languages/c3/config.toml b/languages/c3/config.toml index a0b13dd..1fc00f5 100644 --- a/languages/c3/config.toml +++ b/languages/c3/config.toml @@ -18,4 +18,8 @@ brackets = [ "string", "comment", ] }, + { start = "<*", end = " *>", close = true, newline = true, not_in = [ + "string", + "comment", + ] } ] diff --git a/languages/c3/highlights.scm b/languages/c3/highlights.scm index 2ebe017..5c43da1 100644 --- a/languages/c3/highlights.scm +++ b/languages/c3/highlights.scm @@ -19,7 +19,7 @@ (initializer_list (arg (param_path (param_path_element (ident) @variable.member)))) ;; 2) Parameter (parameter name: (_) @variable.parameter) -(call_invocation (arg (param_path (param_path_element [(ident) (ct_ident)] @variable.parameter)))) +(call_invocation (call_arg (ident) @variable.parameter)) (enum_param_declaration (ident) @variable.parameter) ;; 3) Declaration (global_declaration (ident) @variable.declaration) @@ -320,4 +320,13 @@ (block_comment) ] @comment -(doc_comment) @comment.documentation +(doc_comment) @comment.doc +(doc_comment_text) @comment.doc +(doc_comment_contract name: (_) @emphasis.strong + (#any-of? @emphasis.strong + "@param" + "@return" + "@deprecated" + "@require" + "@ensure" + "@pure")) From 35df0f3e521331b554e8a480637bc483582d504d Mon Sep 17 00:00:00 2001 From: PgBiel <9021226+PgBiel@users.noreply.github.com> Date: Tue, 21 Jan 2025 16:27:57 -0300 Subject: [PATCH 2/2] add function with contract to test --- test.c3 | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test.c3 b/test.c3 index 586b2b4..2c70ae7 100644 --- a/test.c3 +++ b/test.c3 @@ -20,6 +20,21 @@ fn String Person.as_str(Person* self) @dynamic return str.copy_str(); } +<* +Factorial. +@pure +@param i +@require i >= 0 +@ensure return >= 1 +*> +fn int fact(int i = 0) { + if (i == 0) { + return 1; + } else { + return i * fact(i: i - 1); + } +} + fn void main() { Person p = {