Repository navigation
feat: a Python highlighting grammar - #227
Merged
Merged
Conversation
lang.xon declares (grammar python (module python/syntax) ...): .py, .pyw and .pyi files and the python and python3 interpreters, so vi and any other x/tool/syntax user colour Python with x-python installed. The line painter's Lexer rules move to python/lexer.x, which imports x-lang libraries only; the painter and the grammar both read them. python/syntax classes names as the painter does -- keywords, True/False/None as constants, builtins, capitalised names as classes -- from its own copy of the interpreter's keyword and builtin lists, which C0-syntax holds equal. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
x-python declares a highlighting grammar in lang.xon, the way x-ash's
shand x-make'smakedo:With x-python installed, vi's
:set sy(and every other x/tool/syntax user) colours Python files: by suffix, by a#!line naming python or python3, or by a modeline.name), then a capitalised name as a class. A decorator is a keyword. Brackets,,.:;are punctuation; other plain bytes are operators. A window syncs back to a line starting at column 0 with a name,#or@.python-lexer-rules; no other change.A small known cost, my call: the Lexer appends a space to each read, so a blank run at the very end of the text is not a token and the
anyrule hands the trailing newline over asplain. The grammar gives a plain blank byte no class, so it draws nothing; the painter is unchanged.Local, v0.44.0: C0-syntax 5/5 and 09-line 7/7 pass;
lang-kit lint --strictis clean on both new modules. python/line.x keeps the 3providefindings main already has.🤖 Generated with Claude Code