custom gtksourceview file

Need help with C, C++, perl, python, etc?

custom gtksourceview file

Postby jcress410 » 2010-09-22 13:44

working on a custom gtksourceview .lang file for stata, I've written this thing once before and got it to work... but i have since lost the file... somewhere...

so i'm re writing it. Gedit finds the file and loads it (no errors in term when I switch to a stata .do file) but the syntax isn't highlighting,

in view->highlighting gedit correctly changes the highlight mode to "stata", but the text stays the same color.

I don't know jack taco about xml, so if there's an obvious problem i'm missing, please go easy.. :)

Any help would be appreciated. (i can't figure out how to attach the file... it says extension .lang not allowed and extension .txt not allowed, so i'll copy/paste important parts?)
Code: Select all


<?xml version='1.0' encoding='UTF-8'?>
<language id='do' _name='stata' version='2.0' _section='Scientific'>
<metadata>
<property name="mimetypes">text/x-stata-syntax</property>
<property name='globs'>*.do;*.ado</property>
<property name='block-comment-start'>\*</property>
<property name='block-comment-end'>*/</property>
<property name='line-comment-start'>*</property>
</metadata>


<styles>
<style id='comment' _name='comment' map-to='def:comment'/>
<style id='assignment-operator' _name='Assignment Operator' map-to='def:operator'/>
<style id='string' _name='String' map-to='def:string'/>
<style id='keyword' _name='Keyword' map-to='def:keyword'/>
<style id='function' _name='Function' map-to='def:function'/>
<style id='integer-number' _name='Integer Number' map-to='def:base-n-integer'/>
<style id='macro' _name='macro' map-to='def:macro'/>
</styles>


<definitions>
<context id='macro' end-at-line-end='true' style-ref='macro'>
<start>`</start>
<end>'</end>
</context>
 
<context id='string' end-at-line-end='true' style-ref='string'>
<start>&quot;</start>
<end>&quot;</end>
</context>

<context id='function' style-ref='function'>
<keyword>do</keyword>
<keyword>exit</keyword>
<keyword>shell</keyword>
<keyword>ado</keyword>
<keyword>use</keyword>
<keyword>clear</keyword>
<keyword>preserve</keyword>
<keyword>restore</keyword>
<keyword>joinby</keyword>
<keyword>merge</keyword>
<keyword>append</keyword>
<keyword>cross</keyword>
<keyword>collapse</keyword>
<keyword>contract</keyword>
<keyword>reshape</keyword>
<keyword>erase</keyword>
</context>
 
<context id='delimiters' style-ref='delimiter'>
<match>[\)\(]+|[\{\}]+|[][]+|[&lt;&gt;]</match>
</context>
 
<context id='integer-number' style-ref='integer-number'>
<match extended='true'>
(?&lt;![\w\.])
([1-9][0-9]*|0)[i]?
(?![\w\.])
</match>
</context>
 
<context id='decimal' style-ref='integer-number'>
<match>\b([1-9][0-9]*|0)([Uu]([Ll]|LL|ll)?|([Ll]|LL|ll)[Uu]?)?\b</match>
</context>
 
<context id='floating-point-number' style-ref='integer-number'>
<match>\b([0-9]+[Ee][-]?[0-9]+|([0-9]*\.[0-9]+|[0-9]+\.)([Ee][-]?[0-9]+)?)[fFlL]?</match>
</context>
 
<context id='comment' style-ref='comment' end-at-line-end='true'>
<start>*</start>
</context>
 
<context id='blcomment' style-ref='comment'>
<start>/*</start>
<end>*/</end>
</context>
 
<context id='keyword' style-ref='keyword'>
 ---- A COUPLE THOUSAND LINES REMOVED FOR PASTING ----
</context>

<context id='do'>
<include>
<context ref='def:string'/>
<context ref='def:function'/>
<context ref='def:macro'/>
<context ref='def:delimiters'/>
<context ref='def:integer-number'/>
<context ref='def:decimal'/>
<context ref='def:floating-point-number'/>
<context ref='def:blcomment'/>
<context ref='def:comment'/>
<context ref='def:keyword'/>
</include>
</context>

</definitions>
</language>

jcress410
 
Posts: 39
Joined: 2010-09-21 18:13

Re: custom gtksourceview file

Postby jcress410 » 2010-09-22 22:45

nevermind, i figured it out.

I actually wrote a program in stata that generated the .lang file... which i think is kind of funny in its recursion...

So, the .lang file is in the zip file attached if anyone else is running stata/gedit on 'nix,

it also includes the .do file which generated it, and a version of thankful eyes i modified for the occasion.
Attachments
stata lang.zip
(8.6 KiB) Downloaded 490 times
jcress410
 
Posts: 39
Joined: 2010-09-21 18:13


Return to Programming

Who is online

Users browsing this forum: No registered users and 5 guests

fashionable