Skip to main content

Tokenize code snippets.

Project description

Tokenize-All

Tokenize blocks of code in Python. Used by manim-code-blocks to syntax highlight blocks of code.

Example Usage

from tokenize_all import Java

tokens = Java.tokenize(
    """
    public class Main {
        public static void main(String[] args) {
            System.out.println("Hello world!");
        }
    }
    """
)

for token in tokens: print(token)

Output:

>> Token[ type = keyword, value = public, start = 4, end = 10 ]
>> Token[ type = keyword, value = class, start = 11, end = 16 ]
>> Token[ type = class name, value = Main, start = 17, end = 21 ]
>> Token[ type = left brace, value = {, start = 22, end = 23 ]
>> Token[ type = keyword, value = public, start = 31, end = 37 ]
>> Token[ type = keyword, value = static, start = 38, end = 44 ]
>> Token[ type = keyword, value = void, start = 45, end = 49 ]
>> Token[ type = function, value = main, start = 50, end = 54 ]
>> Token[ type = left parentheses, value = (, start = 54, end = >> 55 ]
>> Token[ type = class name, value = String, start = 55, end = >> 61 ]
>> Token[ type = left bracket, value = [, start = 61, end = 62 ]
>> Token[ type = right bracket, value = ], start = 62, end = 63 ]
>> Token[ type = identifier, value = args, start = 64, end = 68 ]
>> Token[ type = right parentheses, value = ), start = 68, end = >> 69 ]
>> Token[ type = left brace, value = {, start = 70, end = 71 ]
>> Token[ type = class name, value = System, start = 83, end = >> 89 ]
>> Token[ type = dot, value = ., start = 89, end = 90 ]
>> Token[ type = identifier, value = out, start = 90, end = 93 ]
>> Token[ type = dot, value = ., start = 93, end = 94 ]
>> Token[ type = function, value = println, start = 94, end = >> 101 ]
>> Token[ type = left parentheses, value = (, start = 101, end = >> 102 ]
>> Token[ type = string, value = "Hello world!", start = 102, >> end = 116 ]
>> Token[ type = right parentheses, value = ), start = 116, end >> = 117 ]
>> Token[ type = semicolon, value = ;, start = 117, end = 118 ]
>> Token[ type = right brace, value = }, start = 126, end = 127 ]
>> Token[ type = right brace, value = }, start = 131, end = 132 ]

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

tokenize_all-1.0.5.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

tokenize_all-1.0.5-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file tokenize_all-1.0.5.tar.gz.

File metadata

  • Download URL: tokenize_all-1.0.5.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.4

File hashes

Hashes for tokenize_all-1.0.5.tar.gz
Algorithm Hash digest
SHA256 99eb0295a3bd8c6fb6cbe11cab8fec5f5dfb5ad0fbcd283327069256c5d83d3c
MD5 9722ec64208b16971441b8a9fe34f5f9
BLAKE2b-256 3a2281a7daa8b85e871720c40d1ce15883ace3cbbb5eb7302479b8d1edbfd2f1

See more details on using hashes here.

File details

Details for the file tokenize_all-1.0.5-py3-none-any.whl.

File metadata

File hashes

Hashes for tokenize_all-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 df0c843a3556378a51ca9a806271a5af9d76c8ddaa5aeac0ac1ad00a320d070f
MD5 9b5ac4b87d3e994b16bea4a56cbfb858
BLAKE2b-256 5b3edb33dd586f9204a604a2890acf50b3a028cb1e4c9a056bce3a27a131279f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page