(String.concat " " (List.map pp_term terms))
| Ast.Group terms ->
sprintf "\\GROUP [%s]" (String.concat " " (List.map pp_term terms))
+ | Ast.Mstyle (l,terms) ->
+ sprintf "\\MSTYLE %s [%s]"
+ (String.concat " " (List.map (fun (k,v) -> k^"="^v) l))
+ (String.concat " " (List.map pp_term terms))
and pp_magic = function
| Ast.List0 (t, sep_opt) ->
(** To be increased each time the term type below changes, used for "safe"
* marshalling *)
-let magic = 4
+let magic = 5
type term =
(* CIC AST *)
| Break
| Box of box_spec * term list
| Group of term list
+ | Mstyle of (string * string) list * term list
and magic_term =
(* level 1 magics *)
| Ast.Break -> Ast.Break
| Ast.Box (kind, terms) -> Ast.Box (kind, List.map k terms)
| Ast.Group terms -> Ast.Group (List.map k terms)
+ | Ast.Mstyle (l, term) -> Ast.Mstyle (l, List.map k term)
let visit_magic k = function
| Ast.List0 (t, l) -> Ast.List0 (k t, l)
let regexp number = xml_digit+
let regexp utf8_blank = " " | "\r\n" | "\n" | "\t" | [160] (* this is a nbsp *)
+let regexp floatwithunit =
+ [ '0' - '9' ] + ["."] [ '0' - '9' ] + ([ 'a' - 'z' ] + | "" )
+let regexp color = "#" [ '0' - '9' 'a' - 'f' 'A' - 'F' ] [ '0' - '9' 'a' - 'f'
+'A' - 'F' ] [ '0' - '9' 'a' - 'f' 'A' - 'F' ] [ '0' - '9' 'a' - 'f' 'A' - 'F' ]
+[ '0' - '9' 'a' - 'f' 'A' - 'F' ] [ '0' - '9' 'a' - 'f' 'A' - 'F' ]
(* ZACK: breaks unicode's binder followed by an ascii letter without blank *)
(* let regexp ident_letter = xml_letter *)
"break";
"list0"; "list1"; "sep";
"opt";
- "term"; "ident"; "number"
+ "term"; "ident"; "number"; "mstyle"
] @ level1_layouts
let level2_meta_keywords =
else
return lexbuf ("IDENT", s)
end
+ | color -> return lexbuf ("COLOR", Ulexing.utf8_lexeme lexbuf)
+ | floatwithunit ->
+ return lexbuf ("FLOATWITHUNIT", Ulexing.utf8_lexeme lexbuf)
| tex_token -> return lexbuf (expand_macro lexbuf)
| qkeyword ->
return lexbuf ("QKEYWORD", remove_quotes (Ulexing.utf8_lexeme lexbuf))
| Ast.Break -> []
| Ast.Box (_, pl) -> List.flatten (List.map aux pl)
| Ast.Group pl -> List.flatten (List.map aux pl)
+ | Ast.Mstyle (_,pl) -> List.flatten (List.map aux pl)
and aux_magic magic =
match magic with
| Ast.Opt p ->
| Ast.Break as t -> t
| Ast.Box (b, pl) -> Ast.Box(b, List.map aux pl)
| Ast.Group pl -> Ast.Group (List.map aux pl)
+ | Ast.Mstyle (l,pl) -> Ast.Mstyle (l, List.map aux pl)
and aux_magic magic =
match magic with
| Ast.Opt p -> Ast.Opt (aux p)
| "ident"; id = IDENT -> Ast.IdentVar id
]
];
+ mstyle: [
+ [ id = IDENT;
+ v = [ IDENT | NUMBER | COLOR | FLOATWITHUNIT ] -> id, v]];
l1_simple_pattern:
[ "layout" LEFTA
[ p1 = SELF; SYMBOL "\\sub"; p2 = SELF ->
return_term_of_level loc
(fun l -> Ast.Layout (Ast.Box ((Ast.HOV, false, false), p l)))
| "break" -> return_term_of_level loc (fun _ -> Ast.Layout Ast.Break)
+ | "mstyle"; m = LIST1 mstyle ; LPAREN; t = l1_pattern; RPAREN ->
+ return_term_of_level loc
+ (fun l ->
+ Ast.Layout (Ast.Mstyle (m, t l)))
| LPAREN; p = l1_pattern; RPAREN ->
return_term_of_level loc (fun l -> CicNotationUtil.group (p l))
]
| Some prec -> prec
in
(match !inferred_level with
- | None -> aux !new_xmlattrs mathonly new_xref prec t
+ | None -> aux !new_xmlattrs mathonly new_xref prec t
| Some child_prec ->
let t' = aux !new_xmlattrs mathonly new_xref child_prec t in
(*prerr_endline
(CicNotationUtil.ungroup terms)
in
box_of mathonly kind attrs children
+ | A.Mstyle (l,terms) ->
+ Mpres.Mstyle
+ (List.map (fun (k,v) -> None,k,v) l,
+ box_of mathonly (A.H, false, false) attrs
+ (aux_children mathonly false xref prec
+ (CicNotationUtil.ungroup terms)))
| A.Group terms ->
let children =
aux_children mathonly false xref prec