IDE : un peu de coloration syntaxique

parent a493d3a4
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE language SYSTEM "language.dtd">
<language _name="Objective Caml" version="1.0" _section="Sources" mimetypes="text/x-ocaml">
<escape-char>\</escape-char>
<block-comment _name = "Comment" style= "Comment" end-at-line-end = "FALSE">
<start-regex>\(\*[^)]</start-regex>
<end-regex>\*\)</end-regex>
</block-comment>
<pattern-item _name = "Decimal" style = "Decimal">
<regex>\b[-]?[0-9][0-9_]*[lL]?\b</regex>
</pattern-item>
<pattern-item _name = "Hex Number" style = "Base-N Integer">
<regex>\b[-]?0[xX][0-9A-Fa-f][0-9A-Fa-f_]*[lL]?\b</regex>
</pattern-item>
<pattern-item _name = "Octal Number" style = "Base-N Integer">
<regex>\b[-]?0[oO][0-7][0-7_]*[lL]?\b</regex>
</pattern-item>
<pattern-item _name = "Binary Number" style = "Base-N Integer">
<regex>\b[-]?0[bB][01][01_]*[lL]?\b</regex>
</pattern-item>
<pattern-item _name = "Floating Point Number" style = "Floating Point">
<regex>\b[-]?[0-9][0-9_]*(\.[0-9_]*)?([Ee][+-]?[0-9][0-9_]*)?</regex>
</pattern-item>
<string _name = "Character Constant" style = "String" end-at-line-end = "TRUE">
<start-regex>&apos;</start-regex>
<end-regex>&apos;</end-regex>
</string>
<string _name = "String" style = "String" end-at-line-end = "FALSE">
<start-regex>&quot;</start-regex>
<end-regex>&quot;</end-regex>
</string>
<pattern-item _name = "Modules" style = "Data Type" case-sensitive="TRUE">
<regex>\b[A-Z][A-Za-z0-9_']*</regex>
</pattern-item>
<keyword-list _name = "Definition keyword" style = "Keyword" case-sensitive="TRUE">
<keyword>theory</keyword>
<keyword>end</keyword>
<keyword>use</keyword>
<keyword>clone</keyword>
<keyword>namespace</keyword>
<keyword>import</keyword>
<keyword>export</keyword>
<keyword>inductive</keyword>
<keyword>logic</keyword>
<keyword>axiom</keyword>
<keyword>lemma</keyword>
<keyword>goal</keyword>
<keyword>type</keyword>
</keyword-list>
<keyword-list _name = "Expression keyword" style = "Keyword" case-sensitive="TRUE">
<keyword>match</keyword>
<keyword>let</keyword>
<keyword>in</keyword>
<keyword>if</keyword>
<keyword>then</keyword>
<keyword>else</keyword>
</keyword-list>
<keyword-list _name = "Types" style = "Data Type" case-sensitive="TRUE">
<keyword>int</keyword>
<keyword>real</keyword>
</keyword-list>
</language>
......@@ -44,6 +44,19 @@ let fname = match !file with
| Some f ->
f
let lang =
let file =
List.fold_right Filename.concat
[Filename.dirname Sys.argv.(0); ".."; "share"; "lang"] "why.lang"
in
if Sys.file_exists file then
let languages_manager = GSourceView.source_languages_manager () in
GSourceView.source_language_from_file ~languages_manager file
else begin
Format.eprintf "could not find lang file (%S)@.";
None
end
let text =
let ic = open_in fname in
let size = in_channel_length ic in
......@@ -170,6 +183,11 @@ let main () =
()
in
source_view#misc#modify_font_by_name font_name;
begin match lang with
| Some lang -> source_view#source_buffer#set_language lang
| None -> ()
end;
source_view#source_buffer#set_highlight true;
source_view#source_buffer#set_text text;
w#add_accel_group accel_group;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment