joelspadin / tree-sitter-devicetree

Tree-sitter grammar for Devicetree files
MIT License
28 stars 6 forks source link

Support node names with unit-addresses in /delete-node/ #17

Closed igor-prusov closed 3 months ago

igor-prusov commented 3 months ago

Many DTS files in Linux kernel have /delete-node/ statements that reference a node with an address. For example arch/arm64/boot/dts/arm/juno-scmi.dtsi:

&sram {
        /delete-node/ scp-sram@0;
        /delete-node/ scp-sram@200;
        ...
};

Device Tree Specification only mentions the node-name syntax:

Devicetree nodes are defined with a node name and unit address with braces marking the start and end of the node definition. They may be preceded by a label.

[label:] node-name[@unit-address] {
[properties definitions]
[child nodes]
}

Previously defined nodes may be deleted.

/delete-node/ node-name;
/delete-node/ &label;

but kernel files are unlikely to go anywhere, so I believe it makes sense to support it in grammar as well.

joelspadin commented 3 months ago

Thanks!

Given that the mac tests passed, and the Windows/Linux tests look like issues with the test runner rather than the code, I'll merge this and figure out why the tests are failing later.

igor-prusov commented 3 months ago

Thanks! I've checked cargo test locally without my changes and it failed the same way. Probably it has something to do with some API changes in tree-sitter 0.22.* crate.