Warning, /frameworks/syntax-highlighting/autotests/input/highlight_ocaml.ml is written in an unsupported language. File is not indexed.
0001 (* ocaml test file -- a big stew of Objective Caml syntax to use to 0002 test Kate's syntax highlighting. This will not run! :-) *) 0003 0004 (* First a little piece of real OCaml that should look right: *) 0005 0006 #load "basic";; 0007 (* Return a default value for a BASIC variable given its identifer. *) 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 (* Directives: *) 0018 #load "pa_o";; 0019 #load "pa_o";; 0020 object # meth ;; (* not a directive - a method call *) 0021 object 0022 # meth ;; (* not a directive - a method call *) 0023 0024 (* OCaml keywords: *) 0025 and as assert asr (* etc. there so many... *) 0026 0027 (* Additional OCaml Revised Syntax keywords: *) 0028 (* These are in a seperate category so they can be coloured to look 0029 like identifiers when ordinary OCaml syntax is being used: *) 0030 declare where value 0031 0032 (* 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.*) 0034 exn lazy_t format unit int real char string ref array bool list option 0035 0036 0037 let integers : int list = [ 0038 123456789; (* decimal *) 0039 -0xabcedf0123456789; (* hexadecimal *) 0040 0xABCDEF0123456789; (* hexadecimal *) 0041 -0o1234567; (* octal *) 0042 0b01001010101010; (* binary *) 0043 -0Xabcedf0123456789; (* hexadecimal *) 0044 0XABCDEF0123456789; (* hexadecimal *) 0045 -0O1234567; (* octal *) 0046 0B01001010101010; (* binary *) 0047 -123_456_789; (* Underscores are allowed in numeric constants. *) 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; (* All variations of the exponent form *) 0056 1.23456789e+4; 0057 -1.23456789e-4; 0058 1.23456789E-4; 0059 -1.23456789E+4; 0060 12_345.6789; (* Underscores are allowed in numeric constants. *) 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'; (* Control characters. Only these four: not the full C-language range. *) 0070 '\000'; '\128'; (* Decimal character codes. These are always 3 digits. *) 0071 '\x02'; '\xff'; '\xFF'; (* Hexadecimal character codes. These are always 3 digits. *) 0072 '\\'; '\''; '\"'; '"' (* Quote character escapes. *) 0073 ];; 0074 0075 (* 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. *) 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 ""; (* Empty string *) 0087 "a"; " "; "ä"; "ab"; 0088 "A\nB"; "A\rB"; "A\tB"; "A\bB"; (* Control characters. Only these four: not the full C-language range. *) 0089 "A\000B"; "A\128B"; (* Decimal character codes. These are always 3 digits. *) 0090 "A\x02B"; "A\xffB"; "A\xFFB"; (* Hexadecimal character codes. These are always 3 digits. *) 0091 "A\\B"; "A\'B"; "A'B"; "A\"B"; (* Quote character escapes. *) 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 (* end *)