tree-sitter / tree-sitter/tree-sitter-cpp

Macro annotations

Open
#40 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
453
Forks
185
PR merge metrics
No merged PRs in 30d

Description

In firefox code, we use some macros to make annotations (for clang static analysis for example).
For example:
https://searchfox.org/mozilla-central/source/dom/animation/AnimationTarget.h#54
or
https://searchfox.org/mozilla-central/source/mfbt/CheckedInt.h#510
Such annotations lead to parse errors and I understand that (because likely this comment itself is valid C++/C: we just have to define some good macros).
So is it something tree-sitter-c/cpp could handle or should I have my own grammar for this code ?
I'd prefer of course the former.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the annotation examples in dom/animation/AnimationTarget.h and mfbt/CheckedInt.h referenced in the issue, then inspect how tree-sitter-c/cpp handles the corresponding macro syntax. Confirm the expected behavior with a minimal parser case; done means establishing whether the existing grammar can parse these annotations or a separate grammar is required.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.