Skip to content
Fetching contributors…
Cannot retrieve contributors at this time
41 lines (32 sloc) 1.5 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 <>.
(* importing some stuff *)
{{ open Parser_utils }}
;lbrace <- Opa_lexer.lbrace
;rbrace_nosp <- Opa_lexer.rbrace_nosp
(* parser for non constants strings like "f(3) is :{f(3)}!"
* the given example will be transformed in
* [sc_list(["f(3)",f(3),"!"])]
;/** string with embedded opa **/
string_with_opa <- (=Opa_parser.deco(just_string_with_opa)):p
{{ let (l,label) = p in
(* slight optimization, but mostly it improves readability of pretty printed code *)
(computed_string l),label
;just_string_with_opa <- [\"] inner_string_element*:l (=Opa_lexer.or_eof([\"])):b {{ if not b then error_string (pos_only _filename _pos_beg _pos_end) else l }}
; inner_string_element <-
/ Opa_parser.opa_in_braces_nosp:e {{ wrap_e magic_to_string e }}
/ (=Opa_parser.careful_deco(Opa_lexer.stringchar+)):p
{{ let l,label = p in string (String.concat "" l) label }}
Something went wrong with that request. Please try again.