Skip to main content

Framework for generating editor syntax files

Project description

python-hilite-syntax

This package allows you to generate syntax-highlighting files from input files (like bnf grammar files). The goal is to enable generation of syntax highlighting files for any language specification on the fly, for all editors

Supported Frontends

  • lark: use lark grammar files (for the LALR parser only) to generate the syntax file for the language the grammar is parsing.
    • see lark-parser for more info on writing lark grammar files
    • see lark-syntax.vim for syntax-highlighting of your lark files in vim
    • see python-shape-plotter-example for several things:
      1. writing a simple LALR lark grammar file
      2. using hilite_syntax to convert lark grammar files to vim syntax and viewing your DSL scripts with color in vim
      3. plotting 2D shapes using matplotlib from the lark DSL file

Supported Backends

  • vim: generate vim syntax highlighting files for the input language.
    • by default, it will write the syntax and ftdetect files to $HOME/.vim, so you can instantly use the generated files, but you can change the output dir
    • pointers to related items:
    • see lark-syntax.vim for highlighting lark grammar files in vim
    • see python-shape-plotter-example for the reasons mentioned in lark above

installing

pip install hilite_syntax

command-line usage

  • help: the subcommand to dump the IR graph of your langauge:

    hilite_syntax help <frontend> [frontend-args]
    hilite_syntax help <backend> [backend-args]
    

    You must run the help commands for each frontend or backend to see what their supported arguments are.

  • dump: the subcommand to dump the IR graph of your langauge, after being parsed by the frontend:

    hilite_syntax dump <frontend> [frontend-args]
    
  • input/output: the subcommand to convert the input to an output syntax highlighting file:

    hilite_syntax input <frontend> [frontend-args] output <backend> [backend-args] 
    

    for example, the following will convert a lark grammar file and install vim syntax files for it at $HOME/.vim:

    hilite_syntax input lark ./mydsl.lark --start root_rule \
                  output vim mydsl --ext mydsl --ext dsl
    

TODO: put up a docs page for the cmdline usage (and subcmds)

library usage

Most of the package lives in the hilite_syntax library, and can be used directly in your application.

TODO: put up a docs page for library usage

internal architecture

TODO: describe lark-specific details, vim-specific details, the intermediate graph representation, and the supported semantic FormatTypes

OTHER TODO

clean up documenting these potential issues:

  1. regex node sementics need to be supported by input AND output implementation. if only the input supports it, an error will occur

    • for example: lark -> vim DOES support regex and string terms
  2. string terminals MIGHT not be supported in output. any backend implementation should specify the supported strings

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

hilite_syntax-0.0.4.tar.gz (22.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hilite_syntax-0.0.4-py3-none-any.whl (18.1 kB view details)

Uploaded Python 3

File details

Details for the file hilite_syntax-0.0.4.tar.gz.

File metadata

  • Download URL: hilite_syntax-0.0.4.tar.gz
  • Upload date:
  • Size: 22.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.6.8

File hashes

Hashes for hilite_syntax-0.0.4.tar.gz
Algorithm Hash digest
SHA256 b9123559bb2180bc13adee5cf67ffcde89921d8fc5b8a2b7d44310d39815975d
MD5 cc1c7458e3ecc60323c99ec1e0951243
BLAKE2b-256 3f08b4d54d7217c2455f30d22c8122a892a82bbd993b727d8e410347a895a635

See more details on using hashes here.

File details

Details for the file hilite_syntax-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: hilite_syntax-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 18.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.6.8

File hashes

Hashes for hilite_syntax-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 489124e491224774c414dc036f447e2ec023eb5173524cc3f74a0708857ec09f
MD5 4bd4ebd05293e79971511770f7094ddd
BLAKE2b-256 edf84b1436054c71a16492b9d7707546fd0f92daf15306720106b1700bdeb089

See more details on using hashes here.

Supported by

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