Instead, I’ll leave you with a couple tips that I tend to follow when writing a lexer for Textadept. I won’t try to explain on how to actually make a lexer since the lexer api is so elegantly written and easy to follow. My Rust lexer, which holds EVERY single context and definition of the language, has 92 lines, including whitespace, comments, and formatting I tend to use. The fact that Textadept uses PEGs for language parsing makes writing an entire lexer a breeze. Memoization allows PEGs to parse syntax grammar quite precise with very little to zero redundancy in the interpretation. It is practically built exclusively for the ability. The layman’s reason is that the PEG standard is spectacular powerful in programming language parsing due to memoization. PEGs happen to be a complete joy to use, as opposed to regular expressions(regex), for programming language parsing. However if you want to make something well, do yourself a favor and watch Roberto’s presentation on LPEG(Lua’s PEG interpretation) or take a few moments of your time to read through the LPEG reference manual. All you really have to do is look over the excellently written piece at the API section for lexers on Textadept to get started. In fact, thanks to the extensive abbreviations done for you on Textadept, you can make a lexer without ever knowing much of PEGs. If you never used PEGs, the syntax isn’t hard to learn, but is not even required to know for making lexers on Textadept. What makes Textadept so special in lexer language writing is the fact it uses parsing expression grammar(PEG) for the syntax parsing. As a programmer(commonly known as a person suffering from OCD) it was frustrating to not finish a lexer and I ended up not trying anymore. To give some credit however, many of my tries did get close to what I envisioned for the language lexer, but never did they reach a level I felt comfortable publishing. Yet after a few days(weeks), I end up with a mesh of regular expressions that would become self aware and still not be done with my ‘attempt’ at a new language lexer. It was never because I did not have the ability to do so, but because the process was so darn extravagantly complex for some, it became an annoyance to finish or start them. A few ages ago, before my enlightenment on Textadept, I gained a massive fear of writing language lexers for text editors. What can I say? I love the darn text editor.Ī little back story, again. As to keep things simple, here is part three of what I’m now calling: “The Ever Expanding Series on Textadept Guides, Tips, and Tricks.” Abbreviated as TEESOTGTAT… or humanly understandable, TGTT. It is beginning to look like I will be writing an article on Textadept for the coming weeks or months to come.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |