Skip to content

Add support for overlay/fragments in DevicetreeLexer and update example file#3021

Merged
birkenfeld merged 1 commit intopygments:masterfrom
kartben:dts_lexer_fixes
Feb 20, 2026
Merged

Add support for overlay/fragments in DevicetreeLexer and update example file#3021
birkenfeld merged 1 commit intopygments:masterfrom
kartben:dts_lexer_fixes

Conversation

@kartben
Copy link
Copy Markdown
Contributor

@kartben kartben commented Jan 22, 2026

The DTS lexer had issues with recognizing overlay/fragment syntax, whereby in the following snippet i2c1 wouldn't be seen as a "node"

&i2c1 {
	serlcd@72 {
		compatible = "sparkfun,serlcd";
		reg = <0x72>;
		columns = <16>;
		rows = <2>;
		command-delay-ms = <10>;
		special-command-delay-ms = <50>;
	};
};

and "i2c1" was being tokenized as a Name.Attribute instead of a Name.Function, causing the rest of the lexing to fail as it encountered the "@" character in an unexpected location.

This fixes the issue by adding proper support for overlay/fragment syntax, both &label form as well as &{node/full/path}.

Note that as can be seen from the diff this doesn't change anything else in the tokenization, so there's that :)

Before:

image

After:

image

…le DTS file

The DTS lexer had issues with recognizing overlay/fragment syntax, whereby in
the following snippet:

&i2c1 {
	serlcd@72 {
		compatible = "sparkfun,serlcd";
		reg = <0x72>;
		columns = <16>;
		rows = <2>;
		command-delay-ms = <10>;
		special-command-delay-ms = <50>;
	};
};

the "i2c1" was being tokenized as a Name.Attribute instead of a Name.Function,
causing the rest of the lexing to fail as it encountered the "@" character.

This fixes the issue by adding proper support for overlay/fragment syntax.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
@kartben kartben changed the title Add support for overlay/fragments in DevicetreeLexer and update examp… Add support for overlay/fragments in DevicetreeLexer and update example file Jan 22, 2026
@kartben kartben marked this pull request as ready for review January 22, 2026 15:07
kartben added a commit to kartben/zephyr that referenced this pull request Feb 19, 2026
Until pygments/pygments#3021 is accepted and merged in upstream Pygments
we need to workaround some of the current limitations of the lexer with
overlay syntax. This fixes a doc build failure in main

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
aescolar pushed a commit to zephyrproject-rtos/zephyr that referenced this pull request Feb 19, 2026
Until pygments/pygments#3021 is accepted and merged in upstream Pygments
we need to workaround some of the current limitations of the lexer with
overlay syntax. This fixes a doc build failure in main

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
@birkenfeld
Copy link
Copy Markdown
Member

Thanks, LGTM!

@birkenfeld birkenfeld merged commit 80d738c into pygments:master Feb 20, 2026
15 checks passed
@Anteru Anteru added this to the 2.20.0 milestone Mar 26, 2026
@Anteru Anteru added the A-lexing area: changes to individual lexers label Mar 26, 2026
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