Skip to content

Conversation

@frasercrmck
Copy link
Contributor

This commit adds a basic lexer for LLVM's TableGen DSL[1][2].

The major design decision is about how to tokenize "code blocks" since those are, at a TableGen language level, string literals. In practice, however, in LLVM 99% of the time they are snippets of C++ which are processed by a TableGen backend. This would ideally be a configurable property of the lexer. For the initial implementation, it is assumed that code blocks contain C++ code and so the CppLexer is invoked on their contents.

[1] https://llvm.org/docs/TableGen/index.html
[2] https://llvm.org/docs/TableGen/ProgRef.html

This commit adds a basic lexer for LLVM's TableGen DSL[1][2].

The major design decision is about how to tokenize "code blocks" since
those are, at a TableGen language level, string literals. In practice,
however, in LLVM 99% of the time they are snippets of C++ which are
processed by a TableGen backend. This would ideally be a configurable
property of the lexer. For the initial implementation, it is assumed
that code blocks contain C++ code and so the CppLexer is invoked on
their contents.

[1] https://llvm.org/docs/TableGen/index.html
[2] https://llvm.org/docs/TableGen/ProgRef.html
@frasercrmck
Copy link
Contributor Author

Some example output:

image

@josh146
Copy link

josh146 commented Jul 20, 2024

Just want to add that this will be a great addition, as we are currently adding a lot of TableGen code blocks to our sphinx project!

@Anteru Anteru merged commit 2bd3197 into pygments:master Oct 6, 2024
@Anteru
Copy link
Collaborator

Anteru commented Oct 6, 2024

I'm sure everyone working on LLVM will appreciate it, merged for 2.19, thanks!

@Anteru Anteru added the A-lexing area: changes to individual lexers label Oct 6, 2024
@Anteru Anteru added this to the 2.19.0 milestone Oct 6, 2024
@frasercrmck frasercrmck deleted the tablegen branch October 6, 2024 18:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-lexing area: changes to individual lexers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants