Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal for supporting semantic highlighting #26

Open
timjroberts opened this issue Apr 24, 2023 Discussed in #23 · 1 comment
Open

Proposal for supporting semantic highlighting #26

timjroberts opened this issue Apr 24, 2023 Discussed in #23 · 1 comment
Labels
C-proposal An open suggestion for a feature or improvement to include in ongoing effort

Comments

@timjroberts
Copy link
Collaborator

Discussed in #23

Originally posted by qobilidop April 20, 2023
Semantic highlighting is a feature supported by LSP[1], and major editors/IDEs (like VS Code[2]) through LSP. The benefits of semantic highlighting are explained in more detail in [2]. I think it is a very useful feature, and a natural fit for p4analyzer to implement. As a reference, rust-analyzer has implemented this feature already[3].

Reference:

@timjroberts timjroberts added the C-proposal An open suggestion for a feature or improvement to include in ongoing effort label Apr 24, 2023
@vgurevich
Copy link

vgurevich commented May 5, 2023

The challenge of building a good semantic highlighter is that it should be architecture-aware, meaning that things like:

  • The names of externs (extern constructors) and their parameters
  • The names of extern methods and their parameters
  • The names of architecture-specific types (typedefs, structs, headers, enums, etc.) and constants
  • The names of architecture-specific package (package constructrors) and their parameters

should be properly highlighted. All this information can be gleaned by analyzing the architecture-specific include files, such as tna.p4, psa.p4, etc.

In addition to that, the highlighter should also be target-aware so that it can properly highlight:

  • target-specific annotations
  • target-specific table attributes (properties)

Unfortunately, there is no standard method to retrieve those. Intel's Tofino compiler allows one to dump all Tofino-specific annotations, but there is no way to dump Tofino-specific table attributes (fortunately, there are not that many).

Semantic highlighter for Emacs supports all the above (@timjroberts -- ask me for the latest version), but only for TNA and T2NA, because all those definitions are hard-coded inside (and I do even update them periodically).

p4analyzer should definitely do better than that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-proposal An open suggestion for a feature or improvement to include in ongoing effort
Projects
None yet
Development

No branches or pull requests

2 participants