You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is just an idea: the implementation of escape rules for Xml (or other transports) could be also delegated to an efficient regexp engine specified by OCamlLex:
{
(* short names for important modules *)
module L = Lexing
module B = Buffer
let get = L.lexeme
exception Error of string
let error fmt = Printf.kprintf (fun msg -> raise (Error msg)) fmt
}
rule escape b = parse
| '&' { B.add_string b "&"; escape b lexbuf }
| '"' { B.add_string b """; escape b lexbuf }
| '\'' { B.add_string b "'"; escape b lexbuf }
| '>' { B.add_string b ">"; escape b lexbuf }
| '<' { B.add_string b "<"; escape b lexbuf }
| [^'&' '"' '\'' '>' '<']+
{ B.add_string b @@ get lexbuf
; escape b lexbuf
}
| eof { let x = B.contents b in B.clear b; x }
| _ { error "don't know how to quote: %s" (get lexbuf) }
{
let escape str = escape (B.create 100) (L.from_string str)
}
The text was updated successfully, but these errors were encountered:
This is just an idea: the implementation of escape rules for Xml (or other transports) could be also delegated to an efficient regexp engine specified by OCamlLex:
The text was updated successfully, but these errors were encountered: