Skip to content
This repository
tag: v1817
Fetching contributors…

Cannot retrieve contributors at this time

file 39 lines (29 sloc) 1.014 kb
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
open Ocaml
open Tgrammar

type pt_type =
  | PT_Record of (string * pt_type option) list
  | PT_ListTuple of pt_type list
  | PT_String of string
  | PT_Char of char
  | PT_Int of int
  | PT_Int64 of int64
  | PT_Float of float
  | PT_Bool of bool
  | PT_Unit

}}

quote <- '"'
literal <- quote (Default.stringchar* $_) quote {{ __2 }}

recel <- literal ":" pt {{ (__1,Some __3) }}
       / literal {{ (__1,None) }}

recels <- recel ("," recel {{ __2 }})* {{ __1::__2 }}

record <- "{" recels "}" {{ PT_Record __2 }}

lstels <- pt ("," pt {{ __2 }})* {{ __1::__2 }}

listtuple <- "[" lstels "]" {{ PT_ListTuple __2 }}

string <- literal {{ PT_String __1 }}
char <- Default.charsinglequote {{ PT_Char __1 }}
integer <- Default.int {{ PT_Int __1 }}
integer64 <- Default.int64 {{ PT_Int64 __1 }}
float <- Default.float {{ PT_Float __1 }}
bool <- Default.bool {{ PT_Bool __1 }}
unit <- "()" {{ PT_Unit }}

+pt : { pt_type } <- (record / listtuple / string / char / float / integer / integer64 / bool / unit) {{ __1 }}
Something went wrong with that request. Please try again.