TextMate grammar parser for python
Project description
TextMate grammar parser for python
Install
pip install python-textmate
Usage
The parser can parse one line, to parse multiple lines iterate over each line and call parse()
>>> from textmate import TextMateGrammar
>>> import json
>>> code = "print(True) # the parser only parses one line."
>>> with open("MagicPython.tmLanguage.json", "r") as tm:
... grammar = TextMateGrammar(json.load(tm))
... print(grammar.parse("print(True)"))
...
[('constant.language.python', (6, 10)),
('punctuation.parenthesis.begin.python', (5, 6)),
('punctuation.parenthesis.end.python', (10, 11)),
('constant.language.python', (6, 10)),
('punctuation.definition.arguments.end.python', (10, 11)),
('meta.function-call.python', (0, 11)),
('keyword.illegal.name.python', (6, 10)),
('support.function.builtin.python', (0, 5)),
('meta.function-call.generic.python', (0, 5)),
('support.function.builtin.python', (0, 5))]
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
python_textmate-0.1.0.tar.gz
(4.2 kB
view details)
Built Distribution
File details
Details for the file python_textmate-0.1.0.tar.gz
.
File metadata
- Download URL: python_textmate-0.1.0.tar.gz
- Upload date:
- Size: 4.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.10.11 Linux/6.9.3-76060903-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6870098a99fd700c1101d4b95982ceba5210bb0067d23315788c48ad56135503 |
|
MD5 | c2de9877cf3d6a8adc3d779e81ef410a |
|
BLAKE2b-256 | ada6761aefe4bcfb5893fe7114651a48073ed5cd285c4860c7e2e8054eb5ba97 |
File details
Details for the file python_textmate-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: python_textmate-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.10.11 Linux/6.9.3-76060903-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2a884135e99234bfbb2af329ba4bb82e87e7763225c42b891c92dd103ea50017 |
|
MD5 | 00d1e9be8d0f785bc848152614555b8b |
|
BLAKE2b-256 | 21f2962859e8090c87068873a08ec6f744d0f17c779f9897d2a6cd84933ee1bd |