Skip to content

Commit

Permalink
c: Add runnable for main function (zed-industries#18720)
Browse files Browse the repository at this point in the history
Release Notes:

- Added Runnable for C main function

This tags can then be used in tasks, for example:

```json
[
  {
    "label": "Run ${ZED_STEM}",
    "command": "gcc",
    "args": [
      "$ZED_FILE",
      "-o",
      "${ZED_DIRNAME}/${ZED_STEM}.out",
      "&&",
      "${ZED_DIRNAME}/${ZED_STEM}.out"
    ],
    "tags": ["c-main"]
  }
]

```
  • Loading branch information
talal authored Oct 4, 2024
1 parent d012e35 commit 2f7430a
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions crates/languages/src/c/runnables.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
; Tag the main function
(
(function_definition
declarator: (function_declarator
declarator: (identifier) @run
)
) @c-main
(#eq? @run "main")
(#set! tag c-main)
)

0 comments on commit 2f7430a

Please sign in to comment.