This content originally appeared on Krasimir Tsonev - blog and was authored by Krasimir Tsonev - blog
I'm now actively working on a VSCode extension. I started it as a theme but then decided to add some more features. Like for example a tin line on the left side of the editor marking the current function scope. In order to do that I had to analyze the current file's code and find the lines that are included in that scope. The obvious approach will be to translate the code to AST and then traverse the tree finding the information that I need. This however will require the usage of a language server which now I don't want to deal with. So I decided to explore a brute force approach. Looping over the string characters and finding balanced matches. I quickly wrapped it into a library. I called it Pairify. It consumes text and returns an array of pairs. This blog post will show you how it works.
This content originally appeared on Krasimir Tsonev - blog and was authored by Krasimir Tsonev - blog
Krasimir Tsonev - blog | Sciencx (2021-02-07T21:52:55+00:00) Pairify – how to match balanced string pairs. Retrieved from https://www.scien.cx/2021/02/07/pairify-how-to-match-balanced-string-pairs/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.