Blog Setup - Implementation 2018-07-08

By Max Woerner Chase

In this post:

Okay, I should summarize what I did before the last post.

There were some things that I want to do sometime, but it wasn't a big deal currently:

I also started hacking on copies of the syntax files for Python and reStructuredText. (I can't... find the latter in my syntax picker, not from Sublime? Where did the file go?) I made varying amounts of progress on various areas, and some observations:

For some reason, I'm testing the syntax file and the highlighting on the blog publisher script. I guess it's just because it's there.

One thing I haven't looked into is assigning expression scopes to the inside of type annotation strings.

The big thing I haven't gotten working, and the whole reason I went down this rabbit hole in the first place, is assigning a scope to every identifier so I can highlight them. One thing I noticed while figuring out what's needed (basically, identifiers can be divided into some that are only legal at the top level in an expression context, and everything else, which is also legal at the top level, but can also appear in the top level at the left-hand side of an assignment statement, as a class or function name, as a named parameter or argument, and as the target of an as keyword.) is that, even though functions are supposed to have a particular scope when they're called, this isn't actually possible to accomplish in all circumstances. In a multi-line expression, you can put a line break before the open parenthesis, and, near as I can tell, the syntax highlighter is powerless to handle this scenario. This doesn't matter in most practical circumstances, and it doesn't matter for what I want to do, but it's kind of bothersome that the recommended scoping behavior seemingly cannot be guaranteed using the scoping engine.

Looking at how this does, I think I'll just try to preserve the existing behavior as much as possible, on the logic that it's good enough for the official syntax, and do the stuff I want on top of it.

That basically consists of:

The main obstacle I have is, I feel like I need to better understand the 50+ contexts defined in the syntax file before I can figure out how to pervasively insert my proposed categorization of names. I think I'll take a break for now, and come back to this later.

(One other tweak that just occurred to me is to have the docstring contexts in the reStructuredText syntax delegate inline literals back to Python. Also, I'm not sure that this syntax has scopes for doctests. I think it should. Need to go over the reStructuredText syntax definition and compare it to what this syntax provides.)

Next time, I wrap this project up.