CyberShadow / tree-sitter-d

17 stars 6 forks source link

incorrect alias_assign instead of assign_expression #9

Open FabArd opened 1 year ago

FabArd commented 1 year ago

Hi,

I am testing syntax highlighting with tree-sitter under emacs (tree-sitter + tree-sitter-langs emacs packages). I made a test with the following file : dmledit.d

I found several incorrect alias_assign delarations :

52        popupMenu = editPopupItem;
...
131        tb = res.getOrAddToolbar("Standard");
...
134        tb = res.getOrAddToolbar("Edit");
...
156        _filename = filename;
...
291            msg = replaceFirst(msg, " near `", "\nnear `");
...
337        _editor = new DMLSourceEdit();
...
368            auto widgetClassName = widgetsList.selectedItem;
...
374        _preview = new ScrollWidget();

It seems that a rule has been forgotten concerning alias_assign as mentionned at (https://dlang.org/spec/template.html#TemplateDeclaration) 'AliasAssign' must be declared in a template :

The AliasAssign and its corresponding AliasDeclaration must both be declared in the same [TemplateDeclaration].

CyberShadow commented 1 year ago

Thanks for filing this. The grammar is incorrect:

https://dlang.org/spec/declaration.html#Declaration

However, AliasAssign cannot appear inside a function (where it would be ambiguous with an assign expression.