File: highlight_ocaml.ml.fold

package info (click to toggle)
kf6-syntax-highlighting 6.13.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 47,568 kB
  • sloc: xml: 197,750; cpp: 12,850; python: 3,023; sh: 955; perl: 546; ruby: 488; pascal: 393; javascript: 161; php: 150; jsp: 132; lisp: 131; haskell: 124; ada: 119; ansic: 107; makefile: 96; f90: 94; ml: 85; cobol: 81; yacc: 71; csh: 62; erlang: 54; sql: 51; java: 47; objc: 37; awk: 31; asm: 30; tcl: 29; fortran: 18; cs: 10
file content (115 lines) | stat: -rw-r--r-- 6,764 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<beginfold id='1'>(*</beginfold id='1'> ocaml test file -- a big stew of Objective Caml syntax to use to
   test Kate's syntax highlighting. This will not run! :-) <endfold id='1'>*)</endfold id='1'>

<beginfold id='1'>(*</beginfold id='1'> First a little piece of real OCaml that should look right: <endfold id='1'>*)</endfold id='1'>

    #load "basic";;
    <beginfold id='1'>(*</beginfold id='1'> Return a default value for a BASIC variable given its identifer. <endfold id='1'>*)</endfold id='1'>
    let default_value (ident : string) : basic_value =
       assert (String.length ident > 0);
       match ident.[String.length ident - 1] with
       | '$' -> Str ""
       | '%' -> Int 0
       | '!' -> Flt 0.0
       | _   -> Flt 0.0
    ;;

<beginfold id='1'>(*</beginfold id='1'> Directives: <endfold id='1'>*)</endfold id='1'>
#load "pa_o";;
  #load "pa_o";;
object # meth ;;  <beginfold id='1'>(*</beginfold id='1'> not a directive - a method call <endfold id='1'>*)</endfold id='1'>
object
   # meth ;;  <beginfold id='1'>(*</beginfold id='1'> not a directive - a method call <endfold id='1'>*)</endfold id='1'>

<beginfold id='1'>(*</beginfold id='1'> OCaml keywords: <endfold id='1'>*)</endfold id='1'>
and as assert asr <beginfold id='1'>(*</beginfold id='1'> etc. there so many... <endfold id='1'>*)</endfold id='1'>

<beginfold id='1'>(*</beginfold id='1'> Additional OCaml Revised Syntax keywords: <endfold id='1'>*)</endfold id='1'>
<beginfold id='1'>(*</beginfold id='1'> These are in a seperate category so they can be coloured to look
   like identifiers when ordinary OCaml syntax is being used: <endfold id='1'>*)</endfold id='1'>
declare where value

<beginfold id='1'>(*</beginfold id='1'> There's no way to reliably highlight all OCaml type expressions,
   (they can be very complex) so just the built-in type names are highlighted.<endfold id='1'>*)</endfold id='1'>
exn lazy_t format unit int float char string ref array bool list option

type poly = [ `A | `BX ]

let _unused = "still an identifier"

let integers : int list = [
    123456789;              <beginfold id='1'>(*</beginfold id='1'> decimal <endfold id='1'>*)</endfold id='1'>
    -0xabcedf0123456789;    <beginfold id='1'>(*</beginfold id='1'> hexadecimal <endfold id='1'>*)</endfold id='1'>
    0xABCDEF0123456789;     <beginfold id='1'>(*</beginfold id='1'> hexadecimal <endfold id='1'>*)</endfold id='1'>
    -0o1234567;             <beginfold id='1'>(*</beginfold id='1'> octal <endfold id='1'>*)</endfold id='1'>
    0b01001010101010;       <beginfold id='1'>(*</beginfold id='1'> binary <endfold id='1'>*)</endfold id='1'>
    -0Xabcedf0123456789;    <beginfold id='1'>(*</beginfold id='1'> hexadecimal <endfold id='1'>*)</endfold id='1'>
    0XABCDEF0123456789;     <beginfold id='1'>(*</beginfold id='1'> hexadecimal <endfold id='1'>*)</endfold id='1'>
    -0O1234567;             <beginfold id='1'>(*</beginfold id='1'> octal <endfold id='1'>*)</endfold id='1'>
    0B01001010101010;       <beginfold id='1'>(*</beginfold id='1'> binary <endfold id='1'>*)</endfold id='1'>
    -123_456_789;           <beginfold id='1'>(*</beginfold id='1'> Underscores are allowed in numeric constants. <endfold id='1'>*)</endfold id='1'>
    0x123n;456L;0o77l;0b11l <beginfold id='1'>(*</beginfold id='1'> int32,int64 and nativeint constants <endfold id='1'>*)</endfold id='1'>
    0x_abce_df01_2345_6789;
    -0o12_34_567;
    0b_0100_1010_1010_1101;
];;

let floats : float list = [
    12345.6789;
    -1.23456789e4;      <beginfold id='1'>(*</beginfold id='1'> All variations of the exponent form <endfold id='1'>*)</endfold id='1'>
    1.23456789e+4;
    -1.23456789e-4;
    1.23456789E-4;
    -1.23456789E+4;
    12_345.6789;       <beginfold id='1'>(*</beginfold id='1'> Underscores are allowed in numeric constants. <endfold id='1'>*)</endfold id='1'>
    -1.23_456_789e+4;
    12_345.6789;
    0x1p-52            <beginfold id='1'>(*</beginfold id='1'> hexadecimal floating-point literals <endfold id='1'>*)</endfold id='1'>
];;

let characters : char list = [
    'a';
    ' ';
    '�';
    '\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'>
    '\000'; '\128';            <beginfold id='1'>(*</beginfold id='1'> Decimal character codes. These are always 3 digits. <endfold id='1'>*)</endfold id='1'>
    '\x02'; '\xff'; '\xFF';    <beginfold id='1'>(*</beginfold id='1'> Hexadecimal character codes. These are always 3 digits. <endfold id='1'>*)</endfold id='1'>
    '\\'; '\''; '\"'; '"'      <beginfold id='1'>(*</beginfold id='1'> Quote character escapes. <endfold id='1'>*)</endfold id='1'>
    ;'\ '; '\o377'
];;

<beginfold id='1'>(*</beginfold id='1'> Quotes used to mark constants in parsers should
   not be confused with character constant quotes.
   "Ticks" at the end of identifiers should
   not be confused with character constant quotes.  <endfold id='1'>*)</endfold id='1'>
let basic_identifier =
  parser
      [< ''F'; ''N'; name = s >] -> ID (s, 'f')
    | [< name = s' >] -> ID (s','i')
;;

let strings : string list = [
    ""; <beginfold id='1'>(*</beginfold id='1'> Empty string <endfold id='1'>*)</endfold id='1'>
    "a"; " ";  "�";   "ab";
    "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'>
    "A\000B"; "A\128B";              <beginfold id='1'>(*</beginfold id='1'> Decimal character codes. These are always 3 digits. <endfold id='1'>*)</endfold id='1'>
    "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'>
    "A\\B"; "A\'B"; "A'B";  "A\"B";  <beginfold id='1'>(*</beginfold id='1'> Quote character escapes. <endfold id='1'>*)</endfold id='1'>
    "A multiline\
    string";
    "\u{207A}"; <beginfold id='1'>(*</beginfold id='1'> Unicode escapes <endfold id='1'>*)</endfold id='1'>
    {|Simple quoted string, we can have " and ' inside, and even {|};
    {another|quoted string|another};
    {foo|More complicated quoted string where we can have {| inside|foo}
];

let camlp4_quotations = [
    <<A Camlp4 source code quotation.>> ;
    <:QUOTE<A labelled Camlp4 source code quotation.>> ;
    <:QU�T�<A labelled Camlp4 source code quotation. (Latin-1 identifier.)>> ;
    << A quote with an escape: \>> (end-quote symbol) >> ;
    << A quote with an escape: \<< (plain start quote-symbol) >> ;
    << A quote with an escape: \<:Trouv�< (labelled start-quote symbol) >> ;
];;

<beginfold id='1'>(*</beginfold id='1'> end <endfold id='1'>*)</endfold id='1'>