Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tag: v43
Fetching contributors…

Cannot retrieve contributors at this time

96 lines (77 sloc) 3.449 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/>.
*)
(* shorcuts to other files *)
;slash_nosp <- Opa_lexer.slash_nosp
;deco_ml_identifier_nosp <- Opa_parser.deco_ml_identifier_nosp
;ml_identifier_nosp <- Opa_lexer.ml_identifier_nosp
;ml_identifier <- Opa_lexer.ml_identifier
;underscore_nosp <- Opa_lexer.underscore_nosp
;lbracket <- Opa_lexer.lbracket
;lbracket_nosp <- Opa_lexer.lbracket_nosp
;rbracket <- Opa_lexer.rbracket
;rbracket_nosp <- Opa_lexer.rbracket_nosp
;lbrace <- Opa_lexer.lbrace
;lbrace_nosp <- Opa_lexer.lbrace_nosp
;rbrace <- Opa_lexer.rbrace
;rbrace_nosp <- Opa_lexer.rbrace_nosp
;spacing <- Opa_lexer.spacing
;semic <- Opa_lexer.semic
(* path definition, ie for [db pathdef : typ] or [db pathdef = expr] *)
;pathdef_nosp <-slash_nosp ml_identifier_nosp:i
(slash_nosp ml_identifier_nosp:i {{QmlAst.Db.Decl_fld i}}
/ "[]" {{ QmlAst.Db.Decl_set [] }}
/ "[_]" {{ QmlAst.Db.Decl_set [] }})*:l
{{ (QmlAst.Db.Decl_fld i)::l }}
;/** todo: extend to multiple index **/
setindex_def <- lbrace (=list1(ml_identifier,semic)):i rbrace
{{ QmlAst.Db.Decl_set [List.sort String.compare i] }}
;pathdef_type_nosp <- slash_nosp ml_identifier_nosp:i
(slash_nosp ml_identifier_nosp:i {{QmlAst.Db.Decl_fld i}}
/ lbracket setindex_def:i rbracket {{i}})*:l
{{ (QmlAst.Db.Decl_fld i)::l }}
;/** database path definition without type **/
pathdef <- spacing pathdef_nosp:v {{ v }}
;/** database path definition with type **/
pathdef_type <- spacing pathdef_type_nosp:v {{ v }}
(* path for reading *)
;/** database query **/
query <- querytype:qt path:p {{ p, qt }}
(* path for writing (no leading !,@ etc.) *)
; /** database write path **/
path_write <- slash_nosp path:p {{ p }}
;querytype <- [?] slash_nosp {{ QmlAst.Db.Option }}
/ [!] slash_nosp {{ QmlAst.Db.Valpath }}
/ [@] slash_nosp {{ QmlAst.Db.Ref }}
/ slash_nosp {{ QmlAst.Db.Default }}
;path = Opa_parser.careful_deco just_path
;just_path <- deco_ml_identifier_nosp:i path_elem*:l {{ let (s,label) = i in ((FldKey s),label) :: l }}
;path_elem = Opa_parser.careful_deco just_path_elem
;just_path_elem <- slash_nosp ml_identifier_nosp:i {{ FldKey i }}
/ lbracket_nosp Opa_parser.expr:e rbracket {{ ExprKey e }}
/ lbracket_nosp spacing [?] rbracket {{ NewKey }}
(**
{7 Separated lists}
*)
(** list where a the separator must occur *)
let list2 element separator = element:e (separator element:e {{e}})+:l
{{ e :: l }}
(**Non-empty lists*)
let list1 element separator = element:e (separator element {{__2}})*:l
{{ e :: l }};
(**Possibly empty lists*)
let list0 element separator = (=list1(element,separator))?:o
{{ match o with
| None -> []
| Some l -> l
}}
Jump to Line
Something went wrong with that request. Please try again.