mirror of
https://github.com/CatalaLang/catala.git
synced 2024-09-20 08:47:14 +03:00
gnu gedit syntax highlighting (#336)
This commit is contained in:
commit
19beb91262
49
INSTALL.md
49
INSTALL.md
@ -110,51 +110,4 @@ because it also works with a remote server.
|
||||
|
||||
## Syntax highlighting
|
||||
|
||||
The Catala language also comes with syntax highlighting to
|
||||
ease program development. The syntax highlighting is done
|
||||
with the [Iro](https://eeyo.io/iro/) compiler that allows
|
||||
writing the syntax only once, and then export it to formats
|
||||
understood by various IDE. Currently, two syntax
|
||||
highlighting plugins are under version control.
|
||||
|
||||
### Atom
|
||||
|
||||
To get Catala syntax highlighting in Atom, simply enter from
|
||||
the root of the repository, depending on the language you want to use :
|
||||
|
||||
make atom_fr
|
||||
|
||||
or
|
||||
|
||||
make atom_en
|
||||
|
||||
You can now reload Atom and check that you have syntax highlighting on any `.catala` file.
|
||||
|
||||
### VSCode
|
||||
|
||||
To get Catala syntax highlighting in VSCode, simply enter from
|
||||
the root of the repository, depending on the language you want to use :
|
||||
|
||||
make vscode_fr
|
||||
|
||||
or
|
||||
|
||||
make vscode_en
|
||||
|
||||
You can now reload VSCode and check that you have syntax highlighting on any `.catala` file.
|
||||
|
||||
### Pygments
|
||||
|
||||
Pygments is a Python-based versatile lexer for various
|
||||
programming languages. To use a version of Pygments
|
||||
augmented with the Catala plugin, simply enter
|
||||
|
||||
sudo make pygments
|
||||
|
||||
This will execute the
|
||||
script `syntax_highlighting/fr/pygments/set_up_pygments.sh`,
|
||||
`syntax_highlighting/pl/pygments/set_up_pygments.sh` and
|
||||
`syntax_highlighting/en/pygments/set_up_pygments.sh`.
|
||||
|
||||
The scripts patch your `pigmentize` executable, used for instance by the `minted` LaTeX package.
|
||||
It will now point to the Catala-enabled version with the appropriate `catala_*` lexer.
|
||||
See the [dedicated `README.md`](./syntax_highlighting/README.md).
|
||||
|
62
syntax_highlighting/README.md
Normal file
62
syntax_highlighting/README.md
Normal file
@ -0,0 +1,62 @@
|
||||
# Syntax highlighting
|
||||
|
||||
The Catala language also comes with syntax highlighting to
|
||||
ease program development. The syntax highlighting is done, among other
|
||||
techniques, with the [Iro](https://eeyo.io/iro/) compiler that allows
|
||||
writing the syntax only once, and then export it to formats
|
||||
understood by various IDE.
|
||||
|
||||
**DISCLAIMER:**
|
||||
|
||||
The maintenance of the various syntax highlighting plugins is *BEST-EFFORT*.
|
||||
Indeed many of the plugins were developed by the community and their creators
|
||||
did not commit to long-term maintenance.
|
||||
|
||||
## Atom
|
||||
|
||||
To get Catala syntax highlighting in Atom, simply enter from
|
||||
the root of the repository, depending on the language you want to use :
|
||||
|
||||
make atom_fr
|
||||
|
||||
or
|
||||
|
||||
make atom_en
|
||||
|
||||
You can now reload Atom and check that you have syntax highlighting on any `.catala` file.
|
||||
|
||||
## VSCode
|
||||
|
||||
To get Catala syntax highlighting in VSCode, simply enter from
|
||||
the root of the repository, depending on the language you want to use :
|
||||
|
||||
make vscode_fr
|
||||
|
||||
or
|
||||
|
||||
make vscode_en
|
||||
|
||||
You can now reload VSCode and check that you have syntax highlighting on any `.catala` file.
|
||||
|
||||
## Pygments
|
||||
|
||||
Pygments is a Python-based versatile lexer for various
|
||||
programming languages. To use a version of Pygments
|
||||
augmented with the Catala plugin, simply enter from the root of the repository
|
||||
|
||||
sudo make pygments
|
||||
|
||||
This will execute the
|
||||
script `syntax_highlighting/fr/pygments/set_up_pygments.sh`,
|
||||
`syntax_highlighting/pl/pygments/set_up_pygments.sh` and
|
||||
`syntax_highlighting/en/pygments/set_up_pygments.sh`.
|
||||
|
||||
The scripts patch your `pigmentize` executable, used for instance by the `minted` LaTeX package.
|
||||
It will now point to the Catala-enabled version with the appropriate `catala_*` lexer.
|
||||
|
||||
## GNU gedit
|
||||
|
||||
Copy the file [catala.lang](./gnu_gedit/catala.lang) to the directory below (create if it does not exist) and then restart GEdit.
|
||||
```
|
||||
~/.local/share/gtksourceview-4/language-specs
|
||||
```
|
254
syntax_highlighting/gnu_gedit/catala.lang
Normal file
254
syntax_highlighting/gnu_gedit/catala.lang
Normal file
@ -0,0 +1,254 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<language id="catala" name="Catala" version="2.0" _section="Source">
|
||||
|
||||
<metadata>
|
||||
<property name="mimetypes">text/x-catala</property>
|
||||
<property name="globs">*.catala_en</property>
|
||||
</metadata>
|
||||
|
||||
<styles>
|
||||
<style id="keyword-decl" name="Declaration" map-to="def:constant"/>
|
||||
<style id="keyword-rule" name="Rule" map-to="def:type"/>
|
||||
<style id="keyword-expr" name="Expression" map-to="def:keyword"/>
|
||||
<style id="comment" name="Comment" map-to="def:special-char"/>
|
||||
<style id="primitive" name="Primitive" map-to="def:preprocessor"/>
|
||||
<style id="sc_id" name="Snake-case" map-to="def:identifier"/>
|
||||
<style id="cc_id" name="Camel-case" map-to="def:comment"/>
|
||||
</styles>
|
||||
|
||||
<definitions>
|
||||
|
||||
<context id="codeblock">
|
||||
<start>```catala-metadata|```catala</start>
|
||||
<end>```</end>
|
||||
<include>
|
||||
<context ref="comment"/>
|
||||
<context ref="keyword-decl"/>
|
||||
<context ref="keyword-rule"/>
|
||||
<context ref="keyword-expr"/>
|
||||
<context ref="primitive"/>
|
||||
<context ref="operator"/>
|
||||
<context ref="sc_id"/>
|
||||
<context ref="cc_id"/>
|
||||
</include>
|
||||
</context>
|
||||
|
||||
<context id="comment" style-ref="comment">
|
||||
<start>#</start>
|
||||
<end>$</end>
|
||||
</context>
|
||||
|
||||
<!--Comments below: macro names in lexer_xx.cppo.ml -->
|
||||
|
||||
<context id="keyword-decl" style-ref="keyword-decl">
|
||||
|
||||
<!--DECLARATION-->
|
||||
<keyword>declaration</keyword>
|
||||
|
||||
</context>
|
||||
|
||||
<context id="keyword-rule" style-ref="keyword-rule">
|
||||
|
||||
<!--SCOPE-->
|
||||
<keyword>scope</keyword>
|
||||
|
||||
<!--CONSEQUENCE-->
|
||||
<keyword>consequence</keyword>
|
||||
|
||||
<!--DATA-->
|
||||
<keyword>data</keyword>
|
||||
|
||||
<!--DEPENDS-->
|
||||
<keyword>depends\s+on</keyword>
|
||||
|
||||
<!--CONTEXT-->
|
||||
<keyword>context</keyword>
|
||||
<keyword>上下文</keyword>
|
||||
|
||||
<!--COLLECTION-->
|
||||
<keyword>collection</keyword>
|
||||
|
||||
<!--CONTAINS-->
|
||||
<keyword>contains</keyword>
|
||||
|
||||
<!--ENUM-->
|
||||
<keyword>enumeration</keyword>
|
||||
|
||||
<!--FILLED-->
|
||||
<keyword>fulfilled</keyword>
|
||||
|
||||
<!--DEFINITION-->
|
||||
<keyword>definition</keyword>
|
||||
|
||||
<!--STATE-->
|
||||
<keyword>state</keyword>
|
||||
|
||||
<!--LABEL-->
|
||||
<keyword>label</keyword>
|
||||
|
||||
<!--EXCEPTION-->
|
||||
<keyword>exception</keyword>
|
||||
|
||||
<!--DEFINED_AS-->
|
||||
<keyword>equals</keyword>
|
||||
|
||||
<!--UNDER_CONDITION-->
|
||||
<keyword>under\s+condition</keyword>
|
||||
|
||||
<!--CONDITION-->
|
||||
<keyword>condition</keyword>
|
||||
|
||||
<!--CONTENT-->
|
||||
<keyword>content</keyword>
|
||||
|
||||
<!--STRUCT-->
|
||||
<keyword>structure</keyword>
|
||||
|
||||
<!--ASSERTION-->
|
||||
<keyword>assertion</keyword>
|
||||
|
||||
<!--RULE-->
|
||||
<keyword>rule</keyword>
|
||||
|
||||
<!--INPUT-->
|
||||
<keyword>input</keyword>
|
||||
|
||||
<!--OUTPUT-->
|
||||
<keyword>output</keyword>
|
||||
|
||||
<!--INTERNAL-->
|
||||
<keyword>internal</keyword>
|
||||
|
||||
<!--LAW_INCLUDE-->
|
||||
<keyword>Include</keyword>
|
||||
|
||||
<!--optional-->
|
||||
<keyword>optional</keyword>
|
||||
|
||||
</context>
|
||||
|
||||
<context id="keyword-expr" style-ref="keyword-expr">
|
||||
|
||||
<!--DECREASING-->
|
||||
<keyword>decreasing</keyword>
|
||||
|
||||
<!--INCREASING-->
|
||||
<keyword>increasing</keyword>
|
||||
|
||||
<!--OF-->
|
||||
<keyword>of</keyword>
|
||||
|
||||
<!--MATCH-->
|
||||
<keyword>match</keyword>
|
||||
|
||||
<!--WITH-->
|
||||
<keyword>with\s+pattern</keyword>
|
||||
|
||||
<!--IF-->
|
||||
<keyword>if</keyword>
|
||||
|
||||
<!--THEN-->
|
||||
<keyword>then</keyword>
|
||||
|
||||
<!--ELSE-->
|
||||
<keyword>else</keyword>
|
||||
|
||||
<!--VARIES-->
|
||||
<keyword>varies</keyword>
|
||||
|
||||
<!--WITH_V-->
|
||||
<keyword>with</keyword>
|
||||
|
||||
<!--FOR-->
|
||||
<keyword>for</keyword>
|
||||
|
||||
<!--ALL-->
|
||||
<keyword>all</keyword>
|
||||
|
||||
<!--WE_HAVE-->
|
||||
<keyword>we\s+have</keyword>
|
||||
|
||||
<!--FIXED-->
|
||||
<keyword>fixed</keyword>
|
||||
|
||||
<!--BY-->
|
||||
<keyword>by</keyword>
|
||||
|
||||
<!--LET-->
|
||||
<keyword>let</keyword>
|
||||
|
||||
<!--EXISTS-->
|
||||
<keyword>exists</keyword>
|
||||
|
||||
<!--IN-->
|
||||
<keyword>in</keyword>
|
||||
|
||||
<!--SUCH-->
|
||||
<keyword>such</keyword>
|
||||
|
||||
<!--THAT-->
|
||||
<keyword>that</keyword>
|
||||
|
||||
<!--INIT-->
|
||||
<keyword>initial</keyword>
|
||||
</context>
|
||||
|
||||
<context id="primitive" style-ref="primitive">
|
||||
|
||||
<!--INTEGER-->
|
||||
<keyword>integer</keyword>
|
||||
|
||||
<!--MONEY-->
|
||||
<keyword>money</keyword>
|
||||
|
||||
<!--TEXT-->
|
||||
<keyword>text</keyword>
|
||||
|
||||
<!--DECIMAL-->
|
||||
<keyword>decimal</keyword>
|
||||
|
||||
<!--DATE-->
|
||||
<keyword>date</keyword>
|
||||
|
||||
<!--DURATION-->
|
||||
<keyword>duration</keyword>
|
||||
|
||||
<!--BOOLEAN-->
|
||||
<keyword>boolean</keyword>
|
||||
|
||||
<!--SUM-->
|
||||
<keyword>sum</keyword>
|
||||
|
||||
<!--WILDCARD-->
|
||||
<keyword>anything</keyword>
|
||||
|
||||
<!--CARDINAL-->
|
||||
<keyword>number</keyword>
|
||||
|
||||
</context>
|
||||
|
||||
<context id="operator" style-ref="keyword-expr">
|
||||
<!--for proper matching, do not allow unnecessary spaces in the following regex-->
|
||||
<match>\.|\s((<=|<|>=|>|\+|-|\*|\/)(\$|\@|\^|\.|)?|not|or|xor|and|year|month|day|maximum|minimum|filter|map|true|false|!=|=|--)(\s|$)</match>
|
||||
</context>
|
||||
|
||||
<!-- Snake-case identifiers-->
|
||||
<context id="sc_id" style-ref="sc_id">
|
||||
<match>\b[[:lower:]]([[:lower:]]|[[:upper:]]|[0-9]|_|\')*\b</match>
|
||||
</context>
|
||||
|
||||
<!-- Camel-case identifiers-->
|
||||
<context id="cc_id" style-ref="cc_id">
|
||||
<match>\b[[:upper:]]([[:lower:]]|[[:upper:]]|[0-9]|_|\')*\b</match>
|
||||
</context>
|
||||
|
||||
<!--main context-->
|
||||
<context id="catala">
|
||||
<include>
|
||||
<context ref="codeblock"/>
|
||||
</include>
|
||||
</context>
|
||||
|
||||
</definitions>
|
||||
</language>
|
Loading…
Reference in New Issue
Block a user