Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Further improvements to textmate based parser #258

Conversation

apozharski
Copy link
Collaborator

@apozharski apozharski commented Jul 19, 2024

Better classdef attributes and validator function parsing based on improvements to MATLAB-language-grammar in:

and a textmate-grammar-python pr which bumps the MATLAB-language-grammar (which will be created once Mathworks pulls in the improvements).

Further improvements:

  • parsing docstrings for functions

@joeced
Copy link
Collaborator

joeced commented Jul 23, 2024

The tests, (see https://github.com/sphinx-contrib/matlabdomain/actions/runs/10058995696/job/27803269388?pr=258#step:4:106) are failing as setup.py does not require the textmate grammar package.

@apozharski
Copy link
Collaborator Author

Yep I have just been running pytest locally to get through the true errors. Unfortunately it looks like there are fundamental problems with the textmate grammar that I am not sure are solvable due to the limitations of the textmate grammar. In particular the syntax for multiline defaults is I believe unparseable. @watermarkhu I am unsure if you have any insights that I do not here.

An example of the problem:

prop = [1;
              2;
              3]; % a prop

in which one cannot unambiguously identify which of the ; actually ends the property default.

@joeced
Copy link
Collaborator

joeced commented Jul 23, 2024

It's ok for the test to fail for now. We'll get there eventually. For the default value of properties the current code starts here:

if self._tk_eq(idx, (Token.Punctuation, "=")):
and uses more than 50 lines to collect it. I hope that textmate grammar can do it in less :)

@watermarkhu
Copy link

Yep I have just been running pytest locally to get through the true errors. Unfortunately it looks like there are fundamental problems with the textmate grammar that I am not sure are solvable due to the limitations of the textmate grammar. In particular the syntax for multiline defaults is I believe unparseable. @watermarkhu I am unsure if you have any insights that I do not here.

An example of the problem:

prop = [1;
              2;
              3]; % a prop

in which one cannot unambiguously identify which of the ; actually ends the property default.

There are two ways to tackle this.

  1. Further edits to the MATLAB grammar: The MATLAB grammar can be further improved to catch these cases. In this case, we can add a dummy newline scope to the array and cell scopes.

  2. Pre-parser:. Similar to the current case, there is MATLAB's line continuations ..., which is allowed to be inserted almost anywhere. I started on adding the line-continuation scope to places that I encountered them, but there are many, many more.

    Just for the sake of getting the tokens, I added a pre-parser to simply remove line-continuations from the source file. While this method is far from ideal, it is another possibility.

@apozharski
Copy link
Collaborator Author

This is replaced with #261

@apozharski apozharski closed this Sep 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants