garazdawi / grammar

TextMate grammar (also used by VS Code) for the Erlang programming language

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Erlang Grammar

TextMate grammar (also used by Visual Studio Code) for the Erlang programming language.

Credits

The grammar has been forked from the original Erlang TextMate bundle:

https://github.com/textmate/erlang.tmbundle

The original license stated:

Permission to copy, use, modify, sell and distribute this
software is granted. This software is provided "as is" without
express or implied warranty, and with no claim as to its
suitability for any purpose.

The reason of the fork is twofold:

  • The original Erlang grammar was not actively maintained and response times for Pull Requests were long.
  • The grammar can be included in isolation in the VS Code extension

License

The current repository is licensed under the Apache License 2.0. Please refer to the LICENSE file for details.

Lazy Guide

According Visual Studio Code Syntax Highlight Guide:

As a grammar grows more complex, it can become difficult to understand and maintain it as json. If you find yourself writing complex regular expressions or needing to add comments to explain aspects of the grammar, consider using yaml to define your grammar instead.

Yaml grammars have the exact same structure as a json based grammar but allow you to use yaml's more concise syntax, along with features such as multi-line strings and comments.

VS Code can only load json [or plist] grammars, so yaml based grammars must be converted to json [or plist].

To work easier with TextMate YAML language files install VSCode extension e.g. TextMate Languages from Ben Hockley.

  • Use commands "Convert to YAML-tmLanguage file" and "Convert to tmLanguage file" provided by extension TextMate Languages.

  • Alternatively download grahampugh/plist-yaml-plist from Github and use below commands: (On Windows use e.g. WSL)

    /path/to/plist_yaml.py Erlang.plist Erlang.yaml
    # Edit YAML file here ... then if you are ready convert back to PLIST
    /path/to/yaml_plist.py Erlang.yaml Erlang.plist

Commit your updates on Erlang.plist and ignode Erlang.yaml.

To test the grammar we use VSCode Textmate grammar test, simply run npm ci && npm test and all tests will be run. To add more tests you can either add annotated files to ./tests/ or use the snapshot facility and then tests should be added to ./test/snap.

See more:

  1. Visual Studio Code Syntax Highlight Guide
  2. TextMate Language Grammars
  3. Writing a TextMate Grammar: Some Lessons Learned
  4. Building a syntax highlighting extension for VS Code

About

TextMate grammar (also used by VS Code) for the Erlang programming language

License:Apache License 2.0


Languages

Language:Erlang 100.0%