[gtksourceview] Add Solidity language definition



commit 7c96532dfc2cf24a6142e98804db56f9a87e397d
Author: MohamedLEGH <mohamed amine legheraba gmail com>
Date:   Wed Oct 31 12:31:25 2018 +0100

    Add Solidity language definition

 data/language-specs/Makefile.am   |   1 +
 data/language-specs/solidity.lang | 321 ++++++++++++++++++++++++++++++++++++++
 po/POTFILES.skip                  |   1 +
 3 files changed, 323 insertions(+)
---
diff --git a/data/language-specs/Makefile.am b/data/language-specs/Makefile.am
index 92afe3f2..6862cfda 100644
--- a/data/language-specs/Makefile.am
+++ b/data/language-specs/Makefile.am
@@ -118,6 +118,7 @@ LANGUAGES =                 \
        scss.lang               \
        sh.lang                 \
        sml.lang                \
+       solidity.lang           \
        sparql.lang             \
        sql.lang                \
        sweave.lang             \
diff --git a/data/language-specs/solidity.lang b/data/language-specs/solidity.lang
new file mode 100644
index 00000000..edece35c
--- /dev/null
+++ b/data/language-specs/solidity.lang
@@ -0,0 +1,321 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ This file is part of GtkSourceView
+
+ Authors: Mohamed Amine LEGHERABA
+ Copyright (C) 2018 Mohamed Amine LEGHERABA <mlegheraba protonmail com>
+ 
+ based on c.lang file
+ Copyright (C) 2005-2007 Marco Barisione <barisione gmail com>
+ Copyright (C) 2005-2007 Emanuele Aina
+
+ 
+ GtkSourceView is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ GtkSourceView is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this library; if not, see <http://www.gnu.org/licenses/>.
+
+-->
+<language id="solidity" name="Solidity" version="2.0" _section="Source">
+  <metadata>
+    <property name="globs">*.sol;*.solidity</property>
+    <property name="line-comment-start">//</property>
+    <property name="block-comment-start">/*</property>
+    <property name="block-comment-end">*/</property>
+  </metadata>
+
+  <styles>
+    <style id="comment"           name="Comment"               map-to="def:comment"/>
+    <style id="string"            name="String"                map-to="def:string"/>
+    <style id="preprocessor"      name="Preprocessor"          map-to="def:preprocessor"/>
+    <style id="common-defines"    name="Common Defines"        map-to="def:special-constant"/>
+    <style id="char"              name="Character"             map-to="def:character"/>
+    <style id="keyword"           name="Keyword"               map-to="def:keyword"/>
+    <style id="reserved"          name="Reserved"              map-to="def:error"/>
+    <style id="type"              name="Data Type"             map-to="def:type"/>
+    <style id="escaped-character" name="Escaped Character"     map-to="def:special-char"/>
+    <style id="floating-point"    name="Floating point number" map-to="def:floating-point"/>
+    <style id="decimal"           name="Decimal number"        map-to="def:decimal"/>
+    <style id="hexadecimal"       name="Hexadecimal number"    map-to="def:base-n-integer"/>
+    <style id="boolean"           name="Boolean value"         map-to="def:boolean"/>
+    <style id="error"             name="Error"                 map-to="def:error"/>
+    <style id="properties"        name="Properties"            map-to="def:statement"/>
+    <style id="function"          name="Function"              map-to="def:builtin"/>
+    <style id="module-handler"    name="Module Handler"        map-to="def:preprocessor"/>
+  </styles>
+
+  <definitions>
+
+    <!--regexs-->
+    <define-regex id="escaped-character" extended="true">
+      \\(                   # leading backslash
+      [\\\"\'nrbtfav\?] |   # escaped character
+      [0-7]{1,3} |          # one, two, or three octal digits
+      x[0-9A-Fa-f]+         # 'x' followed by hex digits
+      )
+    </define-regex>
+
+    <!--contexts used on the main context-->
+    <!-- Preprocessor instructions -->
+
+    <context id="pragma" style-ref="preprocessor">
+      <keyword>pragma</keyword>
+      <keyword>solidity</keyword>
+    </context>
+
+
+    <context id="pragma-number" style-ref="floating-point">
+      <keyword>(\d+\.)(\d+\.)(\d+)</keyword>
+    </context>
+
+    <!-- instructions to importe other solidity files -->
+
+    <context id="module-handler" style-ref="module-handler">
+      <keyword>import</keyword>
+      <keyword>from</keyword>
+      <keyword>as</keyword>
+    </context>
+
+    <context id="string" style-ref="string" end-at-line-end="true" class="string" 
class-disabled="no-spell-check">
+      <start>L?"</start>
+      <end>"</end>
+      <include>
+        <context id="escaped-character" style-ref="escaped-character">
+          <match>\%{escaped-character}</match>
+        </context>
+        <context ref="def:line-continue"/>
+      </include>
+    </context>
+
+    <context id="char" style-ref="char" class="string">
+      <match>L?'(\%{escaped-character}|.)'</match>
+    </context>
+
+    <!-- http://www.lysator.liu.se/c/ANSI-C-grammar-l.html -->
+    <context id="float" style-ref="floating-point">
+      <match extended="true">
+        (?&lt;![\w\.])
+        ((\.[0-9]+ | [0-9]+\.[0-9]*) ([Ee][+-]?[0-9]*)? |
+         ([0-9]+[Ee][+-]?[0-9]*))
+        [fFlL]?
+        (?![\w\.])
+      </match>
+    </context>
+
+    <context id="hexadecimal" style-ref="hexadecimal">
+      <match extended="true">
+        (?&lt;![\w\.])
+        0[xX][a-fA-F0-9]+[uUlL]*
+        (?![\w\.])
+      </match>
+    </context>
+
+    <context id="invalid-hexadecimal" style-ref="error">
+      <match extended="true">
+        (?&lt;![\w\.])
+        0[xX][a-fA-F0-9]*[g-zG-Z][a-zA-Z0-9]*[uUlL]*
+        (?![\w\.])
+      </match>
+    </context>
+
+    <context id="decimal" style-ref="decimal">
+      <match extended="true">
+        (?&lt;![\w\.])
+        (0|[1-9][0-9]*)[uUlL]*
+        (?![\w\.])
+      </match>
+    </context>
+
+    <context id="keywords" style-ref="keyword">
+      <keyword>anonymous|indexed</keyword>
+      <keyword>assembly</keyword>
+      <keyword>assert|require|revert</keyword>
+      <keyword>break</keyword>
+      <keyword>case</keyword>
+      <keyword>constructor</keyword>
+      <keyword>continue</keyword>
+      <keyword>constant|payable|pure|view</keyword>
+      <keyword>contract|interface|library</keyword>
+      <keyword>default</keyword>
+      <keyword>delete</keyword>
+      <keyword>do</keyword>
+      <keyword>else</keyword>
+      <keyword>emit</keyword>
+      <keyword>enum</keyword>
+      <keyword>event</keyword>
+      <keyword>external|internal|private|public</keyword>
+      <keyword>for</keyword>
+      <keyword>function</keyword>
+      <keyword>new</keyword>
+      <keyword>if</keyword>
+      <keyword>is</keyword>
+      <keyword>let</keyword>
+      <keyword>mapping</keyword>
+      <keyword>memory|storage</keyword>
+      <keyword>modifier</keyword>
+      <keyword>return</keyword>
+      <keyword>returns</keyword>
+      <keyword>struct</keyword>
+      <keyword>super</keyword>
+      <keyword>switch</keyword>
+      <keyword>this</keyword>
+      <keyword>throw</keyword>
+      <keyword>using</keyword>
+      <keyword>var</keyword>
+      <keyword>while</keyword>
+    </context>
+
+    <context id="reserved" style-ref="reserved">
+      <keyword>abstract</keyword>
+      <keyword>after</keyword>
+      <keyword>catch</keyword>
+      <keyword>final</keyword>
+      <keyword>in</keyword>
+      <keyword>inline</keyword>
+      <keyword>match</keyword>
+      <keyword>of</keyword>
+      <keyword>relocatable</keyword>
+      <keyword>static</keyword>
+      <keyword>try</keyword>
+      <keyword>type</keyword>
+      <keyword>typeof</keyword>
+    </context>
+
+    <context id="properties" style-ref="properties">
+      <keyword>now</keyword>
+      <keyword>length</keyword>
+      <keyword>push</keyword>
+      <keyword>pop</keyword>
+    </context>
+
+    <context id="propertiesAddress" style-ref="properties">
+      <prefix>\.</prefix>
+      <keyword>balance</keyword>
+      <keyword>call</keyword>
+      <keyword>callcode</keyword>
+      <keyword>delegatecall</keyword>
+      <keyword>gas</keyword>
+      <keyword>send</keyword>
+      <keyword>transfer</keyword>
+      <keyword>value</keyword>
+    </context>
+
+    <context id="propertiesBlock" style-ref="properties">
+      <prefix>(block)\.</prefix>
+      <keyword>coinbase</keyword>
+      <keyword>difficulty</keyword>
+      <keyword>gaslimit</keyword>
+      <keyword>number</keyword>
+      <keyword>timestamp</keyword>
+    </context>
+
+
+    <context id="propertiesMsg" style-ref="properties">
+      <prefix>(msg)\.</prefix>
+      <keyword>data</keyword>
+      <keyword>gas</keyword>
+      <keyword>sender</keyword>
+      <keyword>sig</keyword>
+      <keyword>value</keyword>
+    </context>
+
+    <context id="propertiesTx" style-ref="properties">
+      <prefix>(tx)\.</prefix>
+      <keyword>gasprice</keyword>
+      <keyword>origin</keyword>
+    </context>
+
+    <context id="types" style-ref="type">
+      <keyword>address</keyword>
+      <keyword>bool</keyword>
+      <keyword>byte(s(3[0-2]|[0-2]?[1-9]))?</keyword>
+      <keyword>bytes</keyword>
+      <keyword>string</keyword>
+      
<keyword>u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?</keyword>
+      
<keyword>u?fixed((8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)x(80|[0-7]?[0-9]))?</keyword>
+    </context>
+
+    <!-- C99 booleans -->
+    <context id="boolean" style-ref="boolean">
+      <keyword>true</keyword>
+      <keyword>false</keyword>
+    </context>
+
+    <context id="common-defines" style-ref="common-defines">
+      <keyword>seconds</keyword>
+      <keyword>minutes</keyword>
+      <keyword>hours</keyword>
+      <keyword>days</keyword>
+      <keyword>weeks</keyword>
+      <keyword>years</keyword>
+      <keyword>wei</keyword>
+      <keyword>finney</keyword>
+      <keyword>szabo</keyword>
+      <keyword>ether</keyword>
+    </context>
+
+    <context id="functions" style-ref="function">
+      <keyword>addmod</keyword>
+      <keyword>blockhash</keyword>
+      <keyword>ecrecover</keyword>
+      <keyword>gasleft</keyword>
+      <keyword>keccak256</keyword>
+      <keyword>mulmod</keyword>
+      <keyword>ripemd160</keyword>
+      <keyword>selfdestruct</keyword>
+      <keyword>sha256</keyword>
+      <keyword>sha3</keyword>
+    </context>
+
+    <context id="functionsABI" style-ref="function">
+      <prefix>(abi)\.</prefix>
+      <keyword>decode</keyword>
+      <keyword>encode</keyword>
+      <keyword>encodePacked</keyword>
+      <keyword>encodeWithSelector</keyword>
+      <keyword>encodeWithSignature</keyword>
+    </context>
+    
+    <!--Main context-->
+    <context id="solidity" class="no-spell-check">
+      <include>
+        <context ref="gtk-doc:inline-docs-section"/>
+        <context ref="def:c-like-comment" style-ref="comment"/>
+        <context ref="def:c-like-comment-multiline" style-ref="comment"/>
+        <context ref="def:c-like-close-comment-outside-comment" style-ref="comment"/>
+        <context ref="pragma"/>
+        <context ref="pragma-number"/>
+        <context ref="string"/>
+        <context ref="char"/>
+        <context ref="float"/>
+        <context ref="hexadecimal"/>
+        <context ref="invalid-hexadecimal"/>
+        <context ref="decimal"/>
+        <context ref="keywords"/>
+        <context ref="reserved"/>
+        <context ref="types"/>
+        <context ref="boolean"/>
+        <context ref="common-defines"/>
+        <context ref="properties"/>
+        <context ref="propertiesAddress"/>
+        <context ref="propertiesBlock"/>
+        <context ref="propertiesMsg"/>
+        <context ref="propertiesTx"/>
+        <context ref="functions"/>
+        <context ref="functionsABI"/>
+        <context ref="module-handler"/>
+      </include>
+    </context>
+
+  </definitions>
+</language>
+
diff --git a/po/POTFILES.skip b/po/POTFILES.skip
index d2a4466b..fac31266 100644
--- a/po/POTFILES.skip
+++ b/po/POTFILES.skip
@@ -122,6 +122,7 @@ data/language-specs/scilab.lang
 data/language-specs/scss.lang
 data/language-specs/sh.lang
 data/language-specs/sml.lang
+data/language-specs/solidity.lang
 data/language-specs/sparql.lang
 data/language-specs/sql.lang
 data/language-specs/sweave.lang


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]