Open joeced opened 4 months ago
Hi @joeced @apozharski
Good to see that this is being picked up.
Regarding the output of textmate grammars, there are two issues:
Anyhow, this will still be an ongoing project of mine. Let's keep in touch.
I have opened a PR against MATLAB-Language-grammar that (mostly, within the limitations of textmate grammars) addresses this issue: https://github.com/mathworks/MATLAB-Language-grammar/pull/88
Your example A slightly more complex example:
classdef (AllowedSubclasses = {?SubClass1,?SubClass2}, Hidden=true) SuperClass < foo ...
& bar
end
would now be parsed as:
{'token': 'meta.class.declaration.matlab',
'children': [{'token': 'storage.modifier.section.class.matlab',
'children': [{'token': 'storage.modifier.class.matlab', 'content': 'AllowedSubclasses'},
{'token': 'keyword.operator.assignment.matlab', 'content': '='},
{'token': 'meta.cell.literal.matlab',
'begin': [{'token': 'punctuation.section.braces.begin.matlab', 'content': '{'}],
'end': [{'token': 'punctuation.section.braces.end.matlab', 'content': '}'}],
'children': [{'token': 'keyword.operator.other.question.matlab', 'content': '?'},
{'token': 'variable.other.readwrite.matlab', 'content': 'SubClass1'},
{'token': 'punctuation.separator.comma.matlab', 'content': ','},
{'token': 'keyword.operator.other.question.matlab', 'content': '?'},
{'token': 'variable.other.readwrite.matlab', 'content': 'SubClass2'}]},
{'token': 'punctuation.separator.modifier.comma.matlab', 'content': ','},
{'token': 'storage.modifier.class.matlab', 'content': 'Hidden'},
{'token': 'keyword.operator.assignment.matlab', 'content': '='},
{'token': 'constant.language.boolean.matlab', 'content': 'true'}]},
{'token': 'entity.name.type.class.matlab', 'content': 'SuperClass'},
{'token': 'punctuation.separator.lt.inheritance.matlab', 'content': '<'},
{'token': 'meta.inherited-class.matlab', 'children': [{'token': 'entity.other.inherited-class.matlab', 'content': 'foo'}]},
{'token': 'meta.continuation.line.matlab', 'children': [{'token': 'punctuation.separator.continuation.line.matlab', 'content': '...'}]},
{'token': 'keyword.operator.type.matlab', 'content': '&'},
{'token': 'meta.inherited-class.matlab', 'children': [{'token': 'entity.other.inherited-class.matlab', 'content': 'bar'}]}]}
I started working with textmate-grammar-python for the https://github.com/sphinx-contrib/matlabdomain package. Thanks for starting this work - it's much more structured than the pygments tokens.
Given this MATLAB class definition
is parsed to these tokens with
textmate-grammar-python==0.6.0
:As one can see, we are missing:
{
/}
.SubClass1
?
in front ofSubClass1
andSubClass2
.