]> git.mdlowis.com Git - projs/tide.git/commitdiff
basic highlighting for ocaml
authorMichael D. Lowis <mike@mdlowis.com>
Tue, 29 Aug 2017 02:41:25 +0000 (22:41 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Tue, 29 Aug 2017 02:41:25 +0000 (22:41 -0400)
tide-hl.rb

index fa887a89370e7b593adbffbcd6d0de3129cf6b4b..0cc6f09eb53a699567fa288e7dee4f66b4b2d947 100755 (executable)
@@ -102,8 +102,9 @@ end
 #-------------------------------------------------------------------------------
 
 languages({
-  "Ruby" => Set.new(%w[Rakefile Rakefile.rb .rb gpkgfile]),
-  "C"    => Set.new(%w[.c .h .cpp .hpp .cc .c++ .cxx]),
+  "Ruby"   => Set.new(%w[Rakefile Rakefile.rb .rb gpkgfile]),
+  "C"      => Set.new(%w[.c .h .cpp .hpp .cc .c++ .cxx]),
+  "OCaml" => Set.new(%w[.ml .mli]),
 })
 
 language "C" do
@@ -151,6 +152,24 @@ language "Ruby" do
   match /[0-9]+/, :Number
 end
 
+language "OCaml" do
+  keywords = Set.new %w[
+    and as assert begin class constraint do done downto else end exception
+    external for fun function functor if in include inherit initializer lazy
+    let match method module mutable new object of open or private rec sig struct
+    then to try type val virtual when while with
+  ]
+  constants = Set.new %w[true false ]
+  range start=/\(\*/, stop=/\*\)/, :Comment
+  match /"(\\"|[^"\n])*"/, :String
+  match /'(\\'|[^'\n])*'/, :String
+  match /[A-Z][0-9a-zA-Z_]*/, :Type
+  match_sets /[a-z_][0-9a-zA-Z_]*/, :Keyword => keywords, :Constant => constants
+  match /0x[0-9a-fA-F]+/, :Number
+  match /[0-9]+/, :Number
+  match /\(\)/, :Constant
+end
+
 #-------------------------------------------------------------------------------
 
 # bail if theres nothing to highlight