tree-sitter-devicetree icon indicating copy to clipboard operation
tree-sitter-devicetree copied to clipboard

`/delete-node/` reported as error

Open ensc opened this issue 1 year ago • 4 comments

syntax description rejects a lot of /delete-node/ + /delete-property/ case. E.g. in

/ {
	/delete-node/ foo;
	/delete-property/ bar;
};

/ {
	/delete-node/ foo@0;
};

/ {
	/delete-node/foo;
};

/ {
	/delete-property/bar;
};

/delete-node/ &bar;

only the first block works. Rest is reported as

(document
 (node name: (identifier) {
  (delete_node /delete-node/ name: (identifier) ;)
  (delete_property /delete-property/ name: (identifier) ;)
  } ;)
 (node name: (identifier) {
  (delete_node /delete-node/ name: (identifier)
   name: (ERROR @ (identifier))
   ;)
  } ;)
 (node name: (identifier) {
  (ERROR (identifier) ;)
  } ;)
 (node name: (identifier) {
  (ERROR (identifier) ;)
  } ;)
 (ERROR (identifier)
  (reference & label: (identifier))
  ;))

ensc avatar Feb 14 '24 17:02 ensc

The 3rd & 4th blocks are invalid. AFAIK, directives with arguments are supposed to have whitespace.

The spec is not specific, but reading dtc's source code or the elinux.org wiki can help

axelkar avatar Feb 25 '24 12:02 axelkar

Oh and to the following TODO, yes they are. https://github.com/joelspadin/tree-sitter-devicetree/blob/2087a5b965db2a9efabab958a27fd8ddf43038a2/grammar.js#L180

https://elinux.org/Device_Tree_Mysteries#Signed_Property_Values Apparently dtc allows negative integers?

axelkar avatar Feb 25 '24 13:02 axelkar

The 3rd & 4th blocks are invalid. AFAIK, directives with arguments are supposed to have whitespace.

They are accepted by dtc and I am using them for years...

Whitespaces are simply ignored; e.g.

	a = <23>;
	b=<42>;
	c  =  <666>;

is completely valid. Why should they matter for /delete-.../?

ensc avatar Feb 25 '24 16:02 ensc

They are accepted by dtc and I am using them for years...

Thanks for telling me! I looked at the parser spec but I don't have enough knowledge of tree-sitter to fix it. No idea how it requires whitespace in seq.

axelkar avatar Feb 25 '24 17:02 axelkar