-
Notifications
You must be signed in to change notification settings - Fork 64
Improved parser and other stuff #18
base: master
Are you sure you want to change the base?
Conversation
Fix range bugs. Add Classes to handle entries in the tmbundles correctly. Extend tests.
no more prints and more tight matching
Some of the grammar regexes are not valid in CocoaLand.
Soft tabs is the way to go (and the default in xcode, afaik).
This change adds updatedRangeForChange to the parser and implements a ScopedString class to store all the scope information. Most other changes are tests for the new functionality or minor consistency changes.
now recursive structures and the like are read into the datastructure
Firstly this should clear up some confusion about scopes. In this project scope means some form of lexical scope (basically what is between the begin and end pattern) while what TextMate calles scope selectors or scope for short is now called patternIdentifier or identifier for short. A scope is now also a type of result. Added test for the range extensions. The parser now returns the range that definitely has to be parsed but parses further if it has to. Turns out the range cannot be determined without actually parsing the new string so this seems to be a good tradeoff.
It would be awesome if this could be merged. |
In the meantime you can just use the fork. |
@soffes any plans on merging this in? |
Any progress on this? |
Nope, I decided the current state was good enough (backreferences are usually used to recognize languages embedded within other languages, which usually slows parsing down quite a bit). Also for this you would have to match the begin and end part at the same time which is kind of tricky to implement. If you want to have a go at this, PR's are always welcome. |
Yes, of course. Lua uses this syntax: (Multiline Comment) (Multiline String) I am working on an iOS Lua Editor, your work really helped me a lot! |
You are welcome! Yes, this is another use of back-references. I see how this can be useful. If you want to implement this, your best bet is probably to combine the |
Swift 4 version
This also uses all the latest swiftlint rules.
@alehed I've got a question (or five), partner! When using For instance, in all of the examples below, assume the following is true:
Given
In these situations, does one "break down" the replacement operation into its sub-operations? What about the first case, where the string has had no change in length? Does one re-parse the string in its entirety? As far as background information goes, I simply have a custom If none of this makes sense, please let me know, and I'll try my best to expound on or simplify my question(s). Basically, I just want to know how best to handle the “replacement” aspect of the incremental parsing operation, rather than raw insertion/deletion scenarios. Thanks! P.S. Your changes to the base SyntaxKit are badass, and they've been a great help to me! |
Hi @benstockdesign, glad you like it. Replacement is quite simple, first you delete then you insert. Firstly, this model is simple and always works. Secondly, since the library depends on Foundation and UIKit it is designed to integrate well with the rest of UIKit. For instance If you observe a different behavior by NSTextStorage, please let me know. |
@alehed Okay, that clears things up. I was just never sure. Oh, wait, one last question: what about in |
@benstockdesign according to my experience user edits are never coalesced, correct me if I'm wrong. If you are doing edits programmatically either do all the changes in succession, or maybe it is faster to just reload the whole thing once in the end. You might want to write a performance test for that. The underlying class is |
This should fix #5 and make the framework usable for production.
Uses or closes #5, #10, #11, #15 and #16.
Major changes
The last two changes might be a bit polarizing. The reationale behind them is to make it easier for new people to contribute. Setting up the environment for a new project is always a big hurdle for adoption. If you want to invite people to play around with your framework, make it as simple as possible to go from git clone to a project that builds (and where tests pass). Like this it builds out of the box with no dependencies. Also, the current default in Xcode is soft tabs (4 spaces), so a new user will not mess up the spacing if he uses a clean install of Xcode.
Caveats
There are however a few things that still don't work as expected. Feel free to improve upon this.
Due to differences between Onigurama and NSRegularExpression:
\G
is not supported (for performance reasons the parser does not guarantee to match the end of a pattern right after begin, and even if it would,\G
behaves wierdly with NSRegularExpression). This might be fixable.end
tobegin
like\1
are not supported (I would like to know how Texmate does this).Not implemented:
BundleManager
). Fixable with extra logic.Notes
Since I don't use Carthage or CocoaPods, some work probably still has to be done that is plays well with them. Any help would be appreciated.