Skip to content
Newer
Older
100644 53 lines (39 sloc) 1.72 KB
fccc685 Initial open-source release
MLstate authored Jun 21, 2011
1 (*
2 Copyright © 2011 MLstate
3
4 This file is part of OPA.
5
6 OPA is free software: you can redistribute it and/or modify it under the
7 terms of the GNU Affero General Public License, version 3, as published by
8 the Free Software Foundation.
9
10 OPA is distributed in the hope that it will be useful, but WITHOUT ANY
11 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
13 more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with OPA. If not, see <http://www.gnu.org/licenses/>.
17 *)
18 read default.trx
19 read ocaml_types.trx
20 read ocaml_keywords.trx
21 read ocaml_parser.trx
22
23 types:{{
24 open Base
25 open Ocaml
26 open Tgrammar
27
28 type idl =
29 | IDLLet of Ocaml.expr
30 | IDLType of string * Ocaml.type_expr * string option
31 | IDLSar of string * string * string
32 }}
33
34 spc <- (Default.sharpcomment $ / Default.space $ / Default.mlcomment $)* $
35 delimitor <- ";;" $ / Default.eol $
36
37 let <- Ocaml_parser.Let spc delimitor? spc {{ IDLLet __1 }}
38
39 typident <- Ocaml_types.typevars? Ocaml_types.typeIdent $_
40 type <- Ocaml_types.typedeflist
41
42 deftype <- Ocaml_keywords.TYPE spc typident spc '=' spc type spc delimitor? spc
43 {{ IDLType (__3, __7, None) }}
44
45 sar <- Ocaml_keywords.VAL Ocaml_parser.mlIdent spc ":" spc typident spc "->" spc typident spc delimitor? spc
46 {{ IDLSar (__2,__6,__10) }}
47 / Ocaml_keywords.VAL Ocaml_parser.mlIdent spc ":" spc typident spc delimitor? spc
48 {{ IDLSar (__2,__6,"") }}
49
50 ext <- "external" spc typident spc ":" spc type spc "=" spc Default.string spc delimitor? spc {{ IDLType (__3,__7,Some __11) }}
51
52 +idls : {idl list} <- spc (sar / deftype / let / ext)* {{ __2 }}
Something went wrong with that request. Please try again.