-
-
Notifications
You must be signed in to change notification settings - Fork 4
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
Make the tokeniser more useful for other people #12
Comments
Looking at the code, I can confirm that the messaging mechanism of The messaging mechanism of |
Let me elaborate on my conclusions and give some context. The messaging functionality of the tokeniser is used to store warnings about errors encountered while parsing (yes, errors from the parser are stored here). Both However, the vast majority of the calls to the message-appending methods are immediately followed by a There's actually a single place (inside of this library) where a call isn't immediately followed by a mathics-scanner/mathics_scanner/prescanner.py Line 113 in 295fe97
I don't know what's up with that, but since this is the only place where this happens, including the information of the messages in the errors should be safe (we don't really lose any information besides the one concerning this single line of code). It's also worth noting that the messages queues aren't used internally by the feeder at all. The reason why the message qeueu is a property of the feeder is likely that the feeder is shared between the tokeniser and the prescanner, both of which delegate the message-appending calls to the feeder (so it's convenient to place this functionality in there, even though it makes no conceptual sense). |
Please don't make any changes to master like this until we release what we have. Thanks. |
@rocky, are you planning to release this package this week? I think we need at least to ensure that each "syntax error" message raises an exception, in a way that the front ends and the interpreter be able to catch them in real-time. |
Probably over the weekend if I have time.
That can happen in 1.0.1 or 1.1.0 or 2.0, not 1.0.0. The focus here is just what has already been done. You wanted to fix some bugs based on consistency checking and that's been done. I will add some more checks and if there are further bugs in consistency those will be fixed. It is going to be enough work to hook in the existing changes work in mathicsscript's inputrc and use in Mathics. |
I should say that there is plenty of things that can be done that don't cause disruption. For example you could work on a program to generate the readthe docs tables for example. Or go over the readthedocs tutorial. |
While working in #11 it became clear to me that the tokeniser is still very much tied up to internals of Mathics core. For instance, the whole messaging mechanism is completely useless to anyone other us (the developers of Mathics) and it could likely be entirely replaced by simply throwing errors. Also, there are multiple improvements that could be made to make the public interface cleaner and more intuitive.
I propose the following changes:
Tokeniser
andLineFeed
(this will require some refactoring in core)__next__
forTokeniser
by simply calling thenext
methodtag
parameter ofToken(tag, text, pos)
and mark the type of the token by using subclasses ofToken
(i.e.Token("Number", "3", 4)
becomesNumberToken("3", 4)
)incomplete
method: I'd like to remove it (since it's more of an implementation detail than anything else), but it's used in core so we'd had to deal with that too. Even if we don't remove it, we should rename it to something descriptiveIdeally, I'd like to take care of this before the release, since this are breaking changes and therefore would require a major version bump if we were to merge them after the first release. However, I understand that the refactoring required will take some time and therefore I'm OK with doing this after the first release.
I also take full responsibility over this. I can do most of this work on my own if the rest of the contributors aren't interested. @rocky @mmatera Thoughts?
The text was updated successfully, but these errors were encountered: