Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tag: v810
Fetching contributors…

Cannot retrieve contributors at this time

80 lines (56 sloc) 2.322 kb
(*
Copyright © 2011 MLstate
This file is part of OPA.
OPA is free software: you can redistribute it and/or modify it under the
terms of the GNU Affero General Public License, version 3, as published by
the Free Software Foundation.
OPA is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
more details.
You should have received a copy of the GNU Affero General Public License
along with OPA. If not, see <http://www.gnu.org/licenses/>.
*)
read default.trx
types:{{
open Ocaml
open Tgrammar
type pt_type =
| PT_Record of (string * pt_type) list
| PT_Option of pt_type option
| PT_List of pt_type list
| PT_Tuple of pt_type list
| PT_Cons of (string * pt_type option)
| 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 ")" {{ (__2,__4) }}
recels <- recel ("," recel {{ __2 }})* {{ __1::__2 }}
record <- "{" "Record" "=" "[" recels "]" "}" {{ PT_Record __5 }}
optel <- "(" quote "Some" quote "," pt ")" {{ Some __6 }}
/ "(" quote "None" quote ")" {{ None }}
option <- "{" "Option" "=" "[" optel "]" "}" {{ PT_Option __5 }}
lstel <- "(" pt ")" {{ __2 }}
lstels <- lstel (";" lstel {{ __2 }})* {{ __1::__2 }}
list <- "{" "List" "=" "[" lstels ";"? "]" "}" {{ PT_List __5 }}
tupel <- "(" pt ")" {{ __2 }}
tupels <- tupel ("," tupel {{ __2 }})* {{ __1::__2 }}
tuple <- "{" "Tuple" "=" "[" tupels ","? "]" "}" {{ PT_Tuple __5 }}
cnsel <- "(" literal "," pt ")" {{ (__2,Some __4) }}
/ "(" literal ")" {{ (__2,None) }}
cons <- "{" "Cons" "=" "[" cnsel "]" "}" {{ PT_Cons __5 }}
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 / option / list / tuple / cons / string / char / float / integer / integer64 / bool / unit) {{ __1 }}
Jump to Line
Something went wrong with that request. Please try again.