ruuda / pris

A language for designing slides

Home Page:https://docs.ruuda.nl/pris/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Syntax highlighting

ruuda opened this issue · comments

It would be nice to have syntax highlighting for Pris source files.

Syntax details

A good starting point is the Bison grammar in etc/pris.y. The Pris parser uses a different implementation (in src/lexer.rs and src/parser.rs), but the two should be in sync. The Bison file is used to check that the grammar remains sensible. The tokens defined at the top, together with the string literals (for keywords and suffixes) are all the tokens, and those should be sufficient for syntax highlighting.

Formats

  • Vim
  • Kate
  • Emacs
  • TextMate
  • Sublime Text (covered by TextMate?)
  • GitHub Linguist (covered by TextMate?)
  • Atom (similar to TextMate?)
  • VS Code (preliminary version in etc/vscode)
  • Pygments

I will take care of Vim and Kate myself when I find the time. (Vim is my editor of choice, and Pandoc — which powers my blog — uses highlighting-kate.)

Hello,

Here is what I managed to get after playing a little with syntax highlighting in VS Code:
pris-color-vscode

What do you think?

That is awesome!

I apologise for not keeping this issue up to date, the parser has been replaced since I opened this issue. The lexer is still in src/lexer.rs (now permalink), but the simlicity of the token stream is probably clouded by the code. I should write some docs about it. Apart from the Rust parser, there is a Bison grammar in etc/pris.y that should match the Rust implementation. The tokens defined at the top there, together with the literals, are all existing tokens, and that should be sufficient for syntax highlighting.

If you like to contribute VS Code highlighting support here (even an incomplete version would be nice, at the moment we have nothing), we can put the required files in etc/vscode in the repository. If I understand correctly, a VS Code highlighting extension includes a language-configuration.json file, and then a metadata file for the extension?