Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

70 lines (59 sloc) 2.486 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/>.
*)
(**
* Actions parser
*)
(** importing from the lexer/main parser *)
let deco rule = (=Opa_parser.deco(rule))
;let exact_symbol rule = (=Opa_lexer.exact_symbol(rule))
;let exact_ident rule = (=Opa_lexer.exact_ident(rule))
(** the actual action parser *)
;jqs = deco just_jqs
;just_jqs <-
/ (=Opa_parser.careful_deco(("." {{ "class" }} / "#" {{ "id" }}))):kind
( Opa_parser.deco_ml_identifier:s {{ string2 s }}
/ Opa_parser.opa_in_braces:e {{ e }}):e
{{
let (k, lbl) = kind in
let ident_name =
(match k with
| "class" -> Opacapi.Dom.select_class
| "id" -> Opacapi.Dom.select_id
| _ -> assert false) in
let ident_expr = ((Ident ident_name), lbl) in
let apply_expr = Parser_utils.apply ident_expr e in
coerce_name apply_expr Opacapi.Types.dom
}}
/ Opa_parser.opa_in_braces:e {{ coerce_name e Opacapi.Types.dom }}
;verb = deco just_verb
;just_verb <- (=exact_symbol("<-")) {{ "set" }}
/ (=exact_symbol("-<-")) {{ "prepend" }}
/ (=exact_symbol("+<-")) {{ "append" }}
;val_css_option <- Opa_parser.pos:p (Opa_lexer.rarrow val_css:v{{v}})?:v
{{ Option.default
(("content", `magicToXml, None),p)
v
}}
;val_css = deco just_val_css
;just_val_css <- (Opa_lexer.CSS / (=exact_ident("style")) $) {{ ("css", `identity, None) }}
/ (=exact_ident("value")) {{ ("value", `magicToString, None) }}
/ (=deco(Opa_lexer.ml_identifier)):p {{ ("value_p", `identity, Some [("property", string2 p)]) }}
/ Opa_parser.opa_in_braces:e {{ ("value_p", `identity, Some [("property", e)]) }}
;/** action **/
action = deco just_action
;just_action <-
jqs:jqs
val_css_option:val_css
verb:verb
Opa_parser.expr:e {{ action _filename jqs val_css verb e }}
Jump to Line
Something went wrong with that request. Please try again.