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.1.tar.gz
(4.2 kB
view details)
Built Distribution
File details
Details for the file python_textmate-0.1.1.tar.gz
.
File metadata
- Download URL: python_textmate-0.1.1.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 | 47f1c2c8b50988ef46eda6a4e41a4bc7c47dc4ed5370134cf3d601c088a818a2 |
|
MD5 | 6bb7c39ecd8793173105a04fd8133661 |
|
BLAKE2b-256 | d29cfa0175fc36025eaa2476d105819aab5000c293e6ee148bf2d52ef8286cf6 |
File details
Details for the file python_textmate-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: python_textmate-0.1.1-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 | ca542793ba6888a80b271833ee6c99815a9907ea682677c7b9b2c4550572ceeb |
|
MD5 | c72550bbdc2b9d67a0bbde2df747f691 |
|
BLAKE2b-256 | e1f9d622ac439010cc0510637653f88261a0e102a1e117f30751b15802dd5ad6 |