-
Notifications
You must be signed in to change notification settings - Fork 63
/
unit-lex.ml
115 lines (103 loc) · 1.64 KB
/
unit-lex.ml
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
(* -*- encoding: iso-8859-1 -*- *)
(** ocaml lexical conventions
(http://caml.inria.fr/pub/docs/manual-ocaml/lex.html)
*)
(*
*** literals ***
*)
(* identifiers *)
let _id,
iD',
I9,
_'i,
A_',
u',
éçèæùà (* this file must be iso-8859-1 *)
=
_
;;
(* intergers *)
let _ =
-1
+ 0
+ 10_
+ -0xAFfe_0 + 0X1_
+ 0O7_0_1_2 + -0o12__
- 0B0_1_0 + -0b111_
;;
(* floats *)
let _ =
0. +.
0.0 +.
0e12 +.
0.e1_ +.
999e+1 +.
-9_99_E-0 +.
-.12. +.
0_._e-1_2
;;
(* chars *)
[ 'a';
'&';
'Ç';
'§';
'\\';
'\"';
'\'';
'\b';
'\234';
'\999'; (* wrong, but yet... *)
'\xAF' ]
;;
(* strings *)
let _ = "'a';\n\
\ '&';\
'Ç';\
'§';\
'\\';\
'\"';\
'\'';\
'\b';\
'\234';\
'\999'; (* wrong, but yet... *)\
'\xAF'"
;;
(* naming labels *)
val f :
_l1 : int ->
? _' : float ->
'a
let rec f
~ _l1 : int
? _' : float =
f ~_l1: 0 ?_': 0e1
;;
(* prefix and infix symbols *)
_ = _
<:~ _
> _
@ _
^$ _
%%
;;
!! ( ????: _ )
(* keywords *)
(* don't care about indentation, just should'nt crash :) *)
and as assert asr begin class
constraint do done downto else end
exception external false for fun function
functor if in include inherit initializer
land lazy let lor lsl lsr
lxor match method mod module mutable
new object of open or private
rec sig struct then to true
try type val virtual when while
with
;;
(* line number directives *)
(* should be ignored and not indented: we may still want to indent generated
code for readability *)
#9999 "bla.ml\ \n\999"
let _ =
#9999 "bla.ml\ \n\999"
0