Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 40 lines (29 sloc) 1.014 kB
fccc685 Initial open-source release
MLstate authored
1 open Ocaml
2 open Tgrammar
3
4 type pt_type =
5 | PT_Record of (string * pt_type option) list
6 | PT_ListTuple of pt_type list
7 | PT_String of string
8 | PT_Char of char
9 | PT_Int of int
10 | PT_Int64 of int64
11 | PT_Float of float
12 | PT_Bool of bool
13 | PT_Unit
14
15 }}
16
17 quote <- '"'
18 literal <- quote (Default.stringchar* $_) quote {{ __2 }}
19
20 recel <- literal ":" pt {{ (__1,Some __3) }}
21 / literal {{ (__1,None) }}
22
23 recels <- recel ("," recel {{ __2 }})* {{ __1::__2 }}
24
25 record <- "{" recels "}" {{ PT_Record __2 }}
26
27 lstels <- pt ("," pt {{ __2 }})* {{ __1::__2 }}
28
29 listtuple <- "[" lstels "]" {{ PT_ListTuple __2 }}
30
31 string <- literal {{ PT_String __1 }}
32 char <- Default.charsinglequote {{ PT_Char __1 }}
33 integer <- Default.int {{ PT_Int __1 }}
34 integer64 <- Default.int64 {{ PT_Int64 __1 }}
35 float <- Default.float {{ PT_Float __1 }}
36 bool <- Default.bool {{ PT_Bool __1 }}
37 unit <- "()" {{ PT_Unit }}
38
39 +pt : { pt_type } <- (record / listtuple / string / char / float / integer / integer64 / bool / unit) {{ __1 }}
Something went wrong with that request. Please try again.