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

Replace MATLAB's smart indent function #75

Open
mriesch-tum opened this issue Oct 17, 2019 · 3 comments
Open

Replace MATLAB's smart indent function #75

mriesch-tum opened this issue Oct 17, 2019 · 3 comments

Comments

@mriesch-tum
Copy link
Contributor

First of all, thank you for this project! Until yesterday I was not aware that such a formatter exists and spent some time formatting things manually. This project really makes things easier!

Problem: The issues #51 and #74 already mention that it would be very nice to run the script without the MATLAB editor dependence. For automated tasks (pre-commit hooks, CI, ...) this is crucial as there might not be the possibility to run a GUI. For a large number of files this may be beneficial for the performance. Apparently, the only dependency is the smart indentation function which must be replaced. The replacement could also deal with indentation issues such as #52 .

Approach 1: Write a MATLAB function that can replace MATLAB's smart indent function. As announced in #74, I played around and ended up with a simple indentation code which I would like to share (for what it is worth).

Approach 2: Implement the same thing in Java, as the project is about to be rewritten. May I ask what the status of the Java version is?

@davidvarga
Copy link
Owner

tl;dr :)

Unfortunately I have quite limited time to open source and for Stack Overflow in the last several (or many of them:) ) months.
Status with the Java version is what I found in my local repo is that it works for a limited amount of features but I had hard times with the indentation.

It ran also through my mind that maybe I should write a full parser (an AntrlR grammar) and implement the full functionality based on the parse tree (did for several standards in the every day job ofime). Advantage: based on the parser any possible feature (that do not require the classpath) can be implemented easily and bullet proof. Disadvantage: time effort.

Personally I don't think that a fully reliable intent functionality can be implemented without a parser - an acceptably okay one is possible. Apart from that many feature that nearly imppssible with the current implementation could get a green light with the parser, currently implemented ones coupd be implemented in an elegant fashion and one of the most important thing: with a Java/Kotlin implementation I could fire up continous testing for a minimal fee (financing a MATLAB license from my own pocket is not something that I want to do for this project ... :) )

So an Antlr grammar based parser written in Kotlin compiled to Java6 code would be the way to go in my opinion.

@mriesch-tum
Copy link
Contributor Author

I agree, a full parser is required. Also, I understand that your time budget is limited, no apologies required here :-) Is there some Java code available on GitHub already? Maybe there are some people who are willing to help.

As to pull request #76, consider it as quick-and-dirty fix to bridge the time until the Java version is ready. Maybe someone can extend or use it.

davidvarga added a commit that referenced this issue Oct 23, 2019
Replaces MATLAB's smart indent functionality with self written code #75.
@florianschanda
Copy link

@mriesch-tum and @davidvarga I have managed to write a fully working MATLAB lexer and parser (https://github.com/florianschanda/miss_hit), and I plan to write down the formal grammar sometime soon.

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

No branches or pull requests

3 participants