sprintf "\\MSTYLE %s [%s]"
(String.concat " " (List.map (fun (k,v) -> k^"="^v) l))
(String.concat " " (List.map pp_term terms))
+ | Ast.Mpadded (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 = 5
+let magic = 6
type term =
(* CIC AST *)
| Box of box_spec * term list
| Group of term list
| Mstyle of (string * string) list * term list
+ | Mpadded of (string * string) list * term list
and magic_term =
(* level 1 magics *)
| 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)
+ | Ast.Mpadded (l, term) -> Ast.Mpadded (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 percentage =
+ ('-' | "") [ '0' - '9' ] + '%'
let regexp floatwithunit =
- [ '0' - '9' ] + ["."] [ '0' - '9' ] + ([ 'a' - 'z' ] + | "" )
+ ('-' | "") [ '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' ]
"break";
"list0"; "list1"; "sep";
"opt";
- "term"; "ident"; "number"; "mstyle"
+ "term"; "ident"; "number"; "mstyle" ; "mpadded"
] @ level1_layouts
let level2_meta_keywords =
return lexbuf ("IDENT", s)
end
| color -> return lexbuf ("COLOR", Ulexing.utf8_lexeme lexbuf)
+ | percentage ->
+ return lexbuf ("PERCENTAGE", Ulexing.utf8_lexeme lexbuf)
| floatwithunit ->
return lexbuf ("FLOATWITHUNIT", Ulexing.utf8_lexeme lexbuf)
| tex_token -> return lexbuf (expand_macro lexbuf)
| 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)
+ | Ast.Mpadded (_,pl) -> List.flatten (List.map aux pl)
and aux_magic magic =
match magic with
| Ast.Opt p ->
| 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)
+ | Ast.Mpadded (l,pl) -> Ast.Mpadded (l, List.map aux pl)
and aux_magic magic =
match magic with
| Ast.Opt p -> Ast.Opt (aux p)
mstyle: [
[ id = IDENT;
v = [ IDENT | NUMBER | COLOR | FLOATWITHUNIT ] -> id, v]];
+ mpadded: [
+ [ id = IDENT;
+ v = [ PERCENTAGE ] -> id, v]];
l1_simple_pattern:
[ "layout" LEFTA
[ p1 = SELF; SYMBOL "\\sub"; p2 = SELF ->
return_term_of_level loc
(fun l ->
Ast.Layout (Ast.Mstyle (m, t l)))
+ | "mpadded"; m = LIST1 mpadded ; LPAREN; t = l1_pattern; RPAREN ->
+ return_term_of_level loc
+ (fun l ->
+ Ast.Layout (Ast.Mpadded (m, t l)))
| LPAREN; p = l1_pattern; RPAREN ->
return_term_of_level loc (fun l -> CicNotationUtil.group (p l))
]
box_of mathonly (A.H, false, false) attrs
(aux_children mathonly false xref prec
(CicNotationUtil.ungroup terms)))
+ | A.Mpadded (l,terms) ->
+ Mpres.Mpadded
+ (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