Warning, /frameworks/syntax-highlighting/autotests/folding/highlight_ocaml.ml.fold is written in an unsupported language. File is not indexed.

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