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

Easier way to check these modes against an existing codebase? #30

Open
mtaran-google opened this issue Aug 28, 2017 · 1 comment
Open

Comments

@mtaran-google
Copy link
Contributor

Some cases where these modes currently fail require human review, e.g. when they highlight something in one way but another way is expected. But in a lot of cases I've been seeing, the highlighting just breaks for a while and then starts working again later. This leaves even keywords like void totally unhighlighted. For these modes to be considered fully working, I believe this kind of condition should not occur (at least in "reasonable" code, but ideally in all properly compiling code). But currently I don't get any exceptions or log messages in the console when this happens.

It'd be a lot easier for me to report this type of bug to you if I could just run the CodeMirror mode parser over some existing code and have it report when it got into an unparseable situation. The manual way would be to have this in some web browser window, automatic would be if I could run a small node app that just reads a set of file paths/glob/list of directories/whatever., and it would print out some error messages when it runs into this case.

Does that sound like something feasible? Or does it already exist somewhere and I just haven't looked in the right places?

@marijnh
Copy link
Member

marijnh commented Aug 28, 2017

If you set verbose to 1 in mode.js in the grammar-mode package, that'll output something to the console when the matcher's error-recovery kicks in, but that will also happen for cases where the recovery actually works well, so it's probably not what you're looking for. In general the grammars simply don't aim to be 100% complete, at least not for nightmare grammars like C++'s, where an approximation that works well in practice is really all I dare to aim for.

So I can't really think of a clean way to automatically detect this, except by using heuristics for obviously wrong output or indentation.

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

2 participants