joelspadin / tree-sitter-devicetree

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

Support all valid unit-addresses #13

Closed blmaier closed 7 months ago

blmaier commented 7 months ago

The Devicetree Specification v0.4, section 2.2.1 "Node Names", says

The unit-address component of the name is specific to the bus type on which the node sits. It consists of one or more ASCII characters from the set of characters in Table 2.1.

Table 2.1 allows for all a-z characters, ',', '.', '_', '+', and '-'.

In normal use the unit-address is just a hex number and the devicetree spec technically requires this by saying

The unit-address must match the first address specified in the reg property of the node.

However the devicetree compiler supports the full ASCII table, and there are a significant number of devicetrees in the Linux kernel that use the unit-address as a "name" field. For example see https://elixir.bootlin.com/linux/v6.7.4/source/arch/arm/boot/dts/marvell/armada-xp-crs328-4c-20s-4s.dtsi#L91

joelspadin commented 7 months ago

Thanks for this! Could you add a (or modify an existing) unit test that includes these characters? See https://github.com/joelspadin/tree-sitter-devicetree/blob/main/test/corpus/nodes.txt#L40

blmaier commented 7 months ago

Thanks for this! Could you add a (or modify an existing) unit test that includes these characters? See https://github.com/joelspadin/tree-sitter-devicetree/blob/main/test/corpus/nodes.txt#L40

Extended that unit test with the new characters

joelspadin commented 7 months ago

Thanks!