Warning, file /frameworks/syntax-highlighting/autotests/html/highlight_ocaml.ml.html was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 <!DOCTYPE html> 0002 <html><head> 0003 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> 0004 <title>highlight_ocaml.ml</title> 0005 <meta name="generator" content="KF5::SyntaxHighlighting - Definition (Objective Caml) - Theme (Breeze Light)"/> 0006 </head><body style="background-color:#ffffff;color:#1f1c1b"><pre> 0007 <span style="color:#898887;">(* ocaml test file -- a big stew of Objective Caml syntax to use to</span> 0008 <span style="color:#898887;"> test Kate's syntax highlighting. This will not run! :-) *)</span> 0009 0010 <span style="color:#898887;">(* First a little piece of real OCaml that should look right: *)</span> 0011 0012 <span style="color:#006e28;">#load "basic";;</span> 0013 <span style="color:#898887;">(* Return a default value for a BASIC variable given its identifer. *)</span> 0014 <span style="font-weight:bold;">let</span> default_value (ident : <span style="color:#0057ae;">string</span>) : basic_value = 0015 <span style="font-weight:bold;">assert</span> (<span style="color:#0057ae;font-style:italic;">String</span>.length ident > <span style="color:#b08000;">0</span>); 0016 <span style="font-weight:bold;">match</span> ident.[<span style="color:#0057ae;font-style:italic;">String</span>.length ident - <span style="color:#b08000;">1</span>] <span style="font-weight:bold;">with</span> 0017 | <span style="color:#924c9d;">'$'</span> -> <span style="font-style:italic;">Str</span> <span style="color:#bf0303;">""</span> 0018 | <span style="color:#924c9d;">'%'</span> -> <span style="font-style:italic;">Int</span> <span style="color:#b08000;">0</span> 0019 | <span style="color:#924c9d;">'!'</span> -> <span style="font-style:italic;">Flt</span> <span style="color:#b08000;">0.0</span> 0020 | _ -> <span style="font-style:italic;">Flt</span> <span style="color:#b08000;">0.0</span> 0021 ;; 0022 0023 <span style="color:#898887;">(* Directives: *)</span> 0024 <span style="color:#006e28;">#load "pa_o";;</span> 0025 <span style="color:#006e28;">#load "pa_o";;</span> 0026 <span style="font-weight:bold;">object</span> # meth ;; <span style="color:#898887;">(* not a directive - a method call *)</span> 0027 <span style="font-weight:bold;">object</span> 0028 # meth ;; <span style="color:#898887;">(* not a directive - a method call *)</span> 0029 0030 <span style="color:#898887;">(* OCaml keywords: *)</span> 0031 <span style="font-weight:bold;">and</span> <span style="font-weight:bold;">as</span> <span style="font-weight:bold;">assert</span> <span style="font-weight:bold;">asr</span> <span style="color:#898887;">(* etc. there so many... *)</span> 0032 0033 <span style="color:#898887;">(* Additional OCaml Revised Syntax keywords: *)</span> 0034 <span style="color:#898887;">(* These are in a seperate category so they can be coloured to look</span> 0035 <span style="color:#898887;"> like identifiers when ordinary OCaml syntax is being used: *)</span> 0036 declare where value 0037 0038 <span style="color:#898887;">(* There's no way to reliably highlight all OCaml type expressions,</span> 0039 <span style="color:#898887;"> (they can be very complex) so just the built-in type names are highlighted.*)</span> 0040 <span style="color:#0057ae;">exn</span> <span style="color:#0057ae;">lazy_t</span> format <span style="color:#0057ae;">unit</span> <span style="color:#0057ae;">int</span> <span style="color:#0057ae;">real</span> <span style="color:#0057ae;">char</span> <span style="color:#0057ae;">string</span> <span style="color:#0057ae;">ref</span> <span style="color:#0057ae;">array</span> <span style="color:#0057ae;">bool</span> <span style="color:#0057ae;">list</span> <span style="color:#0057ae;">option</span> 0041 0042 0043 <span style="font-weight:bold;">let</span> integers : <span style="color:#0057ae;">int</span> <span style="color:#0057ae;">list</span> = [ 0044 <span style="color:#b08000;">123456789</span>; <span style="color:#898887;">(* decimal *)</span> 0045 <span style="color:#b08000;">-0xabcedf0123456789</span>; <span style="color:#898887;">(* hexadecimal *)</span> 0046 <span style="color:#b08000;">0xABCDEF0123456789</span>; <span style="color:#898887;">(* hexadecimal *)</span> 0047 <span style="color:#b08000;">-0o1234567</span>; <span style="color:#898887;">(* octal *)</span> 0048 <span style="color:#b08000;">0b01001010101010</span>; <span style="color:#898887;">(* binary *)</span> 0049 <span style="color:#b08000;">-0Xabcedf0123456789</span>; <span style="color:#898887;">(* hexadecimal *)</span> 0050 <span style="color:#b08000;">0XABCDEF0123456789</span>; <span style="color:#898887;">(* hexadecimal *)</span> 0051 <span style="color:#b08000;">-0O1234567</span>; <span style="color:#898887;">(* octal *)</span> 0052 <span style="color:#b08000;">0B01001010101010</span>; <span style="color:#898887;">(* binary *)</span> 0053 <span style="color:#b08000;">-123_456_789</span>; <span style="color:#898887;">(* Underscores are allowed in numeric constants. *)</span> 0054 <span style="color:#b08000;">0x_abce_df01_2345_6789</span>; 0055 <span style="color:#b08000;">-0o12_34_567</span>; 0056 <span style="color:#b08000;">0b_0100_1010_1010_1101</span>; 0057 ];; 0058 0059 <span style="font-weight:bold;">let</span> floats : <span style="color:#0057ae;">real</span> <span style="color:#0057ae;">list</span> = [ 0060 <span style="color:#b08000;">12345.6789</span>; 0061 <span style="color:#b08000;">-1.23456789e4</span>; <span style="color:#898887;">(* All variations of the exponent form *)</span> 0062 <span style="color:#b08000;">1.23456789e+4</span>; 0063 <span style="color:#b08000;">-1.23456789e-4</span>; 0064 <span style="color:#b08000;">1.23456789E-4</span>; 0065 <span style="color:#b08000;">-1.23456789E+4</span>; 0066 <span style="color:#b08000;">12_345.6789</span>; <span style="color:#898887;">(* Underscores are allowed in numeric constants. *)</span> 0067 <span style="color:#b08000;">-1.23_456_789e+4</span>; 0068 <span style="color:#b08000;">12_345.6789</span>; 0069 ];; 0070 0071 <span style="font-weight:bold;">let</span> characters : <span style="color:#0057ae;">char</span> <span style="color:#0057ae;">list</span> = [ 0072 <span style="color:#924c9d;">'a'</span>; 0073 <span style="color:#924c9d;">' '</span>; 0074 <span style="color:#924c9d;">'�'</span>; 0075 <span style="color:#924c9d;">'\n'</span>; <span style="color:#924c9d;">'\r'</span>; <span style="color:#924c9d;">'\t'</span>; <span style="color:#924c9d;">'\b'</span>; <span style="color:#898887;">(* Control characters. Only these four: not the full C-language range. *)</span> 0076 <span style="color:#924c9d;">'\000'</span>; <span style="color:#924c9d;">'\128'</span>; <span style="color:#898887;">(* Decimal character codes. These are always 3 digits. *)</span> 0077 <span style="color:#924c9d;">'\x02'</span>; <span style="color:#924c9d;">'\xff'</span>; <span style="color:#924c9d;">'\xFF'</span>; <span style="color:#898887;">(* Hexadecimal character codes. These are always 3 digits. *)</span> 0078 <span style="color:#924c9d;">'\\'</span>; <span style="color:#924c9d;">'\''</span>; <span style="color:#924c9d;">'\"'</span>; <span style="color:#924c9d;">'"'</span> <span style="color:#898887;">(* Quote character escapes. *)</span> 0079 ];; 0080 0081 <span style="color:#898887;">(* Quotes used to mark constants in parsers should</span> 0082 <span style="color:#898887;"> not be confused with character constant quotes.</span> 0083 <span style="color:#898887;"> </span><span style="color:#898887;font-weight:bold;">"Ticks"</span><span style="color:#898887;"> at the end of identifiers should</span> 0084 <span style="color:#898887;"> not be confused with character constant quotes. *)</span> 0085 <span style="font-weight:bold;">let</span> basic_identifier = 0086 <span style="font-weight:bold;">parser</span> 0087 [< '<span style="color:#924c9d;">'F'</span>; '<span style="color:#924c9d;">'N'</span>; name = s >] -> <span style="font-style:italic;">ID</span> (s, <span style="color:#924c9d;">'f'</span>) 0088 | [< name = s' >] -> <span style="font-style:italic;">ID</span> (s',<span style="color:#924c9d;">'i'</span>) 0089 ;; 0090 0091 <span style="font-weight:bold;">let</span> strings : <span style="color:#0057ae;">string</span> <span style="color:#0057ae;">list</span> = [ 0092 <span style="color:#bf0303;">""</span>; <span style="color:#898887;">(* Empty string *)</span> 0093 <span style="color:#bf0303;">"a"</span>; <span style="color:#bf0303;">" "</span>; <span style="color:#bf0303;">"�"</span>; <span style="color:#bf0303;">"ab"</span>; 0094 <span style="color:#bf0303;">"A</span><span style="color:#924c9d;">\n</span><span style="color:#bf0303;">B"</span>; <span style="color:#bf0303;">"A</span><span style="color:#924c9d;">\r</span><span style="color:#bf0303;">B"</span>; <span style="color:#bf0303;">"A</span><span style="color:#924c9d;">\t</span><span style="color:#bf0303;">B"</span>; <span style="color:#bf0303;">"A</span><span style="color:#924c9d;">\b</span><span style="color:#bf0303;">B"</span>; <span style="color:#898887;">(* Control characters. Only these four: not the full C-language range. *)</span> 0095 <span style="color:#bf0303;">"A</span><span style="color:#924c9d;">\000</span><span style="color:#bf0303;">B"</span>; <span style="color:#bf0303;">"A</span><span style="color:#924c9d;">\128</span><span style="color:#bf0303;">B"</span>; <span style="color:#898887;">(* Decimal character codes. These are always 3 digits. *)</span> 0096 <span style="color:#bf0303;">"A</span><span style="color:#924c9d;">\x02</span><span style="color:#bf0303;">B"</span>; <span style="color:#bf0303;">"A</span><span style="color:#924c9d;">\xff</span><span style="color:#bf0303;">B"</span>; <span style="color:#bf0303;">"A</span><span style="color:#924c9d;">\xFF</span><span style="color:#bf0303;">B"</span>; <span style="color:#898887;">(* Hexadecimal character codes. These are always 3 digits. *)</span> 0097 <span style="color:#bf0303;">"A</span><span style="color:#924c9d;">\\</span><span style="color:#bf0303;">B"</span>; <span style="color:#bf0303;">"A</span><span style="color:#924c9d;">\'</span><span style="color:#bf0303;">B"</span>; <span style="color:#bf0303;">"A'B"</span>; <span style="color:#bf0303;">"A</span><span style="color:#924c9d;">\"</span><span style="color:#bf0303;">B"</span>; <span style="color:#898887;">(* Quote character escapes. *)</span> 0098 <span style="color:#bf0303;">"A multiline</span><span style="color:#924c9d;">\</span> 0099 <span style="color:#bf0303;"> string"</span>; 0100 ]; 0101 0102 <span style="font-weight:bold;">let</span> camlp4_quotations = [ 0103 <span style="color:#bf0303;"><<A Camlp4 source code quotation.>></span> ; 0104 <span style="color:#bf0303;"><:QUOTE<A labelled Camlp4 source code quotation.>></span> ; 0105 <:<span style="font-style:italic;">QU</span>�<span style="font-style:italic;">T</span>�<<span style="font-style:italic;">A</span> labelled <span style="font-style:italic;">Camlp4</span> source code quotation. (<span style="font-style:italic;">Latin</span><span style="color:#b08000;">-1</span> identifier.)>> ; 0106 <span style="color:#bf0303;"><< A quote with an escape: </span><span style="color:#924c9d;">\>></span><span style="color:#bf0303;"> (end-quote symbol) >></span> ; 0107 <span style="color:#bf0303;"><< A quote with an escape: </span><span style="color:#924c9d;">\<<</span><span style="color:#bf0303;"> (plain start quote-symbol) >></span> ; 0108 <span style="color:#bf0303;"><< A quote with an escape: \<:Trouv�< (labelled start-quote symbol) >></span> ; 0109 ];; 0110 0111 <span style="color:#898887;">(* end *)</span> 0112 </pre></body></html>