| Ast.Over (t1, t2) -> sprintf "[%s \\OVER %s]" (pp_term t1) (pp_term t2)
| Ast.Atop (t1, t2) -> sprintf "[%s \\ATOP %s]" (pp_term t1) (pp_term t2)
| Ast.Frac (t1, t2) -> sprintf "\\FRAC %s %s" (pp_term t1) (pp_term t2)
- | Ast.InfRule (t1, t2, t3) -> sprintf "\\INFRULE %s %s %s" (pp_term t1) (pp_term t2) (pp_term t3)
+ | Ast.InfRule (t1, t2, t3) -> sprintf "\\INFRULE %s %s %s" (pp_term t1)
+ (pp_term t2) (pp_term t3)
+ | Ast.Maction l -> sprintf "\\MACTION (%s)"
+ (String.concat "," (List.map pp_term l))
| Ast.Sqrt t -> sprintf "\\SQRT %s" (pp_term t)
| Ast.Root (arg, index) ->
sprintf "\\ROOT %s \\OF %s" (pp_term index) (pp_term arg)
| InfRule of term * term * term
(* | array of term * literal option * literal option
|+ column separator, row separator +| *)
+ | Maction of term list
| Sqrt of term
| Root of term * term (* argument, index *)
| Break
| 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)
+ | Ast.Maction terms -> Ast.Maction (List.map k terms)
let visit_magic k = function
| Ast.List0 (t, l) -> Ast.List0 (k t, l)
[ "sub"; "sup";
"below"; "above";
"over"; "atop"; "frac";
- "sqrt"; "root"
+ "sqrt"; "root"; "mstyle" ; "mpadded"; "maction"
+
]
let level1_keywords =
"break";
"list0"; "list1"; "sep";
"opt";
- "term"; "ident"; "number"; "mstyle" ; "mpadded"
+ "term"; "ident"; "number";
] @ level1_layouts
let level2_meta_keywords =
List.iter
(fun (ligature, symbol) -> Hashtbl.add ligatures ligature symbol)
[ ("->", <:unicode<to>>); ("=>", <:unicode<Rightarrow>>);
- ("<=", <:unicode<leq>>); (">=", <:unicode<geq>>);
- ("<>", <:unicode<neq>>); (":=", <:unicode<def>>);
- ("==", <:unicode<equiv>>);
+ (":=", <:unicode<def>>);
]
let regexp uri_step = [ 'a' - 'z' 'A' - 'Z' '0' - '9' '_' '-' ''' ]+
| 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)
+ | Ast.Maction l -> List.flatten (List.map aux l)
and aux_magic magic =
match magic with
| Ast.Opt p ->
type checked_l1_pattern = CL1P of CicNotationPt.term * int
-let check_l1_pattern level1_pattern level associativity =
+let check_l1_pattern level1_pattern pponly level associativity =
let variables = ref 0 in
let symbols = ref 0 in
let rec aux = function
| 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)
+ | Ast.Maction l as t ->
+ if not pponly then
+ raise(Parse_error("Maction can be used only in output notations"))
+ else t
and aux_magic magic =
match magic with
| Ast.Opt p -> Ast.Opt (aux p)
return_term_of_level loc
(fun l ->
Ast.Layout (Ast.Mpadded (m, t l)))
+ | "maction"; m = LIST1 [ LPAREN; l = l1_pattern; RPAREN -> l ] ->
+ return_term_of_level loc
+ (fun l -> Ast.Layout (Ast.Maction (List.map (fun x ->
+ CicNotationUtil.group (x l)) m)))
| LPAREN; p = l1_pattern; RPAREN ->
return_term_of_level loc (fun l -> CicNotationUtil.group (p l))
]
val compare_rule_id : rule_id -> rule_id -> int
-val check_l1_pattern: (* level1_pattern *)
- CicNotationPt.term -> int -> Gramext.g_assoc -> checked_l1_pattern
+val check_l1_pattern: (* level1_pattern, pponly, precedence, assoc *)
+ CicNotationPt.term -> bool -> int -> Gramext.g_assoc -> checked_l1_pattern
val extend:
checked_l1_pattern ->
box_of mathonly (A.H, false, false) attrs
(aux_children mathonly false xref prec
(CicNotationUtil.ungroup terms)))
+ | A.Maction alternatives ->
+ toggle_action (List.map invoke_reinit alternatives)
| A.Group terms ->
let children =
aux_children mathonly false xref prec
match st with
| Notation (loc, dir, l1, associativity, precedence, l2) ->
let l1 =
- CicNotationParser.check_l1_pattern l1 precedence associativity
+ CicNotationParser.check_l1_pattern
+ l1 (dir = Some `RightToLeft) precedence associativity
in
let item = (l1, precedence, associativity, l2) in
let rule_id = ref [] in