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.2.tar.gz
(4.2 kB
view details)
Built Distribution
File details
Details for the file python_textmate-0.1.2.tar.gz
.
File metadata
- Download URL: python_textmate-0.1.2.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 | 22dc08ca192096086393c989aab84e876ffbabceab41c519f12a4dd93c35f2fa |
|
MD5 | c2ed8e1c9740b0f4ad37bafcae8f744f |
|
BLAKE2b-256 | c5ad57a83ed3004db0c3aa97491c2d269a6b36ae80b4ab3868ae3995359242cb |
File details
Details for the file python_textmate-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: python_textmate-0.1.2-py3-none-any.whl
- Upload date:
- Size: 6.1 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 | c838bb6c50e85742b21bb376f5e90d498afdaa9752b71a19e7470b207613d000 |
|
MD5 | 368edd710dcee426be2b24cb0735e4b8 |
|
BLAKE2b-256 | 3c38ac28852e4dcbae0f5055866d234f649d9243c3ea11b746429738bd28e440 |