(* NotationSource 4.0v9.m :  Jason Harris,  3/2/1999       *)
(* This file is machine generated from NotationSource 4.0v9.nb*)
(* It is not intended to be read by humans.  *)
(* Please consult the source file NotationSource 4.0v9.nb. *)

If[$NotationDebug, CellPrint[Cell[TextData[StyleBox["Notation Release 1.4.0", "Message", Rule[FontWeight, "Bold"]]], "Output"]]]

If[2.99 <= $VersionNumber + $ReleaseNumber <= 3.000999999999999, CellPrint[Cell[TextData[StyleBox["You are using an older version of Mathematica than this version of the Notation package was designed for. The upgrade Mathematica 3.0.0 -> 3.0.1 can be obtained free of charge from WRI. This version of the Notation package will work with Mathematica 3.0.1.", "Message", Rule[FontWeight, "Bold"]]], "Output"]]]

BeginPackage["Utilities`Notation`"]

Unprotect["Utilities`Notation`*"]
ClearAll @@ Complement[Names["Utilities`Notation`*"], {"AutoLoadNotationPalette", "AutoUpdateNotationStyleSheet", "$NotationDebug"}]
ClearAll["Utilities`Notation`Private`*"]

Begin["`Private`"]

SetAttributes[{friendlyOff, friendlyOn, messageStatus}, HoldAll]
messageStatus[MessageName[\[ScriptF]\[ScriptU]\[ScriptN]\[ScriptC]_, \[ScriptM]\[ScriptE]\[ScriptS]\[ScriptG]_String]] := If[Head[MessageName[\[ScriptF]\[ScriptU]\[ScriptN]\[ScriptC], \[ScriptM]\[ScriptE]\[ScriptS]\[ScriptG]] /. Messages[\[ScriptF]\[ScriptU]\[ScriptN]\[ScriptC]]] =!= $Off, $On, $Off, $Off]
friendlyOff[\[ScriptM]\[ScriptE]\[ScriptS]\[ScriptG]_MessageName] := (mesgWasOn[Hold[\[ScriptM]\[ScriptE]\[ScriptS]\[ScriptG]]] = messageStatus[\[ScriptM]\[ScriptE]\[ScriptS]\[ScriptG]] =!= $Off; Off[\[ScriptM]\[ScriptE]\[ScriptS]\[ScriptG]]; )
friendlyOn[\[ScriptM]\[ScriptE]\[ScriptS]\[ScriptG]_MessageName] := If[mesgWasOn[Hold[\[ScriptM]\[ScriptE]\[ScriptS]\[ScriptG]]], On[\[ScriptM]\[ScriptE]\[ScriptS]\[ScriptG]]; mesgWasOn[Hold[\[ScriptM]\[ScriptE]\[ScriptS]\[ScriptG]]] = False; ]

SetAttributes[silentEvaluate, HoldAll]
silentEvaluate[\[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR]_] := Block[{Message}, SetAttributes[Message, HoldFirst]; \[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR]]

silentEvaluate[Unprotect["System`Notation"]]
silentEvaluate[Remove["System`Notation"]]

notationsPublicFunctions = (StringJoin["Global`", #1] & ) /@ {"Action", "ClearNotations", "CreateNotationRules", "InfixNotation", "NotationBoxTag", "NotationPatternTag", "PrintNotationRules", "RemoveInfixNotation", "RemoveNotation", "RemoveNotationRules", "RemoveSymbolize", "Symbolize", "SymbolizeRootName", "WorkingForm"}

General::overShadw = "The symbol \"`1`\" has been used in the global context. The Notation package needs the full use of the symbol \"`1`\" and has therefore removed this symbol from the global context."

With[{overideNames = Intersection[Names["Global`*"], notationsPublicFunctions]}, If[overideNames =!= {}, (Message[Evaluate[ToExpression[StringJoin[#1, "::overShadw"]]], #1] & ) /@ (StringDrop[#1, 7] & ) /@ overideNames; Unprotect /@ overideNames; ClearAll /@ overideNames; Remove /@ overideNames; ]]

$NewVersion = $VersionNumber > 3.1

End[]

Symbolize::usage = "Symbolize[\[ScriptB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]] forces any box structure matching \[ScriptB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS] to be treated internally as a single symbol anywhere it appears in an input expression."

RemoveSymbolize::usage = "RemoveSymbolize[\[ScriptB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]] removes the symbolization of \[ScriptB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]."

SymbolizeRootName::usage := "SymbolizeRootName is an option for Symbolize specifying the name to be used internally for the symbolized boxes."

InfixNotation::usage = "InfixNotation[\[ScriptI]\[ScriptN]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptCapitalO]\[ScriptP], \[ScriptP]\[ScriptR]\[ScriptE]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptCapitalH]\[ScriptE]\[ScriptA]\[ScriptD]] forces the box structure \[ScriptI]\[ScriptN]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptCapitalO]\[ScriptP] to be treated as an infix operator representing the function \[ScriptP]\[ScriptR]\[ScriptE]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptCapitalH]\[ScriptE]\[ScriptA]\[ScriptD] in input and output."

RemoveInfixNotation::usage = "RemoveInfixNotation[\[ScriptI]\[ScriptN]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptCapitalO]\[ScriptP], \[ScriptP]\[ScriptR]\[ScriptE]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptCapitalH]\[ScriptE]\[ScriptA]\[ScriptD]] removes the infix operator \[ScriptI]\[ScriptN]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptCapitalO]\[ScriptP]"

Set[MessageName[Notation, "usage"], "Notation[\[ScriptCapitalE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS] \[DoubleLongLeftRightArrow] \[ScriptCapitalI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalE]\[ScriptX]\[ScriptP]\[ScriptR]] parses any input box structure \[ScriptCapitalE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS] internally as \[ScriptCapitalI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalE]\[ScriptX]\[ScriptP]\[ScriptR], and formats any expression matching \[ScriptCapitalI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalE]\[ScriptX]\[ScriptP]\[ScriptR] as \[ScriptCapitalE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS] in output. To restrict Notation to only parsing, use Notation[\[ScriptCapitalE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS] \[DoubleLongRightArrow] \[ScriptCapitalI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalE]\[ScriptX]\[ScriptP]\[ScriptR]], and to restrict Notation to only formatting, use Notation[\[ScriptCapitalE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS] \[DoubleLongLeftArrow] \[ScriptCapitalI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalE]\[ScriptX]\[ScriptP]\[ScriptR]]."]

RemoveNotation::usage = "RemoveNotation[\[ScriptCapitalE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS] \[DoubleLongLeftRightArrow] \[ScriptCapitalI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalE]\[ScriptX]\[ScriptP]\[ScriptR]] removes the notation \[ScriptCapitalE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM] \[DoubleLongLeftRightArrow] \[ScriptCapitalI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM]. To remove only the parsing, use RemoveNotation[\[ScriptCapitalE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS] \[DoubleLongRightArrow] \[ScriptCapitalI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalE]\[ScriptX]\[ScriptP]\[ScriptR]], and to remove only the formatting, use RemoveNotation[\[ScriptCapitalE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS] \[DoubleLongLeftArrow] \[ScriptCapitalI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalE]\[ScriptX]\[ScriptP]\[ScriptR]]."

NotationBoxTag::usage = "NotationBoxTag is a TagBox tag that is embedded in Notation, Symbolize and InfixNotation statements.  The embedded TagBox ensures correct parsing and retention of proper styling and grouping information."

NotationPatternTag::usage = "NotationPatternTag is a TagBox tag which can be embedded in Notation, Symbolize and InfixNotation statements. When used, this tag indicates that the expression inside of the NotationPatternTag structure represents a complex pattern and not a box structure. It will still be processed by MakeBoxes or MakeExpression."

NotationMadeBoxesTag::usage = "NotationMadeBoxesTag is a TagBox tag which can be embedded in Notation, Symbolize and InfixNotation statements. When used, this tag indicates that the expression inside of the NotationMadeBoxesTag structure represents a made box expression or literal expression. It will not be processed by MakeBoxes."

ClearNotations::usage = "ClearNotations[] will remove all \"notations\" , \"symbolizations\" and \"infix notations\". It does not destroy any rules for MakeExpression and MakeBoxes. This function will reset the notation handling to a pristine state."

WorkingForm::usage = "WorkingForm is an option of Notation, Symbolize and InfixNotation, which specifies which form the notation will be defined in. Possible forms include StandardForm, TraditionalForm, user defined forms, and Automatic which defaults to the default output format type."

Action::usage = "Action is an option of Notation, Symbolize and InfixNotation. It defines what action will be performed with the given notation statement. The possible values are CreateNotationRules, PrintNotationRules and RemoveNotationRules"

CreateNotationRules::usage = "CreateNotationRules is a possible value for the option Action which is used in Notation, Symbolize and InfixNotation. If the option Action is set to CreateNotationRules, then a notation statement will enter the given notation into the system."

RemoveNotationRules::usage = "RemoveNotationRules is a possible value for the option Action which is used in Notation, Symbolize and InfixNotation. If the option Action is set to RemoveNotationRules, then a notation statement will remove the given notation from the system."

PrintNotationRules::usage = "PrintNotationRules is a possible value for the option Action which is used in Notation, Symbolize and InfixNotation. If the option Action is set to PrintNotationRules, then a notation statement will print out a cell containing the rules defining the given notation."

AutoLoadNotationPalette::usage = "AutoLoadNotationPalette is a boolean variable. If False then the Notation palette will not be loaded when the Notation package is loaded. If the value is undefined or True the Notation palette will be loaded when the Notation package loads. Other package designers can set this variable outside of the Notation package through a statement similar to Utilities`Notation`AutoLoadNotationPalette = False."

NotationMakeExpression::usage = "NotationMakeExpression is a private version of MakeExpression. The Notation package uses NotationMakeExpression in an attempt to minimally interfere with other functions that use MakeExpression."

NotationMakeBoxes::usage = "NotationMakeBoxes is a private version of MakeBoxes. The Notation package uses NotationMakeBoxes in an attempt to minimally interfere with other functions that use MakeBoxes."

AutoUpdateNotationStyleSheet::usage = "AutoUpdateNotationStyleSheet is a boolean variable. If False then the current notebook style sheet will not be updated to the latest styles when the Notation package is loaded. If the value is undefined or True the style sheet will be updated when the Notation package loads. Other package designers can set this variable outside of the Notation package by Utilities`Notation`AutoUpdateNotationStyleSheet = False."

UpdateNotationsInNotebook::usage = "UpdateNotationsInNotebook[] is a function that will update all Notations, InfixNotations, and Symbolizations in your current notebook to visually conform to the styles made available with the latest release of Mathematica. Note: UpdateNotationsInNotebook only changes visual styles and Notebooks with old notation templates will still function correctly. This function intensively uses front end memory for large notebooks, so you may need to increase this if the command fails at first. UpdateNotationsInNotebook[\[ScriptN]\[ScriptO]\[ScriptT]\[ScriptE]\[ScriptB]\[ScriptO]\[ScriptO]\[ScriptK]] will update the notations in the notebook \[ScriptN]\[ScriptO]\[ScriptT]\[ScriptE]\[ScriptB]\[ScriptO]\[ScriptO]\[ScriptK]."

UpdateNotebookStyles::usage = "UpdateNotebookStyles[] is a function that will add the styles the notation package defines to your current notebook. These styles are desirable since they change the visual appearance of notation statements. It will also add the input aliases the Notation package uses. Note: however your notebooks will still run without the addition of these styles.  UpdateNotebookStyles[\[ScriptN]\[ScriptO]\[ScriptT]\[ScriptE]\[ScriptB]\[ScriptO]\[ScriptO]\[ScriptK]] will update the style sheet of the notebook \[ScriptN]\[ScriptO]\[ScriptT]\[ScriptE]\[ScriptB]\[ScriptO]\[ScriptO]\[ScriptK]."

AddInputAlias::usage = "AddInputAlias[\[ScriptF]\[ScriptU]\[ScriptL]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS],\[ScriptS]\[ScriptH]\[ScriptO]\[ScriptR]\[ScriptT]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM]] adds the alias \[EscapeKey]\[ScriptS]\[ScriptH]\[ScriptO]\[ScriptR]\[ScriptT]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM]\[EscapeKey] for \[ScriptF]\[ScriptU]\[ScriptL]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS] to the aliases in the curret notebook. AddInputAlias[\[ScriptF]\[ScriptU]\[ScriptL]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS],\[ScriptS]\[ScriptH]\[ScriptO]\[ScriptR]\[ScriptT]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM],\[ScriptN]\[ScriptO]\[ScriptT]\[ScriptE]\[ScriptB]\[ScriptO]\[ScriptO]\[ScriptK]] adds the alias to the notebook \[ScriptN]\[ScriptO]\[ScriptT]\[ScriptE]\[ScriptB]\[ScriptO]\[ScriptO]\[ScriptK]."

ActiveInputAliases::usage = "ActiveInputAliases[] returns a list of all active aliases in the current notebook. ActiveInputAliases[\[ScriptN]\[ScriptO]\[ScriptT]\[ScriptE]\[ScriptB]\[ScriptO]\[ScriptO]\[ScriptK]] returns a list of all active aliases in the notebook \[ScriptN]\[ScriptO]\[ScriptT]\[ScriptE]\[ScriptB]\[ScriptO]\[ScriptO]\[ScriptK]."

Set[Options[Notation], List[Rule[WorkingForm, Automatic], Rule[Action, CreateNotationRules]]]

Options[Symbolize] = {WorkingForm -> Automatic, Action -> CreateNotationRules, SymbolizeRootName -> ""}

Options[InfixNotation] = {WorkingForm -> Automatic, Action -> CreateNotationRules}

Begin["`Private`"]

adjustedOptions[form_] := adjustedOptions[form] = Options[form] /. HoldPattern[(Rule | RuleDelayed)[WorkingForm, Automatic]] -> (WorkingForm :> "Output" /. (CommonDefaultFormatTypes /. AbsoluteOptions[$FrontEnd, "CommonDefaultFormatTypes"]))

SetAttributes[{heldLength, headIsNot, isNot}, HoldAll]
heldLength[\[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR]_] := Length[Unevaluated[\[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR]]]
isNot[\[ScriptP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]_] := Function[\[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR],  !MatchQ[Unevaluated[\[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR]], \[ScriptP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]], HoldAll]
headIsNot[\[ScriptP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]_] := Function[\[ScriptT]\[ScriptE]\[ScriptS]\[ScriptT]\[ScriptCapitalH]\[ScriptE]\[ScriptA]\[ScriptD],  !MatchQ[Head[Unevaluated[\[ScriptT]\[ScriptE]\[ScriptS]\[ScriptT]\[ScriptCapitalH]\[ScriptE]\[ScriptA]\[ScriptD]]], \[ScriptP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]], HoldAll]

General::badarg = "`1` expected at position `2` in `3`"

characterQ[\[ScriptA]_String] := StringLength[\[ScriptA]] == 1
characterQ[\[ScriptO]\[ScriptT]\[ScriptH]\[ScriptE]\[ScriptR]___] := False

structuralBoxes = FractionBox | GridBox | InterpretationBox | RadicalBox | RowBox | SqrtBox | SubscriptBox | SuperscriptBox | SubsuperscriptBox | TagBox | UnderscriptBox | OverscriptBox | UnderoverscriptBox

colorizeStructuralBoxes[(\[ScriptA]:structuralBoxes)[\[ScriptA]\[ScriptR]\[ScriptG]\[ScriptS]__], \[ScriptD]\[ScriptE]\[ScriptP]\[ScriptT]\[ScriptH]_] := ((StyleBox[#1, Background -> Hue[0, 1 - E^(-0.1579*\[ScriptD]\[ScriptE]\[ScriptP]\[ScriptT]\[ScriptH]), 1], FontColor -> Hue[0, 1 - E^(-0.1579*\[ScriptD]\[ScriptE]\[ScriptP]\[ScriptT]\[ScriptH]), 1]] & )[FrameBox[StyleBox[#1, FontColor -> RGBColor[0, 0, 0]]]] & )[\[ScriptA] @@ (colorizeStructuralBoxes[#1, \[ScriptD]\[ScriptE]\[ScriptP]\[ScriptT]\[ScriptH] + 1] & ) /@ {\[ScriptA]\[ScriptR]\[ScriptG]\[ScriptS]}]
colorizeStructuralBoxes[(\[ScriptA]_)[\[ScriptA]\[ScriptR]\[ScriptG]\[ScriptS]__], \[ScriptD]\[ScriptE]\[ScriptP]\[ScriptT]\[ScriptH]_] := \[ScriptA] @@ (colorizeStructuralBoxes[#1, \[ScriptD]\[ScriptE]\[ScriptP]\[ScriptT]\[ScriptH]] & ) /@ {\[ScriptA]\[ScriptR]\[ScriptG]\[ScriptS]}
colorizeStructuralBoxes[\[ScriptA]_, \[ScriptD]\[ScriptE]\[ScriptP]\[ScriptT]\[ScriptH]_] := \[ScriptA]

parsableQ[","] = True
SetDelayed[parsableQ[Pattern[\[ScriptB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR], Blank[]]], SameQ[Head[ToExpression[\[ScriptB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR], ReplaceAll[WorkingForm, adjustedOptions[Notation]], HoldComplete]], HoldComplete]]
SetDelayed[parsableQ[Pattern[\[ScriptB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR], Blank[]], Pattern[\[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS], BlankNullSequence[]]], SameQ[Head[ToExpression[\[ScriptB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR], ReplaceAll[ReplaceAll[WorkingForm, List[\[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS]]], adjustedOptions[Notation]], HoldComplete]], HoldComplete]]

notParsableQ[\[ScriptB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR]___] :=  !parsableQ[\[ScriptB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR]]
silentNotParsableQ[\[ScriptB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR]___] :=  !silentEvaluate[parsableQ[\[ScriptB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR]]]
silentParsableQ[\[ScriptB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR]___] := silentEvaluate[parsableQ[\[ScriptB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR]]]

Attributes[SilentCheck] = HoldAll
SilentCheck[expr_, failexpr_] := Module[{returnValue}, Unprotect[Message]; HoldPattern[m:Message[___]] := Block[{$Messages = {}}, m] /; $Messages =!= {}; returnValue = Check[expr, failexpr]; HoldPattern[m:Message[___]] =. ; Protect[Message]; returnValue]

MakeExpression[\[ScriptB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]_, \[ScriptF]\[ScriptO]\[ScriptR]\[ScriptM]_] := With[{\[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR] = NotationMakeExpression[\[ScriptB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], \[ScriptF]\[ScriptO]\[ScriptR]\[ScriptM]]}, \[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR] /; Head[\[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR]] === HoldComplete]

SetAttributes[NotationMakeBoxes, HoldAllComplete]

MakeBoxes[\[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR]_, \[ScriptF]\[ScriptO]\[ScriptR]\[ScriptM]_] := With[{\[ScriptB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS] = NotationMakeBoxes[\[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR], \[ScriptF]\[ScriptO]\[ScriptR]\[ScriptM]]}, \[ScriptB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS] /; Head[\[ScriptB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]] =!= NotationMakeBoxes]

NotationMakeExpression[TagBox[\[ScriptB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]_, NotationBoxTag, \[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS]___], \[ScriptA]\[ScriptN]\[ScriptY]_] := HoldComplete[NotationBoxTag[\[ScriptB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]]]

If[$NewVersion, NotationMakeBoxes[HoldPattern[NotationBoxTag][\[ScriptA]\[ScriptN]\[ScriptY]__], \[ScriptF]\[ScriptO]\[ScriptR]\[ScriptM]_] := TagBox[\[ScriptA]\[ScriptN]\[ScriptY], NotationBoxTag, Rule[TagStyle, "NotationTemplateStyle"]], NotationMakeBoxes[HoldPattern[NotationBoxTag][\[ScriptA]\[ScriptN]\[ScriptY]__], \[ScriptF]\[ScriptO]\[ScriptR]\[ScriptM]_] := TagBox[\[ScriptA]\[ScriptN]\[ScriptY], NotationBoxTag]]

SetAttributes[NotationBoxTag, HoldAll]

stripNotationBoxTag[\[ScriptA]\[ScriptN]\[ScriptY]_] := \[ScriptA]\[ScriptN]\[ScriptY] //. HoldPattern[NotationBoxTag][\[ScriptS]\[ScriptT]\[ScriptR]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]_] :> \[ScriptS]\[ScriptT]\[ScriptR]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]

identityForm/: NotationMakeBoxes[identityForm[\[ScriptA]\[ScriptN]\[ScriptY]___], \[ScriptF]\[ScriptO]\[ScriptR]\[ScriptM]_] := \[ScriptA]\[ScriptN]\[ScriptY]

SetAttributes[identityForm, HoldAll]

whiteSpaceQ[\[ScriptS]\[ScriptT]\[ScriptR]\[ScriptI]\[ScriptN]\[ScriptG]_String] := DeleteCases[Characters[\[ScriptS]\[ScriptT]\[ScriptR]\[ScriptI]\[ScriptN]\[ScriptG]], "\t" | "\n" | " " | "\[InvisibleSpace]" | "\[VeryThinSpace]" | "\[ThinSpace]" | "\[MediumSpace]" | "\[ThickSpace]" | "\[NegativeVeryThinSpace]" | "\[NegativeThinSpace]" | "\[NegativeMediumSpace]" | "\[NegativeThickSpace]" | "\n" | "\[NoBreak]" | "\[NonBreakingSpace]" | "\[Continuation]" | "\[SpaceIndicator]" | "\[RoundSpaceIndicator]" | "\[AlignmentMarker]" | ""] === {}

whiteSpaceQ[\[ScriptO]\[ScriptT]\[ScriptH]\[ScriptE]\[ScriptR]___] := False

notWhiteSpaceQ[\[ScriptA]\[ScriptN]\[ScriptY]_] :=  !whiteSpaceQ[\[ScriptA]\[ScriptN]\[ScriptY]]

setInternalCharacterInformation[{\[ScriptT]\[ScriptH]\[ScriptE]\[ScriptCapitalC]\[ScriptO]\[ScriptD]\[ScriptE]_, \[ScriptT]\[ScriptH]\[ScriptE]\[ScriptCapitalC]\[ScriptH]\[ScriptA]\[ScriptR]\[ScriptA]\[ScriptC]\[ScriptT]\[ScriptE]\[ScriptR]_, \[ScriptS]\[ScriptH]\[ScriptO]\[ScriptR]\[ScriptT]\[ScriptF]\[ScriptO]\[ScriptR]\[ScriptM]\[ScriptS]_, \[ScriptT]\[ScriptH]\[ScriptE]\[ScriptCapitalF]\[ScriptI]\[ScriptX]\[ScriptI]\[ScriptT]\[ScriptY]_, \[ScriptT]\[ScriptH]\[ScriptE]\[ScriptCapitalP]\[ScriptR]\[ScriptE]\[ScriptC]\[ScriptE]\[ScriptD]\[ScriptE]\[ScriptN]\[ScriptC]\[ScriptE]_, \[ScriptT]\[ScriptH]\[ScriptE]\[ScriptCapitalG]\[ScriptR]\[ScriptO]\[ScriptU]\[ScriptP]\[ScriptI]\[ScriptN]\[ScriptG]_, \[ScriptT]\[ScriptH]\[ScriptE]\[ScriptCapitalR]\[ScriptI]\[ScriptG]\[ScriptH]\[ScriptT]\[ScriptCapitalS]\[ScriptP]\[ScriptA]\[ScriptC]\[ScriptI]\[ScriptN]\[ScriptG]_, \[ScriptT]\[ScriptH]\[ScriptE]\[ScriptCapitalL]\[ScriptE]\[ScriptF]\[ScriptT]\[ScriptCapitalS]\[ScriptP]\[ScriptA]\[ScriptC]\[ScriptI]\[ScriptN]\[ScriptG]_, \[ScriptO]\[ScriptT]\[ScriptH]\[ScriptE]\[ScriptR]___}] := internalCharacterInformation[ToExpression[StringJoin["\"", \[ScriptT]\[ScriptH]\[ScriptE]\[ScriptCapitalC]\[ScriptH]\[ScriptA]\[ScriptR]\[ScriptA]\[ScriptC]\[ScriptT]\[ScriptE]\[ScriptR], "\""]]] = {\[ScriptT]\[ScriptH]\[ScriptE]\[ScriptCapitalC]\[ScriptO]\[ScriptD]\[ScriptE], \[ScriptT]\[ScriptH]\[ScriptE]\[ScriptCapitalF]\[ScriptI]\[ScriptX]\[ScriptI]\[ScriptT]\[ScriptY], \[ScriptT]\[ScriptH]\[ScriptE]\[ScriptCapitalP]\[ScriptR]\[ScriptE]\[ScriptC]\[ScriptE]\[ScriptD]\[ScriptE]\[ScriptN]\[ScriptC]\[ScriptE], \[ScriptT]\[ScriptH]\[ScriptE]\[ScriptCapitalG]\[ScriptR]\[ScriptO]\[ScriptU]\[ScriptP]\[ScriptI]\[ScriptN]\[ScriptG], \[ScriptT]\[ScriptH]\[ScriptE]\[ScriptCapitalR]\[ScriptI]\[ScriptG]\[ScriptH]\[ScriptT]\[ScriptCapitalS]\[ScriptP]\[ScriptA]\[ScriptC]\[ScriptI]\[ScriptN]\[ScriptG], \[ScriptT]\[ScriptH]\[ScriptE]\[ScriptCapitalL]\[ScriptE]\[ScriptF]\[ScriptT]\[ScriptCapitalS]\[ScriptP]\[ScriptA]\[ScriptC]\[ScriptI]\[ScriptN]\[ScriptG], StringDrop[StringDrop[\[ScriptT]\[ScriptH]\[ScriptE]\[ScriptCapitalC]\[ScriptH]\[ScriptA]\[ScriptR]\[ScriptA]\[ScriptC]\[ScriptT]\[ScriptE]\[ScriptR], 2], -1]}

setInternalCharacterInformation[{\[ScriptT]\[ScriptH]\[ScriptE]\[ScriptCapitalC]\[ScriptO]\[ScriptD]\[ScriptE]_, \[ScriptT]\[ScriptH]\[ScriptE]\[ScriptCapitalC]\[ScriptH]\[ScriptA]\[ScriptR]\[ScriptA]\[ScriptC]\[ScriptT]\[ScriptE]\[ScriptR]_, \[ScriptS]\[ScriptH]\[ScriptO]\[ScriptR]\[ScriptT]\[ScriptF]\[ScriptO]\[ScriptR]\[ScriptM]\[ScriptS]_, \[ScriptT]\[ScriptH]\[ScriptE]\[ScriptCapitalF]\[ScriptI]\[ScriptX]\[ScriptI]\[ScriptT]\[ScriptY]_}] := internalCharacterInformation[ToExpression[StringJoin["\"", \[ScriptT]\[ScriptH]\[ScriptE]\[ScriptCapitalC]\[ScriptH]\[ScriptA]\[ScriptR]\[ScriptA]\[ScriptC]\[ScriptT]\[ScriptE]\[ScriptR], "\""]]] = {\[ScriptT]\[ScriptH]\[ScriptE]\[ScriptCapitalC]\[ScriptO]\[ScriptD]\[ScriptE], \[ScriptT]\[ScriptH]\[ScriptE]\[ScriptCapitalF]\[ScriptI]\[ScriptX]\[ScriptI]\[ScriptT]\[ScriptY], StringDrop[StringDrop[\[ScriptT]\[ScriptH]\[ScriptE]\[ScriptCapitalC]\[ScriptH]\[ScriptA]\[ScriptR]\[ScriptA]\[ScriptC]\[ScriptT]\[ScriptE]\[ScriptR], 2], -1]}

\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]:setInternalCharacterInformation[(\[ScriptN]\[ScriptO]\[ScriptT]\[ScriptCapitalL]\[ScriptI]\[ScriptS]\[ScriptT]_)?(headIsNot[List]), ___] := $Failed /; Message[setInternalCharacterInformation::list, HoldForm[\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]], 1]

\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]:setInternalCharacterInformation[___] := With[{\[ScriptN]\[ScriptU]\[ScriptM] = heldLength[\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]]}, $Failed /; \[ScriptN]\[ScriptU]\[ScriptM] != 1 && Message[setInternalCharacterInformation::argx, HoldForm[setInternalCharacterInformation], \[ScriptN]\[ScriptU]\[ScriptM], 1]]

unicodeCharacters::missing = "It appears that the file \"UnicodeCharacters.tr\" has not been included in your installation of Mathematica. The file \"UnicodeCharacters.tr\" is necessary for Notation to determine the precedences of characters. Unfortunately Notation will not run without this file. This sometimes occurs in installations inside WRI."

If[FileNames["UnicodeCharacters.tr", ToFileName[{$TopDirectory, "SystemFiles", "FrontEnd", "TextResources"}]] == {}, Message[unicodeCharacters::missing]]

silentEvaluate[Union[setInternalCharacterInformation /@ ReadList[ToFileName[{$TopDirectory, "SystemFiles", "FrontEnd", "TextResources"}, "UnicodeCharacters.tr"], Word, RecordLists -> True, WordSeparators -> {FromCharacterCode[9]}, RecordSeparators -> {FromCharacterCode[13], FromCharacterCode[10]}]]]

Table[internalCharacterInformation[FromCharacterCode[i]] = {ToString[i], "Letter", StringJoin["Raw", FromCharacterCode[i]]}, {i, 65, 90}]
Table[internalCharacterInformation[FromCharacterCode[i]] = {ToString[i], "Letter", StringJoin["Raw", FromCharacterCode[i]]}, {i, 97, 122}]
Table[internalCharacterInformation[FromCharacterCode[i]] = {ToString[i], "Digit", StringJoin["Raw", FromCharacterCode[i]]}, {i, 48, 57}]

characterInformation[(\[ScriptC]\[ScriptH]\[ScriptA]\[ScriptR]_String)?characterQ] := characterInformationAux[internalCharacterInformation[\[ScriptC]\[ScriptH]\[ScriptA]\[ScriptR]]]
characterInformation[\[ScriptC]\[ScriptH]\[ScriptA]\[ScriptR]_String, \[ScriptF]\[ScriptI]\[ScriptE]\[ScriptL]\[ScriptD]_Symbol] := \[ScriptF]\[ScriptI]\[ScriptE]\[ScriptL]\[ScriptD] /. characterInformation[\[ScriptC]\[ScriptH]\[ScriptA]\[ScriptR]]
characterInformationAux[{\[ScriptT]\[ScriptH]\[ScriptE]\[ScriptCapitalC]\[ScriptO]\[ScriptD]\[ScriptE]_, \[ScriptT]\[ScriptH]\[ScriptE]\[ScriptCapitalF]\[ScriptI]\[ScriptX]\[ScriptI]\[ScriptT]\[ScriptY]_, \[ScriptT]\[ScriptH]\[ScriptE]\[ScriptCapitalP]\[ScriptR]\[ScriptE]\[ScriptC]\[ScriptE]\[ScriptD]\[ScriptE]\[ScriptN]\[ScriptC]\[ScriptE]_, \[ScriptT]\[ScriptH]\[ScriptE]\[ScriptCapitalG]\[ScriptR]\[ScriptO]\[ScriptU]\[ScriptP]\[ScriptI]\[ScriptN]\[ScriptG]_, \[ScriptT]\[ScriptH]\[ScriptE]\[ScriptCapitalR]\[ScriptI]\[ScriptG]\[ScriptH]\[ScriptT]\[ScriptCapitalS]\[ScriptP]\[ScriptA]\[ScriptC]\[ScriptI]\[ScriptN]\[ScriptG]_, \[ScriptT]\[ScriptH]\[ScriptE]\[ScriptCapitalL]\[ScriptE]\[ScriptF]\[ScriptT]\[ScriptCapitalS]\[ScriptP]\[ScriptA]\[ScriptC]\[ScriptI]\[ScriptN]\[ScriptG]_, \[ScriptT]\[ScriptH]\[ScriptE]\[ScriptCapitalC]\[ScriptH]\[ScriptA]\[ScriptR]\[ScriptA]\[ScriptC]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptCapitalF]\[ScriptU]\[ScriptL]\[ScriptL]\[ScriptCapitalN]\[ScriptA]\[ScriptM]\[ScriptE]_}] := {CharacterCode -> \[ScriptT]\[ScriptH]\[ScriptE]\[ScriptCapitalC]\[ScriptO]\[ScriptD]\[ScriptE], CharacterFixity -> \[ScriptT]\[ScriptH]\[ScriptE]\[ScriptCapitalF]\[ScriptI]\[ScriptX]\[ScriptI]\[ScriptT]\[ScriptY], CharacterPrecedence -> \[ScriptT]\[ScriptH]\[ScriptE]\[ScriptCapitalP]\[ScriptR]\[ScriptE]\[ScriptC]\[ScriptE]\[ScriptD]\[ScriptE]\[ScriptN]\[ScriptC]\[ScriptE], CharacterGrouping -> \[ScriptT]\[ScriptH]\[ScriptE]\[ScriptCapitalG]\[ScriptR]\[ScriptO]\[ScriptU]\[ScriptP]\[ScriptI]\[ScriptN]\[ScriptG], CharacterRightSpacing -> \[ScriptT]\[ScriptH]\[ScriptE]\[ScriptCapitalR]\[ScriptI]\[ScriptG]\[ScriptH]\[ScriptT]\[ScriptCapitalS]\[ScriptP]\[ScriptA]\[ScriptC]\[ScriptI]\[ScriptN]\[ScriptG], CharacterLeftSpacing -> \[ScriptT]\[ScriptH]\[ScriptE]\[ScriptCapitalL]\[ScriptE]\[ScriptF]\[ScriptT]\[ScriptCapitalS]\[ScriptP]\[ScriptA]\[ScriptC]\[ScriptI]\[ScriptN]\[ScriptG], CharacterFullName -> \[ScriptT]\[ScriptH]\[ScriptE]\[ScriptCapitalC]\[ScriptH]\[ScriptA]\[ScriptR]\[ScriptA]\[ScriptC]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptCapitalF]\[ScriptU]\[ScriptL]\[ScriptL]\[ScriptCapitalN]\[ScriptA]\[ScriptM]\[ScriptE]}
characterInformationAux[{\[ScriptT]\[ScriptH]\[ScriptE]\[ScriptCapitalC]\[ScriptO]\[ScriptD]\[ScriptE]_, \[ScriptT]\[ScriptH]\[ScriptE]\[ScriptCapitalF]\[ScriptI]\[ScriptX]\[ScriptI]\[ScriptT]\[ScriptY]_, \[ScriptT]\[ScriptH]\[ScriptE]\[ScriptCapitalC]\[ScriptH]\[ScriptA]\[ScriptR]\[ScriptA]\[ScriptC]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptCapitalF]\[ScriptU]\[ScriptL]\[ScriptL]\[ScriptCapitalN]\[ScriptA]\[ScriptM]\[ScriptE]_}] := {CharacterCode -> \[ScriptT]\[ScriptH]\[ScriptE]\[ScriptCapitalC]\[ScriptO]\[ScriptD]\[ScriptE], CharacterFixity -> \[ScriptT]\[ScriptH]\[ScriptE]\[ScriptCapitalF]\[ScriptI]\[ScriptX]\[ScriptI]\[ScriptT]\[ScriptY], CharacterFullName -> \[ScriptT]\[ScriptH]\[ScriptE]\[ScriptCapitalC]\[ScriptH]\[ScriptA]\[ScriptR]\[ScriptA]\[ScriptC]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptCapitalF]\[ScriptU]\[ScriptL]\[ScriptL]\[ScriptCapitalN]\[ScriptA]\[ScriptM]\[ScriptE]}

\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]:characterInformation[(\[ScriptN]\[ScriptO]\[ScriptT]\[ScriptCapitalS]\[ScriptT]\[ScriptR]\[ScriptI]\[ScriptN]\[ScriptG]_)?(headIsNot[String]), ___] := $Failed /; Message[characterInformation::string, 1, HoldForm[\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]]]

\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]:characterInformation[_, (\[ScriptN]\[ScriptO]\[ScriptT]\[ScriptCapitalS]\[ScriptY]\[ScriptM]\[ScriptB]_)?(headIsNot[Symbol]), ___] := $Failed /; Message[characterInformation::sym, \[ScriptN]\[ScriptO]\[ScriptT]\[ScriptCapitalS]\[ScriptY]\[ScriptM]\[ScriptB], 2]

\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]:characterInformation[___] := With[{\[ScriptN]\[ScriptU]\[ScriptM] = heldLength[\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]]}, $Failed /; (\[ScriptN]\[ScriptU]\[ScriptM] < 1 || \[ScriptN]\[ScriptU]\[ScriptM] > 2) && Message[characterInformation::argt, HoldForm[characterInformation], heldLength[\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]], 1, 2]]

isolatingBoxes = ButtonBox | FormBox | FractionBox | FrameBox | GridBox | RowBox | RadicalBox | SqrtBox

nonIsolatingBoxes = AdjustmentBox | ErrorBox | StyleBox | SubscriptBox | SuperscriptBox | SubsuperscriptBox | UnderscriptBox | OverscriptBox | UnderoverscriptBox

mutableIsolatingBoxes = TagBox | InterpretationBox

allTheBoxes = nonIsolatingBoxes | isolatingBoxes | mutableIsolatingBoxes

boxStructureQ[nonIsolatingBoxes[\[ScriptA]\[ScriptR]\[ScriptG]\[ScriptS]___]] := True
boxStructureQ[isolatingBoxes[\[ScriptA]\[ScriptR]\[ScriptG]\[ScriptS]___]] := True
boxStructureQ[mutableIsolatingBoxes[\[ScriptA]\[ScriptR]\[ScriptG]\[ScriptS]___]] := True
boxStructureQ[_] := False

\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]:boxStructureQ[___] := With[{\[ScriptN]\[ScriptU]\[ScriptM] = heldLength[\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]]}, $Failed /; \[ScriptN]\[ScriptU]\[ScriptM] != 1 && Message[boxStructureQ::argx, HoldForm[boxStructureQ], \[ScriptN]\[ScriptU]\[ScriptM], 1]]

nonIsolatingBoxStructureQ[nonIsolatingBoxes[\[ScriptA]\[ScriptR]\[ScriptG]\[ScriptS]___]] := True
nonIsolatingBoxStructureQ[\[ScriptO]\[ScriptT]\[ScriptH]\[ScriptE]\[ScriptR]_] := False

\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]:nonIsolatingBoxStructureQ[___] := With[{\[ScriptN]\[ScriptU]\[ScriptM] = heldLength[\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]]}, $Failed /; \[ScriptN]\[ScriptU]\[ScriptM] != 1 && Message[nonIsolatingBoxStructureQ::argx, HoldForm[nonIsolatingBoxStructureQ], \[ScriptN]\[ScriptU]\[ScriptM], 1]]

mutableIsolatingBoxStructureQ[mutableIsolatingBoxes[\[ScriptA]\[ScriptR]\[ScriptG]\[ScriptS]___]] := True
mutableIsolatingBoxStructureQ[\[ScriptO]\[ScriptT]\[ScriptH]\[ScriptE]\[ScriptR]_] := False

\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]:mutableIsolatingBoxStructureQ[___] := With[{\[ScriptN]\[ScriptU]\[ScriptM] = heldLength[\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]]}, $Failed /; \[ScriptN]\[ScriptU]\[ScriptM] != 1 && Message[mutableIsolatingBoxStructureQ::argx, HoldForm[mutableIsolatingBoxStructureQ], \[ScriptN]\[ScriptU]\[ScriptM], 1]]

effectiveBoxes[\[ScriptS]\[ScriptT]\[ScriptR]\[ScriptI]\[ScriptN]\[ScriptG]_String] := \[ScriptS]\[ScriptT]\[ScriptR]\[ScriptI]\[ScriptN]\[ScriptG]
effectiveBoxes[nonIsolatingBoxes[\[ScriptA]\[ScriptC]\[ScriptT]\[ScriptS]\[ScriptCapitalL]\[ScriptI]\[ScriptK]\[ScriptE]_, ___]] := effectiveBoxes[\[ScriptA]\[ScriptC]\[ScriptT]\[ScriptS]\[ScriptCapitalL]\[ScriptI]\[ScriptK]\[ScriptE]]
effectiveBoxes[mutableIsolatingBoxes[___, SyntaxForm -> \[ScriptA]\[ScriptC]\[ScriptT]\[ScriptS]\[ScriptCapitalL]\[ScriptI]\[ScriptK]\[ScriptE]_, ___]] := effectiveBoxes[\[ScriptA]\[ScriptC]\[ScriptT]\[ScriptS]\[ScriptCapitalL]\[ScriptI]\[ScriptK]\[ScriptE]]
effectiveBoxes[mutableIsolatingBoxes[\[ScriptA]\[ScriptC]\[ScriptT]\[ScriptS]\[ScriptCapitalL]\[ScriptI]\[ScriptK]\[ScriptE]_, ___]] := effectiveBoxes[\[ScriptA]\[ScriptC]\[ScriptT]\[ScriptS]\[ScriptCapitalL]\[ScriptI]\[ScriptK]\[ScriptE]]
effectiveBoxes[isolatingBoxes[___]] := "GenericSymbol"
effectiveBoxes[\[ScriptO]\[ScriptT]\[ScriptH]\[ScriptE]\[ScriptR]_] := "GenericSymbol"

\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]:effectiveBoxes[(\[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalA]\[ScriptR]\[ScriptG]_)?(isNot[_?boxStructureQ]), ___] := $Failed /; Message[effectiveBoxes::badarg, 1, HoldForm[\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]]]

effectiveBoxes::badarg = "Box structure or String expected at position `1` in `2`"

\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]:effectiveBoxes[___] := With[{\[ScriptN]\[ScriptU]\[ScriptM] = heldLength[\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]]}, $Failed /; \[ScriptN]\[ScriptU]\[ScriptM] != 1 && Message[effectiveBoxes::argx, HoldForm[effectiveBoxes], \[ScriptN]\[ScriptU]\[ScriptM], 1]]

prefixOperatorQ[(\[ScriptS]\[ScriptT]\[ScriptR]\[ScriptU]\[ScriptC]\[ScriptT]_)?nonIsolatingBoxStructureQ] := prefixOperatorQ[effectiveBoxes[\[ScriptS]\[ScriptT]\[ScriptR]\[ScriptU]\[ScriptC]\[ScriptT]]]
prefixOperatorQ[(\[ScriptS]\[ScriptT]\[ScriptR]\[ScriptU]\[ScriptC]\[ScriptT]_)?mutableIsolatingBoxStructureQ] := prefixOperatorQ[effectiveBoxes[\[ScriptS]\[ScriptT]\[ScriptR]\[ScriptU]\[ScriptC]\[ScriptT]]]

prefixOperatorQ["\[PartialD]"] = True
prefixOperatorQ["\[Integral]"] = True
prefixOperatorQ["\[ContourIntegral]"] = True
prefixOperatorQ["\[CounterClockwiseContourIntegral]"] = True
prefixOperatorQ["\[ClockwiseContourIntegral]"] = True
prefixOperatorQ["\[DoubleContourIntegral]"] = True
prefixOperatorQ["\[Sum]"] = True
prefixOperatorQ["\[Product]"] = True

prefixOperatorQ["!"] = True
prefixOperatorQ[(\[ScriptC]\[ScriptH]\[ScriptA]\[ScriptR]_)?characterQ] := "Prefix" == characterInformation[\[ScriptC]\[ScriptH]\[ScriptA]\[ScriptR], CharacterFixity]
prefixOperatorQ[\[ScriptO]\[ScriptT]\[ScriptH]\[ScriptE]\[ScriptR]_] := False

\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]:prefixOperatorQ[___] := With[{\[ScriptN]\[ScriptU]\[ScriptM] = heldLength[\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]]}, $Failed /; \[ScriptN]\[ScriptU]\[ScriptM] != 1 && Message[prefixOperatorQ::argx, HoldForm[prefixOperatorQ], \[ScriptN]\[ScriptU]\[ScriptM], 1]]

infixOperatorQ[(\[ScriptS]\[ScriptT]\[ScriptR]\[ScriptU]\[ScriptC]\[ScriptT]_)?nonIsolatingBoxStructureQ] := infixOperatorQ[effectiveBoxes[\[ScriptS]\[ScriptT]\[ScriptR]\[ScriptU]\[ScriptC]\[ScriptT]]]
infixOperatorQ[(\[ScriptS]\[ScriptT]\[ScriptR]\[ScriptU]\[ScriptC]\[ScriptT]_)?mutableIsolatingBoxStructureQ] := infixOperatorQ[effectiveBoxes[\[ScriptS]\[ScriptT]\[ScriptR]\[ScriptU]\[ScriptC]\[ScriptT]]]

infixOperatorQ["+"] = True
infixOperatorQ["*"] = True
infixOperatorQ["^"] = True
infixOperatorQ["."] = True
infixOperatorQ["-"] = True
infixOperatorQ["->"] = True
infixOperatorQ[":>"] = True
infixOperatorQ["="] = True
infixOperatorQ[":="] = True
infixOperatorQ["^="] = True
infixOperatorQ["^:="] = True
infixOperatorQ["+="] = True
infixOperatorQ["-="] = True
infixOperatorQ["*="] = True
infixOperatorQ["/="] = True
infixOperatorQ["/."] = True
infixOperatorQ["//."] = True
infixOperatorQ["//"] = True
infixOperatorQ["/;"] = True
infixOperatorQ["/"] = True
infixOperatorQ[":"] = True
infixOperatorQ[";"] = True
infixOperatorQ["<="] = True
infixOperatorQ["<"] = True
infixOperatorQ[">"] = True
infixOperatorQ[">="] = True
infixOperatorQ["=="] = True
infixOperatorQ["==="] = True
infixOperatorQ["!"] = True
infixOperatorQ["!="] = True
infixOperatorQ["=!="] = True
infixOperatorQ["&&"] = True
infixOperatorQ["||"] = True
infixOperatorQ["?"] = True
infixOperatorQ["@@"] = True
infixOperatorQ["@"] = True
infixOperatorQ["/@"] = True
infixOperatorQ["||"] = True
infixOperatorQ["|"] = True

infixOperatorQ[(\[ScriptC]\[ScriptH]\[ScriptA]\[ScriptR]_)?characterQ] := "Infix" == characterInformation[\[ScriptC]\[ScriptH]\[ScriptA]\[ScriptR], CharacterFixity]
infixOperatorQ[\[ScriptO]\[ScriptT]\[ScriptH]\[ScriptE]\[ScriptR]_] := False

\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]:infixOperatorQ[___] := With[{\[ScriptN]\[ScriptU]\[ScriptM] = heldLength[\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]]}, $Failed /; \[ScriptN]\[ScriptU]\[ScriptM] != 1 && Message[infixOperatorQ::argx, HoldForm[infixOperatorQ], \[ScriptN]\[ScriptU]\[ScriptM], 1]]

postfixOperatorQ[(\[ScriptS]\[ScriptT]\[ScriptR]\[ScriptU]\[ScriptC]\[ScriptT]_)?nonIsolatingBoxStructureQ] := postfixOperatorQ[effectiveBoxes[\[ScriptS]\[ScriptT]\[ScriptR]\[ScriptU]\[ScriptC]\[ScriptT]]]
postfixOperatorQ[(\[ScriptS]\[ScriptT]\[ScriptR]\[ScriptU]\[ScriptC]\[ScriptT]_)?mutableIsolatingBoxStructureQ] := postfixOperatorQ[effectiveBoxes[\[ScriptS]\[ScriptT]\[ScriptR]\[ScriptU]\[ScriptC]\[ScriptT]]]

postfixOperatorQ[";"] = True
postfixOperatorQ["&"] = True
postfixOperatorQ["!!"] = True
postfixOperatorQ["!"] = True
postfixOperatorQ["'"] = True
postfixOperatorQ["--"] = True
postfixOperatorQ["++"] = True
postfixOperatorQ["=."] = True
postfixOperatorQ[".."] = True
postfixOperatorQ["..."] = True
postfixOperatorQ[\[ScriptO]\[ScriptT]\[ScriptH]\[ScriptE]\[ScriptR]_] = False

postfixOperatorQ[(\[ScriptC]\[ScriptH]\[ScriptA]\[ScriptR]_)?characterQ] := "Postfix" == characterInformation[\[ScriptC]\[ScriptH]\[ScriptA]\[ScriptR], CharacterFixity]
postfixOperatorQ[\[ScriptO]\[ScriptT]\[ScriptH]\[ScriptE]\[ScriptR]_] := False

\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]:postfixOperatorQ[___] := With[{\[ScriptN]\[ScriptU]\[ScriptM] = heldLength[\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]]}, $Failed /; \[ScriptN]\[ScriptU]\[ScriptM] != 1 && Message[postfixOperatorQ::argx, HoldForm[postfixOperatorQ], \[ScriptN]\[ScriptU]\[ScriptM], 1]]

operatorQ[\[ScriptB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]_] := prefixOperatorQ[\[ScriptB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]] || infixOperatorQ[\[ScriptB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]] || postfixOperatorQ[\[ScriptB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]]

\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]:operatorQ[___] := With[{\[ScriptN]\[ScriptU]\[ScriptM] = heldLength[\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]]}, $Failed /; \[ScriptN]\[ScriptU]\[ScriptM] != 1 && Message[operatorQ::argx, HoldForm[operatorQ], \[ScriptN]\[ScriptU]\[ScriptM], 1]]

delimiterQ[(\[ScriptS]\[ScriptT]\[ScriptR]\[ScriptU]\[ScriptC]\[ScriptT]_)?nonIsolatingBoxStructureQ] := delimiterQ[effectiveBoxes[\[ScriptS]\[ScriptT]\[ScriptR]\[ScriptU]\[ScriptC]\[ScriptT]]]
delimiterQ[(\[ScriptS]\[ScriptT]\[ScriptR]\[ScriptU]\[ScriptC]\[ScriptT]_)?mutableIsolatingBoxStructureQ] := delimiterQ[effectiveBoxes[\[ScriptS]\[ScriptT]\[ScriptR]\[ScriptU]\[ScriptC]\[ScriptT]]]

delimiterQ["\[InvisibleComma]"] = True
delimiterQ[","] = True
delimiterQ["["] = True
delimiterQ["]"] = True
delimiterQ["("] = True
delimiterQ[")"] = True
delimiterQ["{"] = True
delimiterQ["}"] = True

delimiterQ[(\[ScriptC]\[ScriptH]\[ScriptA]\[ScriptR]_)?characterQ] := With[{\[ScriptT]\[ScriptH]\[ScriptE]\[ScriptCapitalF]\[ScriptI]\[ScriptX]\[ScriptI]\[ScriptT]\[ScriptY] = characterInformation[\[ScriptC]\[ScriptH]\[ScriptA]\[ScriptR], CharacterFixity]}, \[ScriptT]\[ScriptH]\[ScriptE]\[ScriptCapitalF]\[ScriptI]\[ScriptX]\[ScriptI]\[ScriptT]\[ScriptY] == "Open" || \[ScriptT]\[ScriptH]\[ScriptE]\[ScriptCapitalF]\[ScriptI]\[ScriptX]\[ScriptI]\[ScriptT]\[ScriptY] == "InfixOpen" || \[ScriptT]\[ScriptH]\[ScriptE]\[ScriptCapitalF]\[ScriptI]\[ScriptX]\[ScriptI]\[ScriptT]\[ScriptY] == "Close"]
delimiterQ[\[ScriptO]\[ScriptT]\[ScriptH]\[ScriptE]\[ScriptR]_] := False

\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]:delimiterQ[___] := With[{\[ScriptN]\[ScriptU]\[ScriptM] = heldLength[\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]]}, $Failed /; \[ScriptN]\[ScriptU]\[ScriptM] != 1 && Message[delimiterQ::argx, HoldForm[delimiterQ], \[ScriptN]\[ScriptU]\[ScriptM], 1]]

infixOperatorTokenToSymbol[\[ScriptI]\[ScriptN]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptO]\[ScriptP]_String] := silentEvaluate[Check[Module[{\[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR] = ToHeldExpression[StringJoin["a", \[ScriptI]\[ScriptN]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptO]\[ScriptP], "b"]]}, If[Depth[\[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR]] == 3, \[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR][[1,0]], Times]], Times]]

prefixOperatorTokenToSymbol["\[PartialD]"] = D
prefixOperatorTokenToSymbol["\[Integral]"] = Integrate
prefixOperatorTokenToSymbol["\[ContourIntegral]"] = Integrate
prefixOperatorTokenToSymbol["\[CounterClockwiseContourIntegral]"] = Integrate
prefixOperatorTokenToSymbol["\[ClockwiseContourIntegral]"] = Integrate
prefixOperatorTokenToSymbol["\[DoubleContourIntegral]"] = Integrate
prefixOperatorTokenToSymbol[\[ScriptP]\[ScriptR]\[ScriptE]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptCapitalO]\[ScriptP]_String] := silentEvaluate[Check[Module[{\[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR] = ToHeldExpression[StringJoin[\[ScriptP]\[ScriptR]\[ScriptE]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptCapitalO]\[ScriptP], "b"]]}, If[Depth[\[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR]] == 3, \[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR][[1,0]], Times]], Times]]

postfixOperatorTokenToSymbol["'"] = Derivative
postfixOperatorTokenToSymbol[\[ScriptP]\[ScriptO]\[ScriptS]\[ScriptT]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptCapitalO]\[ScriptP]_String] := silentEvaluate[Check[Module[{\[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR] = ToHeldExpression[StringJoin["b", \[ScriptP]\[ScriptO]\[ScriptS]\[ScriptT]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptCapitalO]\[ScriptP]]]}, If[Depth[\[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR]] == 3, \[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR][[1,0]], Times]], Times]]

\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]:infixOperatorTokenToSymbol[(\[ScriptN]\[ScriptO]\[ScriptT]\[ScriptCapitalS]\[ScriptT]\[ScriptR]\[ScriptI]\[ScriptN]\[ScriptG]_)?(headIsNot[String]), ___] := $Failed /; Message[infixOperatorTokenToSymbol::string, 1, HoldForm[\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]]]

\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]:prefixOperatorTokenToSymbol[(\[ScriptN]\[ScriptO]\[ScriptT]\[ScriptCapitalS]\[ScriptT]\[ScriptR]\[ScriptI]\[ScriptN]\[ScriptG]_)?(headIsNot[String]), ___] := $Failed /; Message[prefixOperatorTokenToSymbol::string, 1, HoldForm[\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]]]

\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]:postfixOperatorTokenToSymbol[(\[ScriptN]\[ScriptO]\[ScriptT]\[ScriptCapitalS]\[ScriptT]\[ScriptR]\[ScriptI]\[ScriptN]\[ScriptG]_)?(headIsNot[String]), ___] := $Failed /; Message[postfixOperatorTokenToSymbol::string, 1, HoldForm[\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]]]

\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]:infixOperatorTokenToSymbol[___] := With[{\[ScriptN]\[ScriptU]\[ScriptM] = heldLength[\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]]}, $Failed /; \[ScriptN]\[ScriptU]\[ScriptM] != 1 && Message[infixOperatorTokenToSymbol::argx, HoldForm[infixOperatorTokenToSymbol], \[ScriptN]\[ScriptU]\[ScriptM], 1]]

\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]:prefixOperatorTokenToSymbol[___] := With[{\[ScriptN]\[ScriptU]\[ScriptM] = heldLength[\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]]}, $Failed /; \[ScriptN]\[ScriptU]\[ScriptM] != 1 && Message[prefixOperatorTokenToSymbol::argx, HoldForm[prefixOperatorTokenToSymbol], \[ScriptN]\[ScriptU]\[ScriptM], 1]]

\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]:postfixOperatorTokenToSymbol[___] := With[{\[ScriptN]\[ScriptU]\[ScriptM] = heldLength[\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]]}, $Failed /; \[ScriptN]\[ScriptU]\[ScriptM] != 1 && Message[postfixOperatorTokenToSymbol::argx, HoldForm[postfixOperatorTokenToSymbol], \[ScriptN]\[ScriptU]\[ScriptM], 1]]

effectiveOperator[(\[ScriptS]\[ScriptT]\[ScriptR]\[ScriptU]\[ScriptC]\[ScriptT]_)?boxStructureQ] := effectiveOperator[effectiveBoxes[\[ScriptS]\[ScriptT]\[ScriptR]\[ScriptU]\[ScriptC]\[ScriptT]]]

effectiveOperator["\[PartialD]"] = D

effectiveOperator["\[Integral]"] = Integrate
effectiveOperator["\[ContourIntegral]"] = Integrate
effectiveOperator["\[ClockwiseContourIntegral]"] = Integrate
effectiveOperator["\[CounterClockwiseContourIntegral]"] = Integrate
effectiveOperator["\[ClockwiseContourIntegral]"] = Integrate

effectiveOperator[(\[ScriptO]\[ScriptP]_)?prefixOperatorQ] := prefixOperatorTokenToSymbol[\[ScriptO]\[ScriptP]]
effectiveOperator[(\[ScriptO]\[ScriptP]_)?infixOperatorQ] := infixOperatorTokenToSymbol[\[ScriptO]\[ScriptP]]
effectiveOperator[(\[ScriptO]\[ScriptP]_)?postfixOperatorQ] := postfixOperatorTokenToSymbol[\[ScriptO]\[ScriptP]]
effectiveOperator[other_] := Times

\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]:effectiveOperator[___] := With[{\[ScriptN]\[ScriptU]\[ScriptM] = heldLength[\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]]}, $Failed /; \[ScriptN]\[ScriptU]\[ScriptM] != 1 && Message[effectiveOperator::argx, HoldForm[effectiveOperator], \[ScriptN]\[ScriptU]\[ScriptM], 1]]

SetAttributes[{myHold, releaseMyHold}, HoldAllComplete]

releaseMyHold[\[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR]___] := Evaluate @@ (HoldComplete[\[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR]] //. myHold[\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptM]___] -> \[ScriptT]\[ScriptE]\[ScriptR]\[ScriptM])

flattenAllMyHold[\[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR]_] := myHold @@ (HoldComplete[\[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR]] //. myHold[\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptM]___] -> \[ScriptT]\[ScriptE]\[ScriptR]\[ScriptM])

toMyHeldExpression[\[ScriptA]\[ScriptR]\[ScriptG]\[ScriptS]___] := myHold @@ MakeExpression[\[ScriptA]\[ScriptR]\[ScriptG]\[ScriptS]]

removePatternsAndBlanks[\[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR]_] := Evaluate @@ (myHold[\[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR]] //. {(\[ScriptH]\[ScriptO]\[ScriptL]\[ScriptD]\[ScriptCapitalH]\[ScriptE]\[ScriptA]\[ScriptD]:Optional)[\[ScriptA]_, ___] -> \[ScriptA], (\[ScriptH]\[ScriptO]\[ScriptL]\[ScriptD]\[ScriptCapitalH]\[ScriptE]\[ScriptA]\[ScriptD]:Pattern)[\[ScriptA]_, ___] -> \[ScriptA], (\[ScriptH]\[ScriptO]\[ScriptL]\[ScriptD]\[ScriptCapitalH]\[ScriptE]\[ScriptA]\[ScriptD]:PatternTest)[\[ScriptA]_, ___] -> \[ScriptA], (\[ScriptH]\[ScriptO]\[ScriptL]\[ScriptD]\[ScriptCapitalH]\[ScriptE]\[ScriptA]\[ScriptD]:Condition)[\[ScriptA]_, ___] -> \[ScriptA]})

\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]:removePatternsAndBlanks[___] := With[{\[ScriptN]\[ScriptU]\[ScriptM] = heldLength[\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]]}, $Failed /; \[ScriptN]\[ScriptU]\[ScriptM] != 1 && Message[removePatternsAndBlanks::argx, HoldForm[removePatternsAndBlanks], \[ScriptN]\[ScriptU]\[ScriptM], 1]]

convertPatterns[\[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR]_] := myHold[\[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR]] //. {(\[ScriptH]\[ScriptO]\[ScriptL]\[ScriptD]\[ScriptCapitalH]\[ScriptE]\[ScriptA]\[ScriptD]:Optional)[\[ScriptA]_, ___] -> \[ScriptA], (\[ScriptH]\[ScriptO]\[ScriptL]\[ScriptD]\[ScriptCapitalH]\[ScriptE]\[ScriptA]\[ScriptD]:Pattern)[\[ScriptA]_, _Blank] -> singleBlank[\[ScriptA]], (\[ScriptH]\[ScriptO]\[ScriptL]\[ScriptD]\[ScriptCapitalH]\[ScriptE]\[ScriptA]\[ScriptD]:Pattern)[\[ScriptA]_, _BlankSequence] -> doubleBlank[\[ScriptA]], (\[ScriptH]\[ScriptO]\[ScriptL]\[ScriptD]\[ScriptCapitalH]\[ScriptE]\[ScriptA]\[ScriptD]:Pattern)[\[ScriptA]_, _BlankNullSequence] -> tripleBlank[\[ScriptA]], (\[ScriptH]\[ScriptO]\[ScriptL]\[ScriptD]\[ScriptCapitalH]\[ScriptE]\[ScriptA]\[ScriptD]:Pattern)[\[ScriptA]_, _] -> complexPattern[\[ScriptA]], (\[ScriptH]\[ScriptO]\[ScriptL]\[ScriptD]\[ScriptCapitalH]\[ScriptE]\[ScriptA]\[ScriptD]:PatternTest)[\[ScriptA]_, ___] -> \[ScriptA], (\[ScriptH]\[ScriptO]\[ScriptL]\[ScriptD]\[ScriptCapitalH]\[ScriptE]\[ScriptA]\[ScriptD]:Condition)[\[ScriptA]_, ___] -> \[ScriptA], _Blank -> singleBlank[], _BlankSequence -> doubleBlank[], _BlankNullSequence -> tripleBlank[]}

SetAttributes[{singleBlank, doubleBlank, tripleBlank, complexPattern}, HoldAll]

\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]:convertPatterns[___] := With[{\[ScriptN]\[ScriptU]\[ScriptM] = heldLength[\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]]}, $Failed /; \[ScriptN]\[ScriptU]\[ScriptM] != 1 && Message[convertPatterns::argx, HoldForm[convertPatterns], \[ScriptN]\[ScriptU]\[ScriptM], 1]]

cleanBoxes[\[ScriptB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]_] := \[ScriptB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS] //. {RowBox[{\[ScriptS]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptL]\[ScriptE]_}] :> \[ScriptS]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptL]\[ScriptE], RowBox[{RowBox[{\[ScriptA]\[ScriptR]\[ScriptG]\[ScriptS]___}]}] :> RowBox[{\[ScriptA]\[ScriptR]\[ScriptG]\[ScriptS]}], RowBox[{\[ScriptL]___, (\[ScriptS]\[ScriptP]\[ScriptA]\[ScriptC]\[ScriptE]_)?whiteSpaceQ, \[ScriptR]___}] :> RowBox[{\[ScriptL], \[ScriptR]}]}

tidyBoxes[\[ScriptB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]_] := \[ScriptB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS] //. {RowBox[{RowBox[{\[ScriptA]\[ScriptR]\[ScriptG]\[ScriptS]___}]}] :> RowBox[{\[ScriptA]\[ScriptR]\[ScriptG]\[ScriptS]}], RowBox[{\[ScriptL]___, RowBox[{\[ScriptS]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptL]\[ScriptE]_}], \[ScriptR]___}] :> RowBox[{\[ScriptL], \[ScriptS]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptL]\[ScriptE], \[ScriptR]}]}

\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]:cleanBoxes[___] := With[{\[ScriptN]\[ScriptU]\[ScriptM] = heldLength[\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]]}, $Failed /; \[ScriptN]\[ScriptU]\[ScriptM] != 1 && Message[cleanBoxes::argx, HoldForm[cleanBoxes], \[ScriptN]\[ScriptU]\[ScriptM], 1]]

\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]:tidyBoxes[___] := With[{\[ScriptN]\[ScriptU]\[ScriptM] = heldLength[\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]]}, $Failed /; \[ScriptN]\[ScriptU]\[ScriptM] != 1 && Message[tidyBoxes::argx, HoldForm[tidyBoxes], \[ScriptN]\[ScriptU]\[ScriptM], 1]]

SetAttributes[stripStylingBoxes, HoldAll]
stripStylingBoxes[StyleBox[\[ScriptB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]_, \[ScriptS]\[ScriptT]\[ScriptY]\[ScriptL]\[ScriptE]\[ScriptS]___]] := stripStylingBoxes[\[ScriptB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]]
stripStylingBoxes[AdjustmentBox[\[ScriptB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]_, \[ScriptS]\[ScriptT]\[ScriptY]\[ScriptL]\[ScriptE]\[ScriptS]___]] := stripStylingBoxes[\[ScriptB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]]
stripStylingBoxes[FrameBox[\[ScriptB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]_, \[ScriptS]\[ScriptT]\[ScriptY]\[ScriptL]\[ScriptE]\[ScriptS]___]] := stripStylingBoxes[\[ScriptB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]]
stripStylingBoxes[TagBox[\[ScriptB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]___]] := TagBox[\[ScriptB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]]
stripStylingBoxes[RowBox[\[ScriptB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]___]] := RowBox[stripStylingBoxes /@ \[ScriptB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]]
stripStylingBoxes[(\[ScriptA]_)[\[ScriptA]\[ScriptR]\[ScriptG]\[ScriptS]__]] /; boxStructureQ[\[ScriptA][\[ScriptA]\[ScriptR]\[ScriptG]\[ScriptS]]] := \[ScriptA] @@ stripStylingBoxes /@ {\[ScriptA]\[ScriptR]\[ScriptG]\[ScriptS]}
stripStylingBoxes[{\[ScriptA]\[ScriptR]\[ScriptG]\[ScriptS]__}] := stripStylingBoxes /@ {\[ScriptA]\[ScriptR]\[ScriptG]\[ScriptS]}
stripStylingBoxes[\[ScriptA]_] := \[ScriptA]

\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]:stripStylingBoxes[___] := With[{\[ScriptN]\[ScriptU]\[ScriptM] = heldLength[\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]]}, $Failed /; \[ScriptN]\[ScriptU]\[ScriptM] != 1 && Message[stripStylingBoxes::argx, HoldForm[stripStylingBoxes], \[ScriptN]\[ScriptU]\[ScriptM], 1]]

padList[\[ScriptL]\[ScriptI]\[ScriptS]\[ScriptT]_List, \[ScriptP]\[ScriptA]\[ScriptD]\[ScriptCapitalE]\[ScriptL]\[ScriptE]\[ScriptM]\[ScriptE]\[ScriptN]\[ScriptT]_] := (Drop[#1, -1] & )[Flatten[Thread[{\[ScriptL]\[ScriptI]\[ScriptS]\[ScriptT], \[ScriptP]\[ScriptA]\[ScriptD]\[ScriptCapitalE]\[ScriptL]\[ScriptE]\[ScriptM]\[ScriptE]\[ScriptN]\[ScriptT]}]]]

\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]:padList[(\[ScriptN]\[ScriptO]\[ScriptT]\[ScriptCapitalL]\[ScriptI]\[ScriptS]\[ScriptT]_)?(headIsNot[List]), ___] := $Failed /; Message[padList::list, HoldForm[\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]], 1]

\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]:padList[___] := With[{\[ScriptN]\[ScriptU]\[ScriptM] = heldLength[\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]]}, $Failed /; Which[\[ScriptN]\[ScriptU]\[ScriptM] == 1, Message[padList::argr, HoldForm[padList], 2], \[ScriptN]\[ScriptU]\[ScriptM] != 2, Message[padList::argrx, HoldForm[padList], \[ScriptN]\[ScriptU]\[ScriptM], 2], True, False]]

wasProtected = Unprotect[FullForm]
FullForm/: TagBox[StyleBox[\[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR]_, Verbatim[ShowSpecialCharacters -> False], \[ScriptR]\[ScriptE]\[ScriptS]\[ScriptT]__], FullForm] := TagBox[StyleBox[\[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR], \[ScriptR]\[ScriptE]\[ScriptS]\[ScriptT]], FullForm]
Protect[Evaluate[wasProtected]]

SetDelayed[boxedStringPatternsToPatterns[Pattern[\[ScriptP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], Blank[]], PatternTest[Pattern[\[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS], BlankNullSequence[]], OptionQ]], Module[List[Set[\[ScriptCapitalW]\[ScriptO]\[ScriptR]\[ScriptK]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM], ReplaceAll[ReplaceAll[WorkingForm, List[\[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS]]], adjustedOptions[Notation]]]], Apply[stripStylingBoxes, List[ReplaceRepeated[\[ScriptP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], List[RuleDelayed[HoldPattern[NotationBoxTag][Pattern[\[ScriptS]\[ScriptT]\[ScriptR]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], Blank[]]], \[ScriptS]\[ScriptT]\[ScriptR]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]], RuleDelayed[TagBox[Pattern[\[ScriptS]\[ScriptT]\[ScriptR]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], Blank[]], NotationPatternTag, BlankNullSequence[]], toMyHeldExpression[\[ScriptS]\[ScriptT]\[ScriptR]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], \[ScriptCapitalW]\[ScriptO]\[ScriptR]\[ScriptK]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM]]], RuleDelayed[TagBox[Pattern[\[ScriptS]\[ScriptT]\[ScriptR]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], Blank[]], NotationMadeBoxesTag, BlankNullSequence[]], toMyHeldExpression[\[ScriptS]\[ScriptT]\[ScriptR]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], \[ScriptCapitalW]\[ScriptO]\[ScriptR]\[ScriptK]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM]]], RuleDelayed[Condition[Pattern[\[ScriptS]\[ScriptT]\[ScriptR]\[ScriptI]\[ScriptN]\[ScriptG], Blank[String]], StringMatchQ[\[ScriptS]\[ScriptT]\[ScriptR]\[ScriptI]\[ScriptN]\[ScriptG], "*_"]], ToExpression[\[ScriptS]\[ScriptT]\[ScriptR]\[ScriptI]\[ScriptN]\[ScriptG], \[ScriptCapitalW]\[ScriptO]\[ScriptR]\[ScriptK]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM]]]]]]]]]

\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]:boxedStringPatternsToPatterns[_, ___, (\[ScriptN]\[ScriptO]\[ScriptT]\[ScriptCapitalO]\[ScriptP]\[ScriptT]\[ScriptI]\[ScriptO]\[ScriptN]_)?(isNot[_?OptionQ]), ___] := $Failed /; Message[boxedStringPatternsToPatterns::nonopt, HoldForm[\[ScriptN]\[ScriptO]\[ScriptT]\[ScriptCapitalO]\[ScriptP]\[ScriptT]\[ScriptI]\[ScriptO]\[ScriptN]], 1, HoldForm[\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]]]

SetAttributes[patternToGeneralQ, HoldAll]

patternToGeneralQ[(Blank | BlankNull | BlankSequence | BlankNullSequence)[___]] := True
patternToGeneralQ[HoldPattern[Pattern][_, \[ScriptP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptCapitalC]\[ScriptO]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptN]\[ScriptT]_]] := patternToGeneralQ[\[ScriptP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptCapitalC]\[ScriptO]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptN]\[ScriptT]]
patternToGeneralQ[myHold[\[ScriptP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptCapitalC]\[ScriptO]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptN]\[ScriptT]___]] := patternToGeneralQ[\[ScriptP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptCapitalC]\[ScriptO]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptN]\[ScriptT]]
patternToGeneralQ[___] := False

SetAttributes[{makeHeldSequenceOfBoxes, makeHeldRowBoxOfBoxes}, {HoldAllComplete}]

makeHeldSequenceOfBoxes[{}, \[ScriptF]\[ScriptO]\[ScriptR]\[ScriptM]_Symbol, None] := Sequence[]
makeHeldSequenceOfBoxes[{\[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR]_}, \[ScriptF]\[ScriptO]\[ScriptR]\[ScriptM]_Symbol, None] := MakeBoxes[\[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR], \[ScriptF]\[ScriptO]\[ScriptR]\[ScriptM]]
makeHeldSequenceOfBoxes[{\[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR]_}, \[ScriptF]\[ScriptO]\[ScriptR]\[ScriptM]_Symbol, \[ScriptP]\[ScriptA]\[ScriptR]\[ScriptE]\[ScriptN]\[ScriptT]\[ScriptH]\[ScriptE]\[ScriptS]\[ScriptI]\[ScriptZ]\[ScriptE]\[ScriptD]\[ScriptCapitalB]\[ScriptY]_Symbol] := Parenthesize[\[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR], \[ScriptF]\[ScriptO]\[ScriptR]\[ScriptM], \[ScriptP]\[ScriptA]\[ScriptR]\[ScriptE]\[ScriptN]\[ScriptT]\[ScriptH]\[ScriptE]\[ScriptS]\[ScriptI]\[ScriptZ]\[ScriptE]\[ScriptD]\[ScriptCapitalB]\[ScriptY]]
makeHeldSequenceOfBoxes[{\[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR]___}, \[ScriptF]\[ScriptO]\[ScriptR]\[ScriptM]_Symbol, None] := (Sequence @@ Drop[#1, -1] & )[Flatten[Thread[{Function[\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptM], MakeBoxes[\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptM], \[ScriptF]\[ScriptO]\[ScriptR]\[ScriptM]], {HoldAll}] /@ Unevaluated[{\[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR]}], ","}]]]
makeHeldSequenceOfBoxes[{\[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR]___}, \[ScriptF]\[ScriptO]\[ScriptR]\[ScriptM]_Symbol, \[ScriptP]\[ScriptA]\[ScriptR]\[ScriptE]\[ScriptN]\[ScriptT]\[ScriptH]\[ScriptE]\[ScriptS]\[ScriptI]\[ScriptZ]\[ScriptE]\[ScriptD]\[ScriptCapitalB]\[ScriptY]_Symbol] := (Sequence @@ Drop[#1, -1] & )[Flatten[Thread[{Function[\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptM], Parenthesize[\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptM], \[ScriptF]\[ScriptO]\[ScriptR]\[ScriptM], \[ScriptP]\[ScriptA]\[ScriptR]\[ScriptE]\[ScriptN]\[ScriptT]\[ScriptH]\[ScriptE]\[ScriptS]\[ScriptI]\[ScriptZ]\[ScriptE]\[ScriptD]\[ScriptCapitalB]\[ScriptY]], {HoldAll}] /@ Unevaluated[{\[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR]}], ","}]]]

makeHeldRowBoxOfBoxes[{}, \[ScriptF]\[ScriptO]\[ScriptR]\[ScriptM]_Symbol, None] := \(\)
makeHeldRowBoxOfBoxes[{\[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR]_}, \[ScriptF]\[ScriptO]\[ScriptR]\[ScriptM]_Symbol, None] := MakeBoxes[\[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR], \[ScriptF]\[ScriptO]\[ScriptR]\[ScriptM]]
makeHeldRowBoxOfBoxes[{\[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR]_}, \[ScriptF]\[ScriptO]\[ScriptR]\[ScriptM]_Symbol, \[ScriptP]\[ScriptA]\[ScriptR]\[ScriptE]\[ScriptN]\[ScriptT]\[ScriptH]\[ScriptE]\[ScriptS]\[ScriptI]\[ScriptZ]\[ScriptE]\[ScriptD]\[ScriptCapitalB]\[ScriptY]_Symbol] := Parenthesize[\[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR], \[ScriptF]\[ScriptO]\[ScriptR]\[ScriptM], \[ScriptP]\[ScriptA]\[ScriptR]\[ScriptE]\[ScriptN]\[ScriptT]\[ScriptH]\[ScriptE]\[ScriptS]\[ScriptI]\[ScriptZ]\[ScriptE]\[ScriptD]\[ScriptCapitalB]\[ScriptY]]
makeHeldRowBoxOfBoxes[{\[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR]___}, \[ScriptF]\[ScriptO]\[ScriptR]\[ScriptM]_Symbol, None] := (RowBox[Drop[#1, -1]] & )[Flatten[Thread[{Function[\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptM], MakeBoxes[\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptM], \[ScriptF]\[ScriptO]\[ScriptR]\[ScriptM]], {HoldAll}] /@ Unevaluated[{\[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR]}], ","}]]]
makeHeldRowBoxOfBoxes[{\[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR]___}, \[ScriptF]\[ScriptO]\[ScriptR]\[ScriptM]_Symbol, \[ScriptP]\[ScriptA]\[ScriptR]\[ScriptE]\[ScriptN]\[ScriptT]\[ScriptH]\[ScriptE]\[ScriptS]\[ScriptI]\[ScriptZ]\[ScriptE]\[ScriptD]\[ScriptCapitalB]\[ScriptY]_Symbol] := (RowBox[Drop[#1, -1]] & )[Flatten[Thread[{Function[\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptM], Parenthesize[\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptM], \[ScriptF]\[ScriptO]\[ScriptR]\[ScriptM], \[ScriptP]\[ScriptA]\[ScriptR]\[ScriptE]\[ScriptN]\[ScriptT]\[ScriptH]\[ScriptE]\[ScriptS]\[ScriptI]\[ScriptZ]\[ScriptE]\[ScriptD]\[ScriptCapitalB]\[ScriptY]], {HoldAll}] /@ Unevaluated[{\[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR]}], ","}]]]

makeEvaluatedSequenceOfBoxes[{}, \[ScriptF]\[ScriptO]\[ScriptR]\[ScriptM]_Symbol, None] := Sequence[]
makeEvaluatedSequenceOfBoxes[{\[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR]_}, \[ScriptF]\[ScriptO]\[ScriptR]\[ScriptM]_Symbol, None] := MakeBoxes[\[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR], \[ScriptF]\[ScriptO]\[ScriptR]\[ScriptM]]
makeEvaluatedSequenceOfBoxes[{\[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR]_}, \[ScriptF]\[ScriptO]\[ScriptR]\[ScriptM]_Symbol, \[ScriptP]\[ScriptA]\[ScriptR]\[ScriptE]\[ScriptN]\[ScriptT]\[ScriptH]\[ScriptE]\[ScriptS]\[ScriptI]\[ScriptZ]\[ScriptE]\[ScriptD]\[ScriptCapitalB]\[ScriptY]_Symbol] := Parenthesize[\[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR], \[ScriptF]\[ScriptO]\[ScriptR]\[ScriptM], \[ScriptP]\[ScriptA]\[ScriptR]\[ScriptE]\[ScriptN]\[ScriptT]\[ScriptH]\[ScriptE]\[ScriptS]\[ScriptI]\[ScriptZ]\[ScriptE]\[ScriptD]\[ScriptCapitalB]\[ScriptY]]
makeEvaluatedSequenceOfBoxes[{\[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR]___}, \[ScriptF]\[ScriptO]\[ScriptR]\[ScriptM]_Symbol, None] := (Sequence @@ Drop[#1, -1] & )[Flatten[Thread[{Function[\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptM], MakeBoxes[\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptM], \[ScriptF]\[ScriptO]\[ScriptR]\[ScriptM]], {HoldAll}] /@ Unevaluated[{\[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR]}], ","}]]]
makeEvaluatedSequenceOfBoxes[{\[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR]___}, \[ScriptF]\[ScriptO]\[ScriptR]\[ScriptM]_Symbol, \[ScriptP]\[ScriptA]\[ScriptR]\[ScriptE]\[ScriptN]\[ScriptT]\[ScriptH]\[ScriptE]\[ScriptS]\[ScriptI]\[ScriptZ]\[ScriptE]\[ScriptD]\[ScriptCapitalB]\[ScriptY]_Symbol] := (Sequence @@ Drop[#1, -1] & )[Flatten[Thread[{Function[\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptM], Parenthesize[\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptM], \[ScriptF]\[ScriptO]\[ScriptR]\[ScriptM], \[ScriptP]\[ScriptA]\[ScriptR]\[ScriptE]\[ScriptN]\[ScriptT]\[ScriptH]\[ScriptE]\[ScriptS]\[ScriptI]\[ScriptZ]\[ScriptE]\[ScriptD]\[ScriptCapitalB]\[ScriptY]], {HoldAll}] /@ Unevaluated[{\[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR]}], ","}]]]

makeEvaluatedRowBoxOfBoxes[{}, \[ScriptF]\[ScriptO]\[ScriptR]\[ScriptM]_Symbol, None] := \(\)
makeEvaluatedRowBoxOfBoxes[{\[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR]_}, \[ScriptF]\[ScriptO]\[ScriptR]\[ScriptM]_Symbol, None] := MakeBoxes[\[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR], \[ScriptF]\[ScriptO]\[ScriptR]\[ScriptM]]
makeEvaluatedRowBoxOfBoxes[{\[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR]_}, \[ScriptF]\[ScriptO]\[ScriptR]\[ScriptM]_Symbol, \[ScriptP]\[ScriptA]\[ScriptR]\[ScriptE]\[ScriptN]\[ScriptT]\[ScriptH]\[ScriptE]\[ScriptS]\[ScriptI]\[ScriptZ]\[ScriptE]\[ScriptD]\[ScriptCapitalB]\[ScriptY]_Symbol] := Parenthesize[\[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR], \[ScriptF]\[ScriptO]\[ScriptR]\[ScriptM], \[ScriptP]\[ScriptA]\[ScriptR]\[ScriptE]\[ScriptN]\[ScriptT]\[ScriptH]\[ScriptE]\[ScriptS]\[ScriptI]\[ScriptZ]\[ScriptE]\[ScriptD]\[ScriptCapitalB]\[ScriptY]]
makeEvaluatedRowBoxOfBoxes[{\[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR]___}, \[ScriptF]\[ScriptO]\[ScriptR]\[ScriptM]_Symbol, None] := (RowBox[Drop[#1, -1]] & )[Flatten[Thread[{Function[\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptM], MakeBoxes[\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptM], \[ScriptF]\[ScriptO]\[ScriptR]\[ScriptM]], {HoldAll}] /@ Unevaluated[{\[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR]}], ","}]]]
makeEvaluatedRowBoxOfBoxes[{\[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR]___}, \[ScriptF]\[ScriptO]\[ScriptR]\[ScriptM]_Symbol, \[ScriptP]\[ScriptA]\[ScriptR]\[ScriptE]\[ScriptN]\[ScriptT]\[ScriptH]\[ScriptE]\[ScriptS]\[ScriptI]\[ScriptZ]\[ScriptE]\[ScriptD]\[ScriptCapitalB]\[ScriptY]_Symbol] := (RowBox[Drop[#1, -1]] & )[Flatten[Thread[{Function[\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptM], Parenthesize[\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptM], \[ScriptF]\[ScriptO]\[ScriptR]\[ScriptM], \[ScriptP]\[ScriptA]\[ScriptR]\[ScriptE]\[ScriptN]\[ScriptT]\[ScriptH]\[ScriptE]\[ScriptS]\[ScriptI]\[ScriptZ]\[ScriptE]\[ScriptD]\[ScriptCapitalB]\[ScriptY]], {HoldAll}] /@ Unevaluated[{\[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR]}], ","}]]]

\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]:makeHeldSequenceOfBoxes[___] := With[{\[ScriptN]\[ScriptU]\[ScriptM] = heldLength[\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]]}, $Failed /; Which[\[ScriptN]\[ScriptU]\[ScriptM] == 1, Message[makeHeldSequenceOfBoxes::argr, HoldForm[makeHeldSequenceOfBoxes], 3], \[ScriptN]\[ScriptU]\[ScriptM] != 3, Message[makeHeldSequenceOfBoxes::argrx, HoldForm[makeHeldSequenceOfBoxes], \[ScriptN]\[ScriptU]\[ScriptM], 3], True, False]]

\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]:makeHeldSequenceOfBoxes[(\[ScriptN]\[ScriptO]\[ScriptT]\[ScriptCapitalL]\[ScriptI]\[ScriptS]\[ScriptT]_)?(headIsNot[List]), ___] := $Failed /; Message[makeHeldSequenceOfBoxes::list, HoldForm[\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]], 1]

\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]:makeHeldSequenceOfBoxes[_, (\[ScriptN]\[ScriptO]\[ScriptT]\[ScriptCapitalS]\[ScriptY]\[ScriptM]\[ScriptB]_)?(headIsNot[Symbol]), ___] := $Failed /; Message[makeHeldSequenceOfBoxes::sym, \[ScriptN]\[ScriptO]\[ScriptT]\[ScriptCapitalS]\[ScriptY]\[ScriptM]\[ScriptB], 2]

\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]:makeHeldSequenceOfBoxes[_, _, (\[ScriptN]\[ScriptO]\[ScriptT]\[ScriptCapitalS]\[ScriptY]\[ScriptM]\[ScriptB]_)?(headIsNot[Symbol]), ___] := $Failed /; Message[makeHeldSequenceOfBoxes::sym, \[ScriptN]\[ScriptO]\[ScriptT]\[ScriptCapitalS]\[ScriptY]\[ScriptM]\[ScriptB], 3]

\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]:makeHeldRowBoxOfBoxes[___] := With[{\[ScriptN]\[ScriptU]\[ScriptM] = heldLength[\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]]}, $Failed /; Which[\[ScriptN]\[ScriptU]\[ScriptM] == 1, Message[makeHeldRowBoxOfBoxes::argr, HoldForm[makeHeldRowBoxOfBoxes], 3], \[ScriptN]\[ScriptU]\[ScriptM] != 3, Message[makeHeldRowBoxOfBoxes::argrx, HoldForm[makeHeldRowBoxOfBoxes], \[ScriptN]\[ScriptU]\[ScriptM], 3], True, False]]

\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]:makeHeldRowBoxOfBoxes[(\[ScriptN]\[ScriptO]\[ScriptT]\[ScriptCapitalL]\[ScriptI]\[ScriptS]\[ScriptT]_)?(headIsNot[List]), ___] := $Failed /; Message[makeHeldRowBoxOfBoxes::list, HoldForm[\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]], 1]

\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]:makeHeldRowBoxOfBoxes[_, (\[ScriptN]\[ScriptO]\[ScriptT]\[ScriptCapitalS]\[ScriptY]\[ScriptM]\[ScriptB]_)?(headIsNot[Symbol]), ___] := $Failed /; Message[makeHeldRowBoxOfBoxes::sym, \[ScriptN]\[ScriptO]\[ScriptT]\[ScriptCapitalS]\[ScriptY]\[ScriptM]\[ScriptB], 2]

\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]:makeHeldRowBoxOfBoxes[_, _, (\[ScriptN]\[ScriptO]\[ScriptT]\[ScriptCapitalS]\[ScriptY]\[ScriptM]\[ScriptB]_)?(headIsNot[Symbol]), ___] := $Failed /; Message[makeHeldRowBoxOfBoxes::sym, \[ScriptN]\[ScriptO]\[ScriptT]\[ScriptCapitalS]\[ScriptY]\[ScriptM]\[ScriptB], 3]

\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]:makeEvaluatedSequenceOfBoxes[___] := With[{\[ScriptN]\[ScriptU]\[ScriptM] = heldLength[\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]]}, $Failed /; Which[\[ScriptN]\[ScriptU]\[ScriptM] == 1, Message[makeEvaluatedSequenceOfBoxes::argr, HoldForm[makeEvaluatedSequenceOfBoxes], 3], \[ScriptN]\[ScriptU]\[ScriptM] != 3, Message[makeEvaluatedSequenceOfBoxes::argrx, HoldForm[makeEvaluatedSequenceOfBoxes], \[ScriptN]\[ScriptU]\[ScriptM], 3], True, False]]

\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]:makeEvaluatedSequenceOfBoxes[(\[ScriptN]\[ScriptO]\[ScriptT]\[ScriptCapitalL]\[ScriptI]\[ScriptS]\[ScriptT]_)?(headIsNot[List]), ___] := $Failed /; Message[makeEvaluatedSequenceOfBoxes::list, HoldForm[\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]], 1]

\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]:makeEvaluatedSequenceOfBoxes[_, (\[ScriptN]\[ScriptO]\[ScriptT]\[ScriptCapitalS]\[ScriptY]\[ScriptM]\[ScriptB]_)?(headIsNot[Symbol]), ___] := $Failed /; Message[makeEvaluatedSequenceOfBoxes::sym, \[ScriptN]\[ScriptO]\[ScriptT]\[ScriptCapitalS]\[ScriptY]\[ScriptM]\[ScriptB], 2]

\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]:makeEvaluatedSequenceOfBoxes[_, _, (\[ScriptN]\[ScriptO]\[ScriptT]\[ScriptCapitalS]\[ScriptY]\[ScriptM]\[ScriptB]_)?(headIsNot[Symbol]), ___] := $Failed /; Message[makeEvaluatedSequenceOfBoxes::sym, \[ScriptN]\[ScriptO]\[ScriptT]\[ScriptCapitalS]\[ScriptY]\[ScriptM]\[ScriptB], 3]

\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]:makeEvaluatedRowBoxOfBoxes[___] := With[{\[ScriptN]\[ScriptU]\[ScriptM] = heldLength[\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]]}, $Failed /; Which[\[ScriptN]\[ScriptU]\[ScriptM] == 1, Message[makeEvaluatedRowBoxOfBoxes::argr, HoldForm[makeEvaluatedRowBoxOfBoxes], 3], \[ScriptN]\[ScriptU]\[ScriptM] != 3, Message[makeEvaluatedRowBoxOfBoxes::argrx, HoldForm[makeEvaluatedRowBoxOfBoxes], \[ScriptN]\[ScriptU]\[ScriptM], 3], True, False]]

\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]:makeEvaluatedRowBoxOfBoxes[(\[ScriptN]\[ScriptO]\[ScriptT]\[ScriptCapitalL]\[ScriptI]\[ScriptS]\[ScriptT]_)?(headIsNot[List]), ___] := $Failed /; Message[makeEvaluatedRowBoxOfBoxes::list, HoldForm[\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]], 1]

\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]:makeEvaluatedRowBoxOfBoxes[_, (\[ScriptN]\[ScriptO]\[ScriptT]\[ScriptCapitalS]\[ScriptY]\[ScriptM]\[ScriptB]_)?(headIsNot[Symbol]), ___] := $Failed /; Message[makeEvaluatedRowBoxOfBoxes::sym, \[ScriptN]\[ScriptO]\[ScriptT]\[ScriptCapitalS]\[ScriptY]\[ScriptM]\[ScriptB], 2]

\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]:makeEvaluatedRowBoxOfBoxes[_, _, (\[ScriptN]\[ScriptO]\[ScriptT]\[ScriptCapitalS]\[ScriptY]\[ScriptM]\[ScriptB]_)?(headIsNot[Symbol]), ___] := $Failed /; Message[makeEvaluatedRowBoxOfBoxes::sym, \[ScriptN]\[ScriptO]\[ScriptT]\[ScriptCapitalS]\[ScriptY]\[ScriptM]\[ScriptB], 3]

deleteMultipleUnderBrackets[exprString_String] := StringReplace[exprString, "\[UnderBracket]\[UnderBracket]" -> "\[UnderBracket]"]
pruneEnclosingCharacters[a_String /; StringMatchQ[a, "\"\\[*]\""]] := StringDrop[StringDrop[a, -2], 3]
pruneEnclosingCharacters[other_] := ""
convertNonLettersToFullNames[exprString_String] := StringJoin[Characters[exprString] /. a_String /;  !LetterQ[a] &&  !DigitQ[a] && a != "\[UnderBracket]" :> pruneEnclosingCharacters[ToString[FullForm[a]]]]
deletePossibleLeadingAndTrailingUnderBrackets[exprString_String] := Which[StringMatchQ[exprString, "\[UnderBracket]*\[UnderBracket]"], StringDrop[StringDrop[exprString, 1], -1], StringMatchQ[exprString, "\[UnderBracket]*"], StringDrop[exprString, 1], StringMatchQ[exprString, "*\[UnderBracket]"], StringDrop[exprString, -1], True, exprString]
operatorStringsToSymbolStrings[exprString_String] := deletePossibleLeadingAndTrailingUnderBrackets[deleteMultipleUnderBrackets[convertNonLettersToFullNames[StringReplace[exprString, {" " -> "\[UnderBracket]Space\[UnderBracket]", "->" -> "\[UnderBracket]Rule\[UnderBracket]", ":>" -> "\[UnderBracket]RuleDelayed\[UnderBracket]", ":=" -> "\[UnderBracket]SetDelayed\[UnderBracket]", "!" -> "\[UnderBracket]Exclamation\[UnderBracket]", "\"" -> "\[UnderBracket]DoubleQuote\[UnderBracket]", "#" -> "\[UnderBracket]Hash\[UnderBracket]", "$" -> "\[UnderBracket]Dollar\[UnderBracket]", "%" -> "\[UnderBracket]Percent\[UnderBracket]", "&&" -> "\[UnderBracket]And\[UnderBracket]", "&" -> "\[UnderBracket]Ampersand\[UnderBracket]", "'" -> "\[UnderBracket]Quote\[UnderBracket]", "(" -> "\[UnderBracket]LeftParenthesis\[UnderBracket]", ")" -> "\[UnderBracket]RightParenthesis\[UnderBracket]", "*" -> "\[UnderBracket]Times\[UnderBracket]", "+" -> "\[UnderBracket]Plus\[UnderBracket]", "," -> "\[UnderBracket]Comma\[UnderBracket]", "-" -> "\[UnderBracket]Dash\[UnderBracket]", "." -> "\[UnderBracket]Dot\[UnderBracket]", "/." -> "\[UnderBracket]Replace\[UnderBracket]", "//." -> "\[UnderBracket]ReplaceRepeated\[UnderBracket]", "//" -> "\[UnderBracket]BackAt\[UnderBracket]", "/;" -> "\[UnderBracket]Condition\[UnderBracket]", "/" -> "\[UnderBracket]Slash\[UnderBracket]", ":" -> "\[UnderBracket]Colon\[UnderBracket]", ";" -> "\[UnderBracket]Semicolon\[UnderBracket]", "<=" -> "\[UnderBracket]LessEqual\[UnderBracket]", "<" -> "\[UnderBracket]Less\[UnderBracket]", "===" -> "\[UnderBracket]SameQ\[UnderBracket]", "==" -> "\[UnderBracket]Equal\[UnderBracket]", "=" -> "\[UnderBracket]Set\[UnderBracket]", ">=" -> "\[UnderBracket]GreaterEqual\[UnderBracket]", ">" -> "\[UnderBracket]Greater\[UnderBracket]", "?" -> "\[UnderBracket]Question\[UnderBracket]", "@@" -> "\[UnderBracket]Apply\[UnderBracket]", "/@" -> "\[UnderBracket]Map\[UnderBracket]", "@" -> "\[UnderBracket]At\[UnderBracket]", "[" -> "\[UnderBracket]LeftBracket\[UnderBracket]", "]" -> "\[UnderBracket]RightBracket\[UnderBracket]", "\\" -> "\[UnderBracket]Backslash\[UnderBracket]", "^" -> "\[UnderBracket]Wedge\[UnderBracket]", "_" -> "\[UnderBracket]Underscore\[UnderBracket]", "`" -> "\[UnderBracket]Backquote\[UnderBracket]", "{" -> "\[UnderBracket]LeftBrace\[UnderBracket]", "||" -> "\[UnderBracket]Or\[UnderBracket]", "|" -> "\[UnderBracket]VerticalBar\[UnderBracket]", "}" -> "\[UnderBracket]RightBrace\[UnderBracket]", "~" -> "\[UnderBracket]Tilde\[UnderBracket]"}]]]]

convertBoxesToStringRepresentation[\[ScriptB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]_] := operatorStringsToSymbolStrings[StringJoin[Flatten[{\[ScriptB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]} //. {AdjustmentBox[a_, ___] -> a, ButtonBox[b_, ___] -> b, ErrorBox[b_, ___] -> b, FormBox[b_, ___] -> b, FractionBox[a_, b_, ___] -> {a, "\[UnderBracket]Over\[UnderBracket]", b}, FrameBox[b_, ___] -> b, GridBox[args_, ___] -> {args}, InterpretationBox[b_, ___] -> b, RadicalBox[a_, b_, ___] -> {a, "\[UnderBracket]Root\[UnderBracket]", b}, RowBox[a_] -> a, SqrtBox[a_, ___] -> {"Sqrt\[UnderBracket]", a}, StyleBox[a_, ___] -> a, SubscriptBox[a_, b_, ___] -> {a, "\[UnderBracket]Subscript\[UnderBracket]", b}, SuperscriptBox[a_, b_, ___] -> {a, "\[UnderBracket]Superscript\[UnderBracket]", b}, SubsuperscriptBox[a_, b_, c_, ___] -> {a, "\[UnderBracket]Subsuperscript\[UnderBracket]", b, "\[UnderBracket]and\[UnderBracket]", c}, TagBox[b_, ___] -> b, UnderscriptBox[a_, b_] -> {a, "\[UnderBracket]Underscript\[UnderBracket]", b}, OverscriptBox[a_, b_] -> {a, "\[UnderBracket]Overscript\[UnderBracket]", b}, UnderoverscriptBox[a_, b_, c_] -> {a, "\[UnderBracket]Underoverscript\[UnderBracket]", b, "\[UnderBracket]and\[UnderBracket]", c}}]]]

Symbolize[\[ScriptA]\[ScriptN]\[ScriptY]\[ScriptCapitalS]\[ScriptY]\[ScriptM]\[ScriptB]\[ScriptO]\[ScriptL]\[ScriptI]\[ScriptZ]\[ScriptE]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]___] /; (silentEvaluate[adjustedOptions[Symbolize] =. ]; False) := $Failed

RemoveSymbolize[\[ScriptS]\[ScriptY]\[ScriptM]\[ScriptB]\[ScriptO]\[ScriptL]\[ScriptI]\[ScriptZ]\[ScriptE]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]_, \[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS]___] := Symbolize[\[ScriptS]\[ScriptY]\[ScriptM]\[ScriptB]\[ScriptO]\[ScriptL]\[ScriptI]\[ScriptZ]\[ScriptE]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], Action -> RemoveNotationRules, \[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS]]

\[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalS]\[ScriptY]\[ScriptM]\[ScriptB]\[ScriptO]\[ScriptL]\[ScriptI]\[ScriptZ]\[ScriptE]:Symbolize[\[ScriptS]\[ScriptY]\[ScriptM]\[ScriptB]\[ScriptO]\[ScriptL]\[ScriptI]\[ScriptZ]\[ScriptE]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]_, ___] := (Message[Symbolize::badSymbolizeBoxes, HoldForm[\[ScriptS]\[ScriptY]\[ScriptM]\[ScriptB]\[ScriptO]\[ScriptL]\[ScriptI]\[ScriptZ]\[ScriptE]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]], HoldForm[\[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalS]\[ScriptY]\[ScriptM]\[ScriptB]\[ScriptO]\[ScriptL]\[ScriptI]\[ScriptZ]\[ScriptE]]]; $Failed) /; Head[\[ScriptS]\[ScriptY]\[ScriptM]\[ScriptB]\[ScriptO]\[ScriptL]\[ScriptI]\[ScriptZ]\[ScriptE]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]] =!= NotationBoxTag

Symbolize::badSymbolizeBoxes = "The Symbolize boxes `1` do not have an embedded NotationBoxTag TagBox. The Symbolize statement `2` may not have been entered using the palette, or the embedded TagBox may have been deleted. The embedded TagBox ensures correct parsing and retention of proper styling and grouping information."

\[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalS]\[ScriptY]\[ScriptM]\[ScriptB]\[ScriptO]\[ScriptL]\[ScriptI]\[ScriptZ]\[ScriptE]:Symbolize[\[ScriptS]\[ScriptY]\[ScriptM]\[ScriptB]\[ScriptO]\[ScriptL]\[ScriptI]\[ScriptZ]\[ScriptE]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]_, ___, \[ScriptN]\[ScriptO]\[ScriptT]\[ScriptCapitalO]\[ScriptP]\[ScriptT]\[ScriptI]\[ScriptO]\[ScriptN]_, ___] := (Message[Symbolize::nonopt, HoldForm[\[ScriptN]\[ScriptO]\[ScriptT]\[ScriptCapitalO]\[ScriptP]\[ScriptT]\[ScriptI]\[ScriptO]\[ScriptN]], 1, HoldForm[\[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalS]\[ScriptY]\[ScriptM]\[ScriptB]\[ScriptO]\[ScriptL]\[ScriptI]\[ScriptZ]\[ScriptE]]]; $Failed) /;  !OptionQ[\[ScriptN]\[ScriptO]\[ScriptT]\[ScriptCapitalO]\[ScriptP]\[ScriptT]\[ScriptI]\[ScriptO]\[ScriptN]]

\[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalS]\[ScriptY]\[ScriptM]\[ScriptB]\[ScriptO]\[ScriptL]\[ScriptI]\[ScriptZ]\[ScriptE]:Symbolize[\[ScriptS]\[ScriptY]\[ScriptM]\[ScriptB]\[ScriptO]\[ScriptL]\[ScriptI]\[ScriptZ]\[ScriptE]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]_, ___, (Rule | RuleDelayed)[Action, \[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalV]\[ScriptA]\[ScriptL]\[ScriptU]\[ScriptE]_], ___] := (Message[Symbolize::optcrp, Action, HoldForm[\[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalV]\[ScriptA]\[ScriptL]\[ScriptU]\[ScriptE]], HoldForm[\[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalS]\[ScriptY]\[ScriptM]\[ScriptB]\[ScriptO]\[ScriptL]\[ScriptI]\[ScriptZ]\[ScriptE]]]; $Failed) /;  !MatchQ[\[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalV]\[ScriptA]\[ScriptL]\[ScriptU]\[ScriptE], CreateNotationRules | RemoveNotationRules | PrintNotationRules]

Symbolize::optcrp = "Value of option \"`1` \[Rule] `2`\" in `3` should be CreateNotationRules, RemoveNotationRules or PrintNotationRules."

\[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalS]\[ScriptY]\[ScriptM]\[ScriptB]\[ScriptO]\[ScriptL]\[ScriptI]\[ScriptZ]\[ScriptE]:Symbolize[NotationBoxTag[RowBox[\[ScriptB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]___], ___], \[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS]___] := (Message[Symbolize::rowBoxHead, identityForm @@ {RowBox[\[ScriptB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]]}, HoldForm[\[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalS]\[ScriptY]\[ScriptM]\[ScriptB]\[ScriptO]\[ScriptL]\[ScriptI]\[ScriptZ]\[ScriptE]]]; $Failed) /; True
Symbolize::rowBoxHead = "The box structure \"`1`\" in `2` is not of the right form. Structures to be symbolized cannot have a RowBox as their head. Examine the full box structures for possible unintended groupings."

\[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalS]\[ScriptY]\[ScriptM]\[ScriptB]\[ScriptO]\[ScriptL]\[ScriptI]\[ScriptZ]\[ScriptE]:Symbolize[NotationBoxTag[\[ScriptB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]_, ___], \[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS]___] := With[{\[ScriptP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptE]\[ScriptD]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS] = boxedStringPatternsToPatterns[cleanBoxes[\[ScriptB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]], WorkingForm -> WorkingForm /. {\[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS]} /. adjustedOptions[Symbolize]]}, (Message[Symbolize::patternToGeneral, \[ScriptP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptE]\[ScriptD]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], identityForm[\[ScriptB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]], HoldForm[\[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalS]\[ScriptY]\[ScriptM]\[ScriptB]\[ScriptO]\[ScriptL]\[ScriptI]\[ScriptZ]\[ScriptE]]]; $Failed) /; patternToGeneralQ[\[ScriptP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptE]\[ScriptD]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]]]
Symbolize::patternToGeneral = "The pattern `1` appearing in the symbolize statement Symbolize[`2`] is too general to be used."

Symbolize[\[ScriptS]\[ScriptY]\[ScriptM]\[ScriptB]\[ScriptO]\[ScriptL]\[ScriptI]\[ScriptZ]\[ScriptE]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]_, \[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS]___] := With[{\[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS] = stripNotationBoxTag[\[ScriptS]\[ScriptY]\[ScriptM]\[ScriptB]\[ScriptO]\[ScriptL]\[ScriptI]\[ScriptZ]\[ScriptE]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]]}, createSymbolize[\[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], \[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS]]; ]

Symbolize[\[ScriptA]\[ScriptL]\[ScriptL]___] := (Message[Symbolize::unknownParseError, identityForm @@ {{\[ScriptA]\[ScriptL]\[ScriptL]}}]; CellPrint[Cell[BoxData[colorizeStructuralBoxes[\[ScriptA]\[ScriptL]\[ScriptL], 1]], "Output"]]; $Failed)
Symbolize::unknownParseError = "Unknown error occurred in parsing the Symbolize definition `1`. Please report this to jasonh@wri.com, Please carefully examine the following box structures for spurious characters, weird groupings etc."

createSymbolize[\[ScriptB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]_, (\[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS]___)?OptionQ] := With[{\[ScriptCapitalW]\[ScriptO]\[ScriptR]\[ScriptK]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM] = WorkingForm /. {\[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS]} /. adjustedOptions[Symbolize], \[ScriptCapitalA]\[ScriptC]\[ScriptT]\[ScriptI]\[ScriptO]\[ScriptN] = Action /. {\[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS]} /. adjustedOptions[Symbolize]}, With[{\[ScriptP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptE]\[ScriptD]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS] = boxedStringPatternsToPatterns[cleanBoxes[\[ScriptB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]], WorkingForm -> \[ScriptCapitalW]\[ScriptO]\[ScriptR]\[ScriptK]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM]]}, If[FreeQ[\[ScriptP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptE]\[ScriptD]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], Pattern | Blank | BlankNull | BlankSequence | BlankNullSequence], createSymbolizeSingleInstance[\[ScriptB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], \[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS]], executeSymbolizeAction[myHold[NotationMakeExpression[\[ScriptM]\[ScriptA]\[ScriptT]\[ScriptC]\[ScriptH]\[ScriptE]\[ScriptD]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]:\[ScriptP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptE]\[ScriptD]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], \[ScriptCapitalW]\[ScriptO]\[ScriptR]\[ScriptK]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM]]], myHold[createSymbolizeSingleInstance[\[ScriptM]\[ScriptA]\[ScriptT]\[ScriptC]\[ScriptH]\[ScriptE]\[ScriptD]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], \[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS]]; MakeExpression[\[ScriptM]\[ScriptA]\[ScriptT]\[ScriptC]\[ScriptH]\[ScriptE]\[ScriptD]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], \[ScriptCapitalW]\[ScriptO]\[ScriptR]\[ScriptK]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM]]], \[ScriptCapitalW]\[ScriptO]\[ScriptR]\[ScriptK]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM], \[ScriptCapitalA]\[ScriptC]\[ScriptT]\[ScriptI]\[ScriptO]\[ScriptN]]]; ]]

executeSymbolizeAction[\[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]_, \[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]_, \[ScriptCapitalW]\[ScriptO]\[ScriptR]\[ScriptK]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM]_, CreateNotationRules] := releaseMyHold[\[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL] := \[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]]

executeSymbolizeAction[\[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]_, \[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]_, \[ScriptCapitalW]\[ScriptO]\[ScriptR]\[ScriptK]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM]_, RemoveNotationRules] := releaseMyHold[\[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL] =. ]

executeSymbolizeAction[\[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]_, \[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]_, \[ScriptCapitalW]\[ScriptO]\[ScriptR]\[ScriptK]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM]_, PrintNotationRules] := releaseMyHold[CellPrint[Cell[BoxData[MakeBoxes[\[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL] := \[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL], StandardForm]], "Output", ShowStringCharacters -> True]]]

createSymbolizeSingleInstance[\[ScriptB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]_, (\[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS]___)?OptionQ] := With[{\[ScriptCapitalW]\[ScriptO]\[ScriptR]\[ScriptK]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM] = WorkingForm /. {\[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS]} /. adjustedOptions[Symbolize], \[ScriptCapitalS]\[ScriptY]\[ScriptM]\[ScriptB]\[ScriptO]\[ScriptL]\[ScriptI]\[ScriptZ]\[ScriptE]\[ScriptCapitalR]\[ScriptO]\[ScriptO]\[ScriptT]\[ScriptCapitalN]\[ScriptA]\[ScriptM]\[ScriptE] = SymbolizeRootName /. {\[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS]} /. adjustedOptions[Symbolize], \[ScriptCapitalA]\[ScriptC]\[ScriptT]\[ScriptI]\[ScriptO]\[ScriptN] = Action /. {\[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS]} /. adjustedOptions[Symbolize]}, With[{\[ScriptN]\[ScriptE]\[ScriptW]\[ScriptCapitalS]\[ScriptY]\[ScriptM]\[ScriptB]\[ScriptO]\[ScriptL]\[ScriptCapitalS]\[ScriptT]\[ScriptR]\[ScriptI]\[ScriptN]\[ScriptG] = If[\[ScriptCapitalS]\[ScriptY]\[ScriptM]\[ScriptB]\[ScriptO]\[ScriptL]\[ScriptI]\[ScriptZ]\[ScriptE]\[ScriptCapitalR]\[ScriptO]\[ScriptO]\[ScriptT]\[ScriptCapitalN]\[ScriptA]\[ScriptM]\[ScriptE] === "", convertBoxesToStringRepresentation[cleanBoxes[\[ScriptB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]]], \[ScriptCapitalS]\[ScriptY]\[ScriptM]\[ScriptB]\[ScriptO]\[ScriptL]\[ScriptI]\[ScriptZ]\[ScriptE]\[ScriptCapitalR]\[ScriptO]\[ScriptO]\[ScriptT]\[ScriptCapitalN]\[ScriptA]\[ScriptM]\[ScriptE]]}, executeSymbolizeSingleInstanceAction[myHold[\[ScriptB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]], \[ScriptN]\[ScriptE]\[ScriptW]\[ScriptCapitalS]\[ScriptY]\[ScriptM]\[ScriptB]\[ScriptO]\[ScriptL]\[ScriptCapitalS]\[ScriptT]\[ScriptR]\[ScriptI]\[ScriptN]\[ScriptG], \[ScriptCapitalW]\[ScriptO]\[ScriptR]\[ScriptK]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM], \[ScriptCapitalA]\[ScriptC]\[ScriptT]\[ScriptI]\[ScriptO]\[ScriptN]]]]

executeSymbolizeSingleInstanceAction[\[ScriptB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]_, \[ScriptN]\[ScriptE]\[ScriptW]\[ScriptCapitalS]\[ScriptY]\[ScriptM]\[ScriptB]\[ScriptO]\[ScriptL]\[ScriptCapitalS]\[ScriptT]\[ScriptR]\[ScriptI]\[ScriptN]\[ScriptG]_, \[ScriptCapitalW]\[ScriptO]\[ScriptR]\[ScriptK]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM]_, CreateNotationRules] := With[{\[ScriptN]\[ScriptE]\[ScriptW]\[ScriptCapitalS]\[ScriptY]\[ScriptM]\[ScriptB]\[ScriptO]\[ScriptL] = If[Names[\[ScriptN]\[ScriptE]\[ScriptW]\[ScriptCapitalS]\[ScriptY]\[ScriptM]\[ScriptB]\[ScriptO]\[ScriptL]\[ScriptCapitalS]\[ScriptT]\[ScriptR]\[ScriptI]\[ScriptN]\[ScriptG]] != {}, Message[Symbolize::boxSymbolExists]; Unique[StringJoin[\[ScriptN]\[ScriptE]\[ScriptW]\[ScriptCapitalS]\[ScriptY]\[ScriptM]\[ScriptB]\[ScriptO]\[ScriptL]\[ScriptCapitalS]\[ScriptT]\[ScriptR]\[ScriptI]\[ScriptN]\[ScriptG], "$"]], Symbol[\[ScriptN]\[ScriptE]\[ScriptW]\[ScriptCapitalS]\[ScriptY]\[ScriptM]\[ScriptB]\[ScriptO]\[ScriptL]\[ScriptCapitalS]\[ScriptT]\[ScriptR]\[ScriptI]\[ScriptN]\[ScriptG]]]}, releaseMyHold[NotationMakeExpression[\[ScriptB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], \[ScriptCapitalW]\[ScriptO]\[ScriptR]\[ScriptK]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM]] := HoldComplete[\[ScriptN]\[ScriptE]\[ScriptW]\[ScriptCapitalS]\[ScriptY]\[ScriptM]\[ScriptB]\[ScriptO]\[ScriptL]]; NotationMakeBoxes[\[ScriptN]\[ScriptE]\[ScriptW]\[ScriptCapitalS]\[ScriptY]\[ScriptM]\[ScriptB]\[ScriptO]\[ScriptL], \[ScriptCapitalW]\[ScriptO]\[ScriptR]\[ScriptK]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM]] := \[ScriptB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]; symbolizedTable[\[ScriptN]\[ScriptE]\[ScriptW]\[ScriptCapitalS]\[ScriptY]\[ScriptM]\[ScriptB]\[ScriptO]\[ScriptL]] := {\[ScriptB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], \[ScriptCapitalW]\[ScriptO]\[ScriptR]\[ScriptK]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM]}; HoldComplete[\[ScriptN]\[ScriptE]\[ScriptW]\[ScriptCapitalS]\[ScriptY]\[ScriptM]\[ScriptB]\[ScriptO]\[ScriptL]]]]

executeSymbolizeSingleInstanceAction[\[ScriptB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]_, \[ScriptN]\[ScriptE]\[ScriptW]\[ScriptCapitalS]\[ScriptY]\[ScriptM]\[ScriptB]\[ScriptO]\[ScriptL]\[ScriptCapitalS]\[ScriptT]\[ScriptR]\[ScriptI]\[ScriptN]\[ScriptG]_, \[ScriptCapitalW]\[ScriptO]\[ScriptR]\[ScriptK]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM]_, RemoveNotationRules] := silentEvaluate[With[{\[ScriptS]\[ScriptY]\[ScriptM]\[ScriptB]\[ScriptO]\[ScriptL] = myHold @@ MakeExpression[\[ScriptB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], \[ScriptCapitalW]\[ScriptO]\[ScriptR]\[ScriptK]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM]]}, releaseMyHold[NotationMakeExpression[\[ScriptB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], \[ScriptCapitalW]\[ScriptO]\[ScriptR]\[ScriptK]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM]] =. ; NotationMakeBoxes[\[ScriptS]\[ScriptY]\[ScriptM]\[ScriptB]\[ScriptO]\[ScriptL], \[ScriptCapitalW]\[ScriptO]\[ScriptR]\[ScriptK]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM]] =. ; symbolizedTable[\[ScriptS]\[ScriptY]\[ScriptM]\[ScriptB]\[ScriptO]\[ScriptL]] =. ]]]

executeSymbolizeSingleInstanceAction[\[ScriptB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]_, \[ScriptN]\[ScriptE]\[ScriptW]\[ScriptCapitalS]\[ScriptY]\[ScriptM]\[ScriptB]\[ScriptO]\[ScriptL]\[ScriptCapitalS]\[ScriptT]\[ScriptR]\[ScriptI]\[ScriptN]\[ScriptG]_, \[ScriptCapitalW]\[ScriptO]\[ScriptR]\[ScriptK]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM]_, PrintNotationRules] := With[{\[ScriptN]\[ScriptE]\[ScriptW]\[ScriptCapitalS]\[ScriptY]\[ScriptM]\[ScriptB]\[ScriptO]\[ScriptL] = Symbol[\[ScriptN]\[ScriptE]\[ScriptW]\[ScriptCapitalS]\[ScriptY]\[ScriptM]\[ScriptB]\[ScriptO]\[ScriptL]\[ScriptCapitalS]\[ScriptT]\[ScriptR]\[ScriptI]\[ScriptN]\[ScriptG]]}, releaseMyHold[CellPrint[Cell[BoxData[MakeBoxes[NotationMakeExpression[\[ScriptB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], \[ScriptCapitalW]\[ScriptO]\[ScriptR]\[ScriptK]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM]] := HoldComplete[\[ScriptN]\[ScriptE]\[ScriptW]\[ScriptCapitalS]\[ScriptY]\[ScriptM]\[ScriptB]\[ScriptO]\[ScriptL]], StandardForm]], "Output", ShowStringCharacters -> True]]; CellPrint[Cell[BoxData[MakeBoxes[NotationMakeBoxes[\[ScriptN]\[ScriptE]\[ScriptW]\[ScriptCapitalS]\[ScriptY]\[ScriptM]\[ScriptB]\[ScriptO]\[ScriptL], \[ScriptCapitalW]\[ScriptO]\[ScriptR]\[ScriptK]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM]] := \[ScriptB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], StandardForm]], "Output", ShowStringCharacters -> True]]; ]]

Symbolize::boxSymbolExists = "Warning: The box structure attempting to be symbolized has a similar or identical symbol already defined, possibly overriding previously symbolized box structure."

wasProtected = Unprotect[Remove]
Remove[\[ScriptS]\[ScriptY]\[ScriptM]\[ScriptB]\[ScriptO]\[ScriptL]_] /; ValueQ[symbolizedTable[\[ScriptS]\[ScriptY]\[ScriptM]\[ScriptB]\[ScriptO]\[ScriptL]]] := With[{\[ScriptB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS] = symbolizedTable[\[ScriptS]\[ScriptY]\[ScriptM]\[ScriptB]\[ScriptO]\[ScriptL]][[1]], \[ScriptCapitalW]\[ScriptO]\[ScriptR]\[ScriptK]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM] = symbolizedTable[\[ScriptS]\[ScriptY]\[ScriptM]\[ScriptB]\[ScriptO]\[ScriptL]][[2]]}, MakeExpression[\[ScriptB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], \[ScriptCapitalW]\[ScriptO]\[ScriptR]\[ScriptK]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM]] =. ; MakeBoxes[\[ScriptS]\[ScriptY]\[ScriptM]\[ScriptB]\[ScriptO]\[ScriptL], \[ScriptCapitalW]\[ScriptO]\[ScriptR]\[ScriptK]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM]] =. ; symbolizedTable[\[ScriptS]\[ScriptY]\[ScriptM]\[ScriptB]\[ScriptO]\[ScriptL]] =. ; ClearAll[\[ScriptS]\[ScriptY]\[ScriptM]\[ScriptB]\[ScriptO]\[ScriptL]]; Remove[\[ScriptS]\[ScriptY]\[ScriptM]\[ScriptB]\[ScriptO]\[ScriptL]]]
SetAttributes[Remove, ReadProtected]
Protect[Evaluate[wasProtected]]

SetAttributes[symbolizedTable, HoldAll]

createSymbolize[\[ScriptA]\[ScriptL]\[ScriptL]_, \[ScriptO]\[ScriptT]\[ScriptH]\[ScriptE]\[ScriptR]___] := (Message[Symbolize::unknownProcessingError]; CellPrint[Cell[BoxData[colorizeStructuralBoxes[\[ScriptA]\[ScriptL]\[ScriptL], 1]], "Output"]]; HoldComplete[Symbol["$Failed"]])

Symbolize::unknownProcessingError = "Unknown error occurred in processing the Symbolize definition.        \t\tPlease report this to jasonh@wri.com, Please carefully examine the following box structures for spurious characters, weird groupings etc."

InfixNotation[\[ScriptA]\[ScriptN]\[ScriptY]\[ScriptCapitalI]\[ScriptN]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptO]\[ScriptP]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]___] /; (silentEvaluate[adjustedOptions[InfixNotation] =. ]; False) := $Failed

RemoveInfixNotation[\[ScriptI]\[ScriptN]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptO]\[ScriptP]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]_, \[ScriptP]\[ScriptR]\[ScriptE]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptCapitalH]\[ScriptE]\[ScriptA]\[ScriptD]_, \[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS]___] := InfixNotation[\[ScriptI]\[ScriptN]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptO]\[ScriptP]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], \[ScriptP]\[ScriptR]\[ScriptE]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptCapitalH]\[ScriptE]\[ScriptA]\[ScriptD], Action -> RemoveNotationRules, \[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS]]

\[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalI]\[ScriptN]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptCapitalN]\[ScriptO]\[ScriptT]\[ScriptA]\[ScriptT]\[ScriptI]\[ScriptO]\[ScriptN]:InfixNotation[\[ScriptI]\[ScriptN]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptO]\[ScriptP]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]_, ___] := (Message[InfixNotation::badInfixNotationBoxes, HoldForm[\[ScriptI]\[ScriptN]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptO]\[ScriptP]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]], HoldForm[\[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalI]\[ScriptN]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptCapitalN]\[ScriptO]\[ScriptT]\[ScriptA]\[ScriptT]\[ScriptI]\[ScriptO]\[ScriptN]]]; $Failed) /; Head[\[ScriptI]\[ScriptN]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptO]\[ScriptP]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]] =!= NotationBoxTag

InfixNotation::badInfixNotationBoxes = "The InfixNotation boxes `1` do not have an embedded NotationBoxTag TagBox. The InfixNotation statement `2` may not have been entered using the palette, or the embedded TagBox may have been deleted. The embedded TagBox ensures correct parsing and retention of proper styling and grouping information."

\[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalI]\[ScriptN]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptCapitalN]\[ScriptO]\[ScriptT]\[ScriptA]\[ScriptT]\[ScriptI]\[ScriptO]\[ScriptN]:InfixNotation[\[ScriptI]\[ScriptN]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptO]\[ScriptP]_, \[ScriptP]\[ScriptR]\[ScriptE]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptCapitalH]\[ScriptE]\[ScriptA]\[ScriptD]_, ___, \[ScriptN]\[ScriptO]\[ScriptT]\[ScriptCapitalO]\[ScriptP]\[ScriptT]\[ScriptI]\[ScriptO]\[ScriptN]_, ___] := (Message[InfixNotation::nonopt, HoldForm[\[ScriptN]\[ScriptO]\[ScriptT]\[ScriptCapitalO]\[ScriptP]\[ScriptT]\[ScriptI]\[ScriptO]\[ScriptN]], 1, HoldForm[\[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalI]\[ScriptN]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptCapitalN]\[ScriptO]\[ScriptT]\[ScriptA]\[ScriptT]\[ScriptI]\[ScriptO]\[ScriptN]]]; $Failed) /;  !OptionQ[\[ScriptN]\[ScriptO]\[ScriptT]\[ScriptCapitalO]\[ScriptP]\[ScriptT]\[ScriptI]\[ScriptO]\[ScriptN]]

\[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalI]\[ScriptN]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptCapitalN]\[ScriptO]\[ScriptT]\[ScriptA]\[ScriptT]\[ScriptI]\[ScriptO]\[ScriptN]:InfixNotation[\[ScriptI]\[ScriptN]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptO]\[ScriptP]_, \[ScriptP]\[ScriptR]\[ScriptE]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptCapitalH]\[ScriptE]\[ScriptA]\[ScriptD]_, ___, (Rule | RuleDelayed)[Action, \[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalV]\[ScriptA]\[ScriptL]\[ScriptU]\[ScriptE]_], ___] := (Message[InfixNotation::optcrp, Action, HoldForm[\[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalV]\[ScriptA]\[ScriptL]\[ScriptU]\[ScriptE]], HoldForm[\[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalI]\[ScriptN]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptCapitalN]\[ScriptO]\[ScriptT]\[ScriptA]\[ScriptT]\[ScriptI]\[ScriptO]\[ScriptN]]]; $Failed) /;  !MatchQ[\[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalV]\[ScriptA]\[ScriptL]\[ScriptU]\[ScriptE], CreateNotationRules | RemoveNotationRules | PrintNotationRules]

InfixNotation::optcrp = "Value of option \"`1` \[Rule] `2`\" in `3` should be CreateNotationRules, RemoveNotationRules or PrintNotationRules."

\[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalI]\[ScriptN]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptCapitalN]\[ScriptO]\[ScriptT]\[ScriptA]\[ScriptT]\[ScriptI]\[ScriptO]\[ScriptN]:InfixNotation[NotationBoxTag[RowBox[\[ScriptB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]___], ___], \[ScriptP]\[ScriptR]\[ScriptE]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptCapitalH]\[ScriptE]\[ScriptA]\[ScriptD]_, \[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS]___] := (Message[InfixNotation::rowBoxHead, identityForm @@ {RowBox[\[ScriptB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]]}, HoldForm[\[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalI]\[ScriptN]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptCapitalN]\[ScriptO]\[ScriptT]\[ScriptA]\[ScriptT]\[ScriptI]\[ScriptO]\[ScriptN]]]; $Failed) /; True
InfixNotation::rowBoxHead = "The InfixNotation box structure \"`1`\" is not of the right form. Structures to be used as an infix operator cannot have a RowBox as their head. Examine the full box structures of `2` for possible unintended groupings."

\[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalI]\[ScriptN]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptCapitalN]\[ScriptO]\[ScriptT]\[ScriptA]\[ScriptT]\[ScriptI]\[ScriptO]\[ScriptN]:InfixNotation[NotationBoxTag[\[ScriptI]\[ScriptN]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptO]\[ScriptP]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]_, ___], \[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalP]\[ScriptR]\[ScriptE]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptCapitalH]\[ScriptE]\[ScriptA]\[ScriptD]_, \[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS]___] := (Message[InfixNotation::badPrefixHead, HoldForm[\[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalP]\[ScriptR]\[ScriptE]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptCapitalH]\[ScriptE]\[ScriptA]\[ScriptD]], identityForm @@ {\[ScriptI]\[ScriptN]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptO]\[ScriptP]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]}, HoldForm[\[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalI]\[ScriptN]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptCapitalN]\[ScriptO]\[ScriptT]\[ScriptA]\[ScriptT]\[ScriptI]\[ScriptO]\[ScriptN]]]; $Failed) /; Head[\[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalP]\[ScriptR]\[ScriptE]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptCapitalH]\[ScriptE]\[ScriptA]\[ScriptD]] =!= Symbol
InfixNotation::badPrefixHead = "In `3`, the prefix head \"`1`\" corresponding to the infix operator \"`2`\" is not a symbol."

InfixNotation[\[ScriptI]\[ScriptN]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptO]\[ScriptP]_, \[ScriptP]\[ScriptR]\[ScriptE]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptCapitalH]\[ScriptE]\[ScriptA]\[ScriptD]_, \[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS]___] := With[{\[ScriptI]\[ScriptN]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptO]\[ScriptP]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS] = stripNotationBoxTag[\[ScriptI]\[ScriptN]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptO]\[ScriptP]]}, createInfixNotation[\[ScriptI]\[ScriptN]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptO]\[ScriptP]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], \[ScriptP]\[ScriptR]\[ScriptE]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptCapitalH]\[ScriptE]\[ScriptA]\[ScriptD], \[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS]]; ]

InfixNotation[\[ScriptA]\[ScriptL]\[ScriptL]_, \[ScriptO]\[ScriptT]\[ScriptH]\[ScriptE]\[ScriptR]___] := (Message[InfixNotation::unknownParseError, identityForm @@ {\[ScriptA]\[ScriptL]\[ScriptL]}]; CellPrint[Cell[BoxData[colorizeStructuralBoxes[\[ScriptA]\[ScriptL]\[ScriptL], 1]], "Output"]]; $Failed)
InfixNotation::unknownParseError = "Unknown error occurred in parsing the InfixNotation definition `1`. Please report this to jasonh@wri.com, Please carefully examine the following box structures for spurious characters weird groupings etc."

createInfixNotation[\[ScriptI]\[ScriptN]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptO]\[ScriptP]_, \[ScriptP]\[ScriptR]\[ScriptE]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptCapitalH]\[ScriptE]\[ScriptA]\[ScriptD]_, (\[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS]___)?OptionQ] := With[{\[ScriptCapitalW]\[ScriptO]\[ScriptR]\[ScriptK]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM] = WorkingForm /. {\[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS]} /. adjustedOptions[InfixNotation], \[ScriptCapitalA]\[ScriptC]\[ScriptT]\[ScriptI]\[ScriptO]\[ScriptN] = Action /. {\[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS]} /. adjustedOptions[InfixNotation]}, executeInfixNotationAction[\[ScriptI]\[ScriptN]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptO]\[ScriptP], \[ScriptP]\[ScriptR]\[ScriptE]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptCapitalH]\[ScriptE]\[ScriptA]\[ScriptD], effectiveOperator[\[ScriptI]\[ScriptN]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptO]\[ScriptP]], \[ScriptCapitalW]\[ScriptO]\[ScriptR]\[ScriptK]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM], \[ScriptCapitalA]\[ScriptC]\[ScriptT]\[ScriptI]\[ScriptO]\[ScriptN]]]

executeInfixNotationAction[\[ScriptI]\[ScriptN]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptO]\[ScriptP]_, \[ScriptP]\[ScriptR]\[ScriptE]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptCapitalH]\[ScriptE]\[ScriptA]\[ScriptD]_, \[ScriptG]\[ScriptR]\[ScriptO]\[ScriptU]\[ScriptP]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalP]\[ScriptR]\[ScriptE]\[ScriptC]\[ScriptE]\[ScriptD]\[ScriptE]\[ScriptN]\[ScriptC]\[ScriptE]_, \[ScriptCapitalW]\[ScriptO]\[ScriptR]\[ScriptK]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM]_, CreateNotationRules] := (NotationMakeExpression[RowBox[\[ScriptA]_], \[ScriptCapitalW]\[ScriptO]\[ScriptR]\[ScriptK]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM]] /; MemberQ[\[ScriptA], \[ScriptI]\[ScriptN]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptO]\[ScriptP]] := MakeExpression[parseFlatInfix[\[ScriptP]\[ScriptR]\[ScriptE]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptCapitalH]\[ScriptE]\[ScriptA]\[ScriptD], \[ScriptI]\[ScriptN]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptO]\[ScriptP], \[ScriptA]], \[ScriptCapitalW]\[ScriptO]\[ScriptR]\[ScriptK]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM]] /; appearsInfix[\[ScriptI]\[ScriptN]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptO]\[ScriptP], \[ScriptA]]; NotationMakeBoxes[\[ScriptP]\[ScriptR]\[ScriptE]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptCapitalH]\[ScriptE]\[ScriptA]\[ScriptD][\[ScriptA]\[ScriptR]\[ScriptG]1_, \[ScriptA]\[ScriptR]\[ScriptG]\[ScriptS]__], \[ScriptCapitalW]\[ScriptO]\[ScriptR]\[ScriptK]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM]] := (RowBox[padList[#1, \[ScriptI]\[ScriptN]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptO]\[ScriptP]]] & )[(Parenthesize[#1, \[ScriptCapitalW]\[ScriptO]\[ScriptR]\[ScriptK]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM], \[ScriptG]\[ScriptR]\[ScriptO]\[ScriptU]\[ScriptP]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalP]\[ScriptR]\[ScriptE]\[ScriptC]\[ScriptE]\[ScriptD]\[ScriptE]\[ScriptN]\[ScriptC]\[ScriptE]] & ) /@ Unevaluated /@ Unevaluated[{\[ScriptA]\[ScriptR]\[ScriptG]1, \[ScriptA]\[ScriptR]\[ScriptG]\[ScriptS]}]]; )

executeInfixNotationAction[\[ScriptI]\[ScriptN]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptO]\[ScriptP]_, \[ScriptP]\[ScriptR]\[ScriptE]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptCapitalH]\[ScriptE]\[ScriptA]\[ScriptD]_, \[ScriptG]\[ScriptR]\[ScriptO]\[ScriptU]\[ScriptP]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalP]\[ScriptR]\[ScriptE]\[ScriptC]\[ScriptE]\[ScriptD]\[ScriptE]\[ScriptN]\[ScriptC]\[ScriptE]_, \[ScriptCapitalW]\[ScriptO]\[ScriptR]\[ScriptK]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM]_, RemoveNotationRules] := silentEvaluate[NotationMakeExpression[RowBox[\[ScriptA]_], \[ScriptCapitalW]\[ScriptO]\[ScriptR]\[ScriptK]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM]] /; MemberQ[\[ScriptA], \[ScriptI]\[ScriptN]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptO]\[ScriptP]] =. ; NotationMakeBoxes[\[ScriptP]\[ScriptR]\[ScriptE]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptCapitalH]\[ScriptE]\[ScriptA]\[ScriptD][\[ScriptA]\[ScriptR]\[ScriptG]1_, \[ScriptA]\[ScriptR]\[ScriptG]\[ScriptS]__], \[ScriptCapitalW]\[ScriptO]\[ScriptR]\[ScriptK]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM]] =. ; ]

executeInfixNotationAction[\[ScriptI]\[ScriptN]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptO]\[ScriptP]_, \[ScriptP]\[ScriptR]\[ScriptE]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptCapitalH]\[ScriptE]\[ScriptA]\[ScriptD]_, \[ScriptG]\[ScriptR]\[ScriptO]\[ScriptU]\[ScriptP]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalP]\[ScriptR]\[ScriptE]\[ScriptC]\[ScriptE]\[ScriptD]\[ScriptE]\[ScriptN]\[ScriptC]\[ScriptE]_, \[ScriptCapitalW]\[ScriptO]\[ScriptR]\[ScriptK]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM]_, PrintNotationRules] := (CellPrint[Cell[BoxData[MakeBoxes[NotationMakeExpression[RowBox[\[ScriptA]_], \[ScriptCapitalW]\[ScriptO]\[ScriptR]\[ScriptK]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM]] /; MemberQ[\[ScriptA], \[ScriptI]\[ScriptN]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptO]\[ScriptP]] := MakeExpression[parseFlatInfix[\[ScriptP]\[ScriptR]\[ScriptE]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptCapitalH]\[ScriptE]\[ScriptA]\[ScriptD], \[ScriptI]\[ScriptN]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptO]\[ScriptP], \[ScriptA]], \[ScriptCapitalW]\[ScriptO]\[ScriptR]\[ScriptK]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM]] /; appearsInfix[\[ScriptI]\[ScriptN]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptO]\[ScriptP], \[ScriptA]], StandardForm]], "Output", ShowStringCharacters -> True]]; CellPrint[Cell[BoxData[MakeBoxes[MakeBoxes[\[ScriptP]\[ScriptR]\[ScriptE]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptCapitalH]\[ScriptE]\[ScriptA]\[ScriptD][\[ScriptA]\[ScriptR]\[ScriptG]1_, \[ScriptA]\[ScriptR]\[ScriptG]\[ScriptS]__], \[ScriptCapitalW]\[ScriptO]\[ScriptR]\[ScriptK]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM]] := (RowBox[padList[#1, \[ScriptI]\[ScriptN]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptO]\[ScriptP]]] & )[(Parenthesize[#1, \[ScriptCapitalW]\[ScriptO]\[ScriptR]\[ScriptK]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM], \[ScriptG]\[ScriptR]\[ScriptO]\[ScriptU]\[ScriptP]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalP]\[ScriptR]\[ScriptE]\[ScriptC]\[ScriptE]\[ScriptD]\[ScriptE]\[ScriptN]\[ScriptC]\[ScriptE]] & ) /@ Unevaluated /@ Unevaluated[{\[ScriptA]\[ScriptR]\[ScriptG]1, \[ScriptA]\[ScriptR]\[ScriptG]\[ScriptS]}]], StandardForm]], "Output", ShowStringCharacters -> True]]; )

SetAttributes[{parseFlatInfix, parseFlatInfixAux}, HoldAll]

parseFlatInfix[\[ScriptP]\[ScriptR]\[ScriptE]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptCapitalH]\[ScriptE]\[ScriptA]\[ScriptD]_, \[ScriptI]\[ScriptN]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptO]\[ScriptP]_, {\[ScriptL]\[ScriptH]\[ScriptS]___, (\[ScriptF]\[ScriptI]\[ScriptR]\[ScriptS]\[ScriptT]_)?notWhiteSpaceQ, ___?whiteSpaceQ, \[ScriptI]\[ScriptN]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptO]\[ScriptP]_, ___?whiteSpaceQ, (\[ScriptB]_)?notWhiteSpaceQ, \[ScriptR]\[ScriptE]\[ScriptS]\[ScriptT]___}] := parseFlatInfixAux[\[ScriptP]\[ScriptR]\[ScriptE]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptCapitalH]\[ScriptE]\[ScriptA]\[ScriptD], \[ScriptI]\[ScriptN]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptO]\[ScriptP], \[ScriptF]\[ScriptI]\[ScriptR]\[ScriptS]\[ScriptT], {\[ScriptL]\[ScriptH]\[ScriptS]}, {\[ScriptB], \[ScriptR]\[ScriptE]\[ScriptS]\[ScriptT]}]

parseFlatInfixAux[\[ScriptP]\[ScriptR]\[ScriptE]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptCapitalH]\[ScriptE]\[ScriptA]\[ScriptD]_, \[ScriptI]\[ScriptN]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptO]\[ScriptP]_, \[ScriptF]\[ScriptI]\[ScriptR]\[ScriptS]\[ScriptT]_, {\[ScriptL]\[ScriptH]\[ScriptS]___}, {\[ScriptR]\[ScriptE]\[ScriptS]\[ScriptT]___}] := Block[{parseOperator, parseArgument, returnAnswer}, SetAttributes[{parseOperator, parseArgument}, HoldAll]; parseOperator[_?whiteSpaceQ, \[ScriptR]___] := parseOperator[\[ScriptR]]; parseOperator[\[ScriptI]\[ScriptN]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptO]\[ScriptP], \[ScriptR]___] := parseArgument[\[ScriptR]]; parseArgument[_?whiteSpaceQ, \[ScriptR]___] := parseArgument[\[ScriptR]]; parseArgument[\[ScriptA]_, \[ScriptR]___] := Sequence[\[ScriptA], parseOperator[\[ScriptR]]]; returnAnswer[{\[ScriptP]\[ScriptA]\[ScriptR]\[ScriptS]\[ScriptE]\[ScriptD]__, parseOperator[\[ScriptR]\[ScriptH]\[ScriptS]___]}] := returnFormatedOutput[\[ScriptP]\[ScriptR]\[ScriptE]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptCapitalH]\[ScriptE]\[ScriptA]\[ScriptD], {\[ScriptL]\[ScriptH]\[ScriptS]}, {\[ScriptP]\[ScriptA]\[ScriptR]\[ScriptS]\[ScriptE]\[ScriptD]}, {\[ScriptR]\[ScriptH]\[ScriptS]}]; returnAnswer[Block[{$RecursionLimit = Infinity}, {\[ScriptF]\[ScriptI]\[ScriptR]\[ScriptS]\[ScriptT], parseArgument[\[ScriptR]\[ScriptE]\[ScriptS]\[ScriptT]]}]]]

appearsInfix[\[ScriptO]\[ScriptP]_, {___, _?notWhiteSpaceQ, ___?whiteSpaceQ, \[ScriptO]\[ScriptP]_, ___?whiteSpaceQ, _?notWhiteSpaceQ, ___}] := True
appearsInfix[_] := False

returnFormatedOutput[\[ScriptP]\[ScriptR]\[ScriptE]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptCapitalH]\[ScriptE]\[ScriptA]\[ScriptD]_, {\[ScriptL]\[ScriptH]\[ScriptS]___}, {\[ScriptP]\[ScriptA]\[ScriptR]\[ScriptS]\[ScriptE]\[ScriptD]__}, {\[ScriptR]\[ScriptH]\[ScriptS]___}] := RowBox[{\[ScriptL]\[ScriptH]\[ScriptS], RowBox[{ToString[\[ScriptP]\[ScriptR]\[ScriptE]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptCapitalH]\[ScriptE]\[ScriptA]\[ScriptD]], "[", RowBox[padList[{\[ScriptP]\[ScriptA]\[ScriptR]\[ScriptS]\[ScriptE]\[ScriptD]}, ","]], "]"}], \[ScriptR]\[ScriptH]\[ScriptS]}] /; {\[ScriptL]\[ScriptH]\[ScriptS], \[ScriptR]\[ScriptH]\[ScriptS]} =!= {}
returnFormatedOutput[\[ScriptP]\[ScriptR]\[ScriptE]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptCapitalH]\[ScriptE]\[ScriptA]\[ScriptD]_, {\[ScriptL]\[ScriptH]\[ScriptS]___}, {\[ScriptP]\[ScriptA]\[ScriptR]\[ScriptS]\[ScriptE]\[ScriptD]__}, {\[ScriptR]\[ScriptH]\[ScriptS]___}] := RowBox[{ToString[\[ScriptP]\[ScriptR]\[ScriptE]\[ScriptF]\[ScriptI]\[ScriptX]\[ScriptCapitalH]\[ScriptE]\[ScriptA]\[ScriptD]], "[", RowBox[padList[{\[ScriptP]\[ScriptA]\[ScriptR]\[ScriptS]\[ScriptE]\[ScriptD]}, ","]], "]"}] /; {\[ScriptL]\[ScriptH]\[ScriptS], \[ScriptR]\[ScriptH]\[ScriptS]} === {}

\[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalI]\[ScriptN]\[ScriptP]\[ScriptU]\[ScriptT]\[ScriptCapitalA]\[ScriptL]\[ScriptI]\[ScriptA]\[ScriptS]:AddInputAlias[\[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]_, ___] := (Message[AddInputAlias::badInputAliasBoxes, HoldForm[\[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]], HoldForm[\[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalI]\[ScriptN]\[ScriptP]\[ScriptU]\[ScriptT]\[ScriptCapitalA]\[ScriptL]\[ScriptI]\[ScriptA]\[ScriptS]]]; $Failed) /; Head[\[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]] =!= NotationBoxTag

AddInputAlias::badInputAliasBoxes = "The InputAliasBoxes boxes `1` do not have an embedded NotationBoxTag TagBox. The AddInputAlias statement `2` may not have been entered using the palette, or the embedded TagBox may have been deleted. The embedded TagBox ensures correct parsing and retention of proper styling and grouping information."

\[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalI]\[ScriptN]\[ScriptP]\[ScriptU]\[ScriptT]\[ScriptCapitalA]\[ScriptL]\[ScriptI]\[ScriptA]\[ScriptS]:AddInputAlias[\[ScriptF]\[ScriptU]\[ScriptL]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]_NotationBoxTag, \[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalS]\[ScriptH]\[ScriptO]\[ScriptR]\[ScriptT]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM]_, ___] := (Message[AddInputAlias::badShortForm, HoldForm[\[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalS]\[ScriptH]\[ScriptO]\[ScriptR]\[ScriptT]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM]], HoldForm[\[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalI]\[ScriptN]\[ScriptP]\[ScriptU]\[ScriptT]\[ScriptCapitalA]\[ScriptL]\[ScriptI]\[ScriptA]\[ScriptS]]]; $Failed) /; Head[\[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalS]\[ScriptH]\[ScriptO]\[ScriptR]\[ScriptT]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM]] =!= String

AddInputAlias::badShortForm = "The short form `1` in the AddInputAlias statement `2` is not a string."

\[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalI]\[ScriptN]\[ScriptP]\[ScriptU]\[ScriptT]\[ScriptCapitalA]\[ScriptL]\[ScriptI]\[ScriptA]\[ScriptS]:AddInputAlias[\[ScriptF]\[ScriptU]\[ScriptL]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]_NotationBoxTag, \[ScriptS]\[ScriptH]\[ScriptO]\[ScriptR]\[ScriptT]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM]_String, \[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalN]\[ScriptO]\[ScriptT]\[ScriptE]\[ScriptB]\[ScriptO]\[ScriptO]\[ScriptK]_] := (Message[AddInputAlias::badNotebook, HoldForm[\[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalN]\[ScriptO]\[ScriptT]\[ScriptE]\[ScriptB]\[ScriptO]\[ScriptO]\[ScriptK]], HoldForm[\[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalI]\[ScriptN]\[ScriptP]\[ScriptU]\[ScriptT]\[ScriptCapitalA]\[ScriptL]\[ScriptI]\[ScriptA]\[ScriptS]]]; $Failed) /; Head[\[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalN]\[ScriptO]\[ScriptT]\[ScriptE]\[ScriptB]\[ScriptO]\[ScriptO]\[ScriptK]] =!= NotebookObject

AddInputAlias::badNotebook = "The third argument of `2` is not a notebook object."

\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]:AddInputAlias[___] := With[{\[ScriptN]\[ScriptU]\[ScriptM] = heldLength[\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]]}, $Failed /; Which[\[ScriptN]\[ScriptU]\[ScriptM] == 1, Message[AddInputAlias::argtu, HoldForm[AddInputAlias], 2, 3], \[ScriptN]\[ScriptU]\[ScriptM] < 2 || \[ScriptN]\[ScriptU]\[ScriptM] > 3, Message[AddInputAlias::argt, HoldForm[AddInputAlias], \[ScriptN]\[ScriptU]\[ScriptM], 2, 3], True, False]]

AddInputAlias[\[ScriptF]\[ScriptU]\[ScriptL]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]_NotationBoxTag, \[ScriptS]\[ScriptH]\[ScriptO]\[ScriptR]\[ScriptT]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM]_String, HoldPattern[\[ScriptN]\[ScriptO]\[ScriptT]\[ScriptE]\[ScriptB]\[ScriptO]\[ScriptO]\[ScriptK]_:SelectedNotebook[]]] := With[{\[ScriptA]\[ScriptL]\[ScriptI]\[ScriptA]\[ScriptS]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS] = stripNotationBoxTag[\[ScriptF]\[ScriptU]\[ScriptL]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]], \[ScriptO]\[ScriptL]\[ScriptD]\[ScriptCapitalA]\[ScriptL]\[ScriptI]\[ScriptA]\[ScriptS]\[ScriptE]\[ScriptS] = Options[\[ScriptN]\[ScriptO]\[ScriptT]\[ScriptE]\[ScriptB]\[ScriptO]\[ScriptO]\[ScriptK], "InputAliases"][[1,2]]}, SetOptions[\[ScriptN]\[ScriptO]\[ScriptT]\[ScriptE]\[ScriptB]\[ScriptO]\[ScriptO]\[ScriptK], "InputAliases" -> Join[DeleteCases[\[ScriptO]\[ScriptL]\[ScriptD]\[ScriptCapitalA]\[ScriptL]\[ScriptI]\[ScriptA]\[ScriptS]\[ScriptE]\[ScriptS], \[ScriptS]\[ScriptH]\[ScriptO]\[ScriptR]\[ScriptT]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM] :> _], {\[ScriptS]\[ScriptH]\[ScriptO]\[ScriptR]\[ScriptT]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM] :> \[ScriptA]\[ScriptL]\[ScriptI]\[ScriptA]\[ScriptS]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]}]]]

\[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalA]\[ScriptC]\[ScriptT]\[ScriptI]\[ScriptV]\[ScriptE]\[ScriptCapitalI]\[ScriptN]\[ScriptP]\[ScriptU]\[ScriptT]\[ScriptCapitalA]\[ScriptL]\[ScriptI]\[ScriptA]\[ScriptS]\[ScriptE]\[ScriptS]:ActiveInputAliases[\[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalN]\[ScriptO]\[ScriptT]\[ScriptE]\[ScriptB]\[ScriptO]\[ScriptO]\[ScriptK]_, ___] := (Message[ActiveInputAliases::badNotebook, HoldForm[\[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalN]\[ScriptO]\[ScriptT]\[ScriptE]\[ScriptB]\[ScriptO]\[ScriptO]\[ScriptK]], HoldForm[\[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalA]\[ScriptC]\[ScriptT]\[ScriptI]\[ScriptV]\[ScriptE]\[ScriptCapitalI]\[ScriptN]\[ScriptP]\[ScriptU]\[ScriptT]\[ScriptCapitalA]\[ScriptL]\[ScriptI]\[ScriptA]\[ScriptS]\[ScriptE]\[ScriptS]]]; $Failed) /; Head[\[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalN]\[ScriptO]\[ScriptT]\[ScriptE]\[ScriptB]\[ScriptO]\[ScriptO]\[ScriptK]] =!= NotebookObject

ActiveInputAliases::badNotebook = "The first argument of `2` is not a notebook object."

\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]:ActiveInputAliases[_, __] := $Failed /; Message[ActiveInputAliases::argt, HoldForm[ActiveInputAliases], heldLength[\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]], 0, 1]

ActiveInputAliases[HoldPattern[\[ScriptN]\[ScriptO]\[ScriptT]\[ScriptE]\[ScriptB]\[ScriptO]\[ScriptO]\[ScriptK]_:SelectedNotebook[]]] := DisplayForm[TableForm[Options[\[ScriptN]\[ScriptO]\[ScriptT]\[ScriptE]\[ScriptB]\[ScriptO]\[ScriptO]\[ScriptK], "InputAliases"][[1,2]]]]

SetDelayed[Condition[Notation[Pattern[\[ScriptA]\[ScriptN]\[ScriptY]\[ScriptCapitalN]\[ScriptO]\[ScriptT]\[ScriptA]\[ScriptT]\[ScriptI]\[ScriptO]\[ScriptN], BlankNullSequence[]]], CompoundExpression[silentEvaluate[Unset[adjustedOptions[Notation]]], False]], $Failed]

SetDelayed[RemoveNotation[Pattern[\[ScriptN]\[ScriptO]\[ScriptT]\[ScriptA]\[ScriptT]\[ScriptI]\[ScriptO]\[ScriptN], Blank[]], Pattern[\[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS], BlankNullSequence[]]], Notation[\[ScriptN]\[ScriptO]\[ScriptT]\[ScriptA]\[ScriptT]\[ScriptI]\[ScriptO]\[ScriptN], Rule[Action, RemoveNotationRules], \[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS]]]

SetDelayed[Notation[Pattern[\[ScriptO]\[ScriptL]\[ScriptD]\[ScriptCapitalN]\[ScriptO]\[ScriptT]\[ScriptA]\[ScriptT]\[ScriptI]\[ScriptO]\[ScriptN], Blank[]], Pattern[\[ScriptR]\[ScriptE]\[ScriptS]\[ScriptT], BlankNullSequence[]]], Condition[CompoundExpression[Message[MessageName[Notation, "oldNotation"]], Notation[Apply[DoubleLongLeftRightArrow, \[ScriptO]\[ScriptL]\[ScriptD]\[ScriptCapitalN]\[ScriptO]\[ScriptT]\[ScriptA]\[ScriptT]\[ScriptI]\[ScriptO]\[ScriptN]], \[ScriptR]\[ScriptE]\[ScriptS]\[ScriptT]]], MatchQ[SymbolName[Head[\[ScriptO]\[ScriptL]\[ScriptD]\[ScriptCapitalN]\[ScriptO]\[ScriptT]\[ScriptA]\[ScriptT]\[ScriptI]\[ScriptO]\[ScriptN]]], "DoubleLeftRightArrow"]]]

Set[MessageName[Notation, "oldNotation"], "Future versions of the Notation package will no longer support \[DoubleLeftRightArrow], instead they will use \[DoubleLongLeftRightArrow]. Please make this change to all your Notations."]

validNotationHeads = "DoubleLongRightArrow" | "DoubleLongLeftArrow" | "DoubleLongLeftRightArrow"

SetDelayed[Notation[Pattern[\[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalN]\[ScriptO]\[ScriptT]\[ScriptA]\[ScriptT]\[ScriptI]\[ScriptO]\[ScriptN], Blank[]], Pattern[\[ScriptR]\[ScriptE]\[ScriptS]\[ScriptT], BlankNullSequence[]]], Condition[CompoundExpression[Message[MessageName[Notation, "badNotation"], \[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalN]\[ScriptO]\[ScriptT]\[ScriptA]\[ScriptT]\[ScriptI]\[ScriptO]\[ScriptN]], $Failed], Not[MatchQ[SymbolName[Head[\[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalN]\[ScriptO]\[ScriptT]\[ScriptA]\[ScriptT]\[ScriptI]\[ScriptO]\[ScriptN]]], validNotationHeads]]]]

Set[MessageName[Notation, "badNotation"], "The notation \"`1`\" is not of the form \[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS] \[DoubleLongLeftRightArrow] \[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalE]\[ScriptX]\[ScriptP]\[ScriptR]\[ScriptE]\[ScriptS]\[ScriptS]\[ScriptI]\[ScriptO]\[ScriptN] or \[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS] \[DoubleLongRightArrow] \[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalE]\[ScriptX]\[ScriptP]\[ScriptR]\[ScriptE]\[ScriptS]\[ScriptS]\[ScriptI]\[ScriptO]\[ScriptN] or \[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS] \[DoubleLongLeftArrow] \[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalE]\[ScriptX]\[ScriptP]\[ScriptR]\[ScriptE]\[ScriptS]\[ScriptS]\[ScriptI]\[ScriptO]\[ScriptN]. Examine the full box structures for possible unintended groupings."]

SetDelayed[Pattern[\[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalN]\[ScriptO]\[ScriptT]\[ScriptA]\[ScriptT]\[ScriptI]\[ScriptO]\[ScriptN], Notation[Pattern[\[ScriptD]\[ScriptI]\[ScriptR]\[ScriptE]\[ScriptC]\[ScriptT]\[ScriptI]\[ScriptO]\[ScriptN], Blank[]][Pattern[\[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalN]\[ScriptO]\[ScriptT]\[ScriptA]\[ScriptT]\[ScriptI]\[ScriptO]\[ScriptN], Blank[]], Blank[]], Pattern[\[ScriptR]\[ScriptE]\[ScriptS]\[ScriptT], BlankNullSequence[]]]], Condition[CompoundExpression[Message[MessageName[Notation, "badExternalNotationBoxes"], HoldForm[\[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalN]\[ScriptO]\[ScriptT]\[ScriptA]\[ScriptT]\[ScriptI]\[ScriptO]\[ScriptN]], HoldForm[\[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalN]\[ScriptO]\[ScriptT]\[ScriptA]\[ScriptT]\[ScriptI]\[ScriptO]\[ScriptN]]], $Failed], UnsameQ[Head[\[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalN]\[ScriptO]\[ScriptT]\[ScriptA]\[ScriptT]\[ScriptI]\[ScriptO]\[ScriptN]], NotationBoxTag]]]

Set[MessageName[Notation, "badExternalNotationBoxes"], "The external representation `1` does not have an embedded NotationBoxTag TagBox. The Notation statement `2` may not have been entered using the palette, or the embedded TagBox may have been deleted. The embedded TagBox ensures correct parsing and retention of proper styling and grouping information."]

SetDelayed[Pattern[\[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalN]\[ScriptO]\[ScriptT]\[ScriptA]\[ScriptT]\[ScriptI]\[ScriptO]\[ScriptN], Notation[Pattern[\[ScriptD]\[ScriptI]\[ScriptR]\[ScriptE]\[ScriptC]\[ScriptT]\[ScriptI]\[ScriptO]\[ScriptN], Blank[]][Blank[], Pattern[\[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalN]\[ScriptO]\[ScriptT]\[ScriptA]\[ScriptT]\[ScriptI]\[ScriptO]\[ScriptN], Blank[]]], Pattern[\[ScriptR]\[ScriptE]\[ScriptS]\[ScriptT], BlankNullSequence[]]]], Condition[CompoundExpression[Message[MessageName[Notation, "badInternalNotationBoxes"], HoldForm[\[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalN]\[ScriptO]\[ScriptT]\[ScriptA]\[ScriptT]\[ScriptI]\[ScriptO]\[ScriptN]], HoldForm[\[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalN]\[ScriptO]\[ScriptT]\[ScriptA]\[ScriptT]\[ScriptI]\[ScriptO]\[ScriptN]]], $Failed], UnsameQ[Head[\[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalN]\[ScriptO]\[ScriptT]\[ScriptA]\[ScriptT]\[ScriptI]\[ScriptO]\[ScriptN]], NotationBoxTag]]]

Set[MessageName[Notation, "badInternalNotationBoxes"], "The internal representation `1` does not have an embedded NotationBoxTag TagBox. The Notation statement `2` may not have been entered using the palette, or the embedded TagBox may have been deleted. The embedded TagBox ensures correct parsing and retention of proper styling and grouping information."]

SetDelayed[Pattern[\[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalN]\[ScriptO]\[ScriptT]\[ScriptA]\[ScriptT]\[ScriptI]\[ScriptO]\[ScriptN], Notation[Pattern[\[ScriptN]\[ScriptO]\[ScriptT]\[ScriptA]\[ScriptT]\[ScriptI]\[ScriptO]\[ScriptN], Blank[]], BlankNullSequence[], Pattern[\[ScriptN]\[ScriptO]\[ScriptT]\[ScriptCapitalO]\[ScriptP]\[ScriptT]\[ScriptI]\[ScriptO]\[ScriptN], Blank[]], BlankNullSequence[]]], Condition[CompoundExpression[Message[MessageName[Notation, "nonopt"], HoldForm[\[ScriptN]\[ScriptO]\[ScriptT]\[ScriptCapitalO]\[ScriptP]\[ScriptT]\[ScriptI]\[ScriptO]\[ScriptN]], 1, HoldForm[\[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalN]\[ScriptO]\[ScriptT]\[ScriptA]\[ScriptT]\[ScriptI]\[ScriptO]\[ScriptN]]], $Failed], Not[OptionQ[\[ScriptN]\[ScriptO]\[ScriptT]\[ScriptCapitalO]\[ScriptP]\[ScriptT]\[ScriptI]\[ScriptO]\[ScriptN]]]]]

SetDelayed[Pattern[\[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalN]\[ScriptO]\[ScriptT]\[ScriptA]\[ScriptT]\[ScriptI]\[ScriptO]\[ScriptN], Notation[Pattern[\[ScriptN]\[ScriptO]\[ScriptT]\[ScriptA]\[ScriptT]\[ScriptI]\[ScriptO]\[ScriptN], Blank[]], BlankNullSequence[], Alternatives[Rule, RuleDelayed][Action, Pattern[\[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalV]\[ScriptA]\[ScriptL]\[ScriptU]\[ScriptE], Blank[]]], BlankNullSequence[]]], Condition[CompoundExpression[Message[MessageName[Notation, "optcrp"], Action, HoldForm[\[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalV]\[ScriptA]\[ScriptL]\[ScriptU]\[ScriptE]], HoldForm[\[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalN]\[ScriptO]\[ScriptT]\[ScriptA]\[ScriptT]\[ScriptI]\[ScriptO]\[ScriptN]]], $Failed], Not[MatchQ[\[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalV]\[ScriptA]\[ScriptL]\[ScriptU]\[ScriptE], Alternatives[CreateNotationRules, RemoveNotationRules, PrintNotationRules]]]]]

Set[MessageName[Notation, "optcrp"], "Value of option \"`1` \[Rule] `2`\" in `3` should be CreateNotationRules, RemoveNotationRules or PrintNotationRules."]

SetDelayed[Pattern[\[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalN]\[ScriptO]\[ScriptT]\[ScriptA]\[ScriptT]\[ScriptI]\[ScriptO]\[ScriptN], Notation[Pattern[\[ScriptN]\[ScriptO]\[ScriptT]\[ScriptA]\[ScriptT]\[ScriptI]\[ScriptO]\[ScriptN]\[ScriptCapitalT]\[ScriptY]\[ScriptP]\[ScriptE], Blank[]][Pattern[\[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL], Blank[]], Pattern[\[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL], Blank[]]], Pattern[\[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS], BlankNullSequence[]]]], Condition[CompoundExpression[Message[MessageName[Notation, "badRepresentationBoxes"], HoldForm[\[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]], HoldForm[\[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalN]\[ScriptO]\[ScriptT]\[ScriptA]\[ScriptT]\[ScriptI]\[ScriptO]\[ScriptN]]], $Failed], silentEvaluate[Not[parsableQ[stripNotationBoxTag[\[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]], \[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS]]]]]]

Set[MessageName[Notation, "badRepresentationBoxes"], "Cannot parse the internal representation \"`1`\" occurring in `2`"]

fullArrowsToShortArrowsRules = {"DoubleLongRightArrow" -> "\[DoubleLongRightArrow]", "DoubleLongLeftArrow" -> "\[DoubleLongLeftArrow]", "DoubleLongLeftRightArrow" -> "\[DoubleLongLeftRightArrow]"}

SetDelayed[Notation[Pattern[\[ScriptN]\[ScriptO]\[ScriptT]\[ScriptA]\[ScriptT]\[ScriptI]\[ScriptO]\[ScriptN]\[ScriptCapitalT]\[ScriptY]\[ScriptP]\[ScriptE], Blank[]][Pattern[\[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL], Blank[]], Pattern[\[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL], Blank[]]], Pattern[\[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS], BlankNullSequence[]]], checkNotationPatterns[\[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL], patternsInBoxes[\[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL], \[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS]], ReplaceAll[SymbolName[\[ScriptN]\[ScriptO]\[ScriptT]\[ScriptA]\[ScriptT]\[ScriptI]\[ScriptO]\[ScriptN]\[ScriptCapitalT]\[ScriptY]\[ScriptP]\[ScriptE]], fullArrowsToShortArrowsRules], \[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL], patternsInBoxes[\[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL], \[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS]], \[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS]]]

SetDelayed[patternsInBoxes[Pattern[\[ScriptB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], Blank[]], Pattern[\[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS], BlankNullSequence[]]], Module[List[Set[\[ScriptCapitalW]\[ScriptO]\[ScriptR]\[ScriptK]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM], ReplaceAll[ReplaceAll[WorkingForm, List[\[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS]]], adjustedOptions[Notation]]]], Union[Cases[ReplaceRepeated[\[ScriptB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], List[RuleDelayed[TagBox[Pattern[\[ScriptS]\[ScriptT]\[ScriptR]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], Blank[]], NotationPatternTag, BlankNullSequence[]], With[List[Set[eval, convertPatterns[toMyHeldExpression[\[ScriptS]\[ScriptT]\[ScriptR]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], \[ScriptCapitalW]\[ScriptO]\[ScriptR]\[ScriptK]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM]]]]], Condition[eval, True]]], RuleDelayed[TagBox[Pattern[\[ScriptS]\[ScriptT]\[ScriptR]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], Blank[]], NotationMadeBoxesTag, BlankNullSequence[]], With[List[Set[eval, convertPatterns[toMyHeldExpression[\[ScriptS]\[ScriptT]\[ScriptR]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], \[ScriptCapitalW]\[ScriptO]\[ScriptR]\[ScriptK]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM]]]]], Condition[eval, True]]], RuleDelayed[Condition[Pattern[\[ScriptS]\[ScriptT]\[ScriptR]\[ScriptI]\[ScriptN]\[ScriptG], Blank[String]], StringMatchQ[\[ScriptS]\[ScriptT]\[ScriptR]\[ScriptI]\[ScriptN]\[ScriptG], "*_"]], With[List[Set[eval, convertPatterns[toMyHeldExpression[\[ScriptS]\[ScriptT]\[ScriptR]\[ScriptI]\[ScriptN]\[ScriptG], \[ScriptCapitalW]\[ScriptO]\[ScriptR]\[ScriptK]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM]]]]], Condition[eval, True]]]]], Rule[Alternatives[Pattern[a, Blank[singleBlank]], Pattern[a, Blank[doubleBlank]], Pattern[a, Blank[tripleBlank]], Pattern[a, Blank[complexPattern]]], a], List[0, Infinity]]]]]

SetDelayed[checkNotationPatterns[Pattern[\[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], Blank[]], Pattern[\[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptS], Blank[]], Alternatives["\[DoubleLongLeftArrow]", "\[DoubleLongLeftRightArrow]"], Pattern[\[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], Blank[]], Pattern[\[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptS], Blank[]], Pattern[\[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS], BlankNullSequence[]]], Condition[CompoundExpression[Message[MessageName[Notation, "freePattsInExternalNotation"], Apply[identityForm, \[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]]], $Failed], containsFreeBlanksQ[\[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptS]]]]

Set[MessageName[Notation, "freePattsInExternalNotation"], "All patterns in the external representation must be able to be filled.  Free blank patterns found inside the external representation \"`1`\"."]

SetDelayed[checkNotationPatterns[Pattern[\[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], Blank[]], Pattern[\[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptS], Blank[]], Alternatives["\[DoubleLongRightArrow]", "\[DoubleLongLeftRightArrow]"], Pattern[\[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], Blank[]], Pattern[\[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptS], Blank[]], Pattern[\[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS], BlankNullSequence[]]], Condition[CompoundExpression[Message[MessageName[Notation, "freePattsInInternalNotation"], Apply[identityForm, \[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]]], $Failed], containsFreeBlanksQ[\[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptS]]]]

Set[MessageName[Notation, "freePattsInInternalNotation"], "All patterns in the internal representation must be able to be filled.  Free blank patterns found inside the internal representation \"`1`\"."]

containsFreeBlanksQ[\[ScriptP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptS]_] :=  !FreeQ[\[ScriptP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptS], singleBlank[] | doubleBlank[] | tripleBlank[]]

SetDelayed[checkNotationPatterns[Pattern[\[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], Blank[]], Pattern[\[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptS], Blank[]], Alternatives["\[DoubleLongLeftArrow]", "\[DoubleLongLeftRightArrow]"], Pattern[\[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], Blank[]], Pattern[\[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptS], Blank[]], Pattern[\[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS], BlankNullSequence[]]], With[List[Set[\[ScriptL]\[ScriptH]\[ScriptS]\[ScriptCapitalP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptS]\[ScriptCapitalN]\[ScriptO]\[ScriptT]\[ScriptCapitalI]\[ScriptN]\[ScriptR]\[ScriptH]\[ScriptS], Complement[\[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptS], \[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptS]]]], Condition[CompoundExpression[Message[MessageName[Notation, "externalPatternNotFilled"], Apply[HoldForm, First[\[ScriptL]\[ScriptH]\[ScriptS]\[ScriptCapitalP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptS]\[ScriptCapitalN]\[ScriptO]\[ScriptT]\[ScriptCapitalI]\[ScriptN]\[ScriptR]\[ScriptH]\[ScriptS]]], Apply[identityForm, \[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]], Apply[identityForm, \[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]]], $Failed], UnsameQ[\[ScriptL]\[ScriptH]\[ScriptS]\[ScriptCapitalP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptS]\[ScriptCapitalN]\[ScriptO]\[ScriptT]\[ScriptCapitalI]\[ScriptN]\[ScriptR]\[ScriptH]\[ScriptS], List[]]]]]

Set[MessageName[Notation, "externalPatternNotFilled"], "Pattern \"`1`\" appearing in the external representation \"`2`\" cannot be filled since \"`1`\" does not appear in the internal representation \"`3`\"."]

SetDelayed[checkNotationPatterns[Pattern[\[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], Blank[]], Pattern[\[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptS], Blank[]], Alternatives["\[DoubleLongRightArrow]", "\[DoubleLongLeftRightArrow]"], Pattern[\[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], Blank[]], Pattern[\[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptS], Blank[]], Pattern[\[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS], BlankNullSequence[]]], With[List[Set[\[ScriptR]\[ScriptH]\[ScriptS]\[ScriptCapitalP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptS]\[ScriptCapitalN]\[ScriptO]\[ScriptT]\[ScriptCapitalI]\[ScriptN]\[ScriptL]\[ScriptH]\[ScriptS], Complement[\[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptS], \[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptS]]]], Condition[CompoundExpression[Message[MessageName[Notation, "internalPatternNotFilled"], Apply[HoldForm, First[\[ScriptR]\[ScriptH]\[ScriptS]\[ScriptCapitalP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptS]\[ScriptCapitalN]\[ScriptO]\[ScriptT]\[ScriptCapitalI]\[ScriptN]\[ScriptL]\[ScriptH]\[ScriptS]]], Apply[identityForm, \[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]], Apply[identityForm, \[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]]], $Failed], UnsameQ[\[ScriptR]\[ScriptH]\[ScriptS]\[ScriptCapitalP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptS]\[ScriptCapitalN]\[ScriptO]\[ScriptT]\[ScriptCapitalI]\[ScriptN]\[ScriptL]\[ScriptH]\[ScriptS], List[]]]]]

Set[MessageName[Notation, "internalPatternNotFilled"], "Pattern \"`1`\" appearing in the internal representation \"`2`\" cannot be filled since \"`1`\" does not appear in the external representation \"`3`\"."]

SetDelayed[checkNotationPatterns[Pattern[\[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], Blank[]], Pattern[\[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptS], Blank[]], "\[DoubleLongRightArrow]", Pattern[\[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], Blank[]], Pattern[\[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptS], Blank[]], Pattern[\[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS], BlankNullSequence[]]], With[List[Set[\[ScriptL]\[ScriptH]\[ScriptS]\[ScriptCapitalP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptS]\[ScriptCapitalN]\[ScriptO]\[ScriptT]\[ScriptCapitalI]\[ScriptN]\[ScriptR]\[ScriptH]\[ScriptS], Complement[\[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptS], \[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptS], List[singleBlank[], doubleBlank[], tripleBlank[]]]]], Condition[$Failed, And[UnsameQ[\[ScriptL]\[ScriptH]\[ScriptS]\[ScriptCapitalP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptS]\[ScriptCapitalN]\[ScriptO]\[ScriptT]\[ScriptCapitalI]\[ScriptN]\[ScriptR]\[ScriptH]\[ScriptS], List[]], Message[MessageName[Notation, "externalPatternsNotUsed"], Map[Function[Apply[HoldForm, Slot[1]]], \[ScriptL]\[ScriptH]\[ScriptS]\[ScriptCapitalP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptS]\[ScriptCapitalN]\[ScriptO]\[ScriptT]\[ScriptCapitalI]\[ScriptN]\[ScriptR]\[ScriptH]\[ScriptS]], Apply[identityForm, \[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]], Apply[identityForm, \[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]]]]]]]

Set[MessageName[Notation, "externalPatternsNotUsed"], "Warning: The pattern(s) \"`1`\" appearing in the external representation \"`2`\" are not used in the internal representation \"`3`\"."]

SetDelayed[checkNotationPatterns[Pattern[\[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], Blank[]], Pattern[\[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptS], Blank[]], "\[DoubleLongLeftArrow]", Pattern[\[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], Blank[]], Pattern[\[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptS], Blank[]], Pattern[\[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS], BlankNullSequence[]]], With[List[Set[\[ScriptR]\[ScriptH]\[ScriptS]\[ScriptCapitalP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptS]\[ScriptCapitalN]\[ScriptO]\[ScriptT]\[ScriptCapitalI]\[ScriptN]\[ScriptL]\[ScriptH]\[ScriptS], Complement[\[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptS], \[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptS], List[singleBlank[], doubleBlank[], tripleBlank[]]]]], Condition[$Failed, And[UnsameQ[\[ScriptR]\[ScriptH]\[ScriptS]\[ScriptCapitalP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptS]\[ScriptCapitalN]\[ScriptO]\[ScriptT]\[ScriptCapitalI]\[ScriptN]\[ScriptL]\[ScriptH]\[ScriptS], List[]], Message[MessageName[Notation, "internalPatternNotUsed"], Map[Function[Apply[HoldForm, Slot[1]]], \[ScriptR]\[ScriptH]\[ScriptS]\[ScriptCapitalP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptS]\[ScriptCapitalN]\[ScriptO]\[ScriptT]\[ScriptCapitalI]\[ScriptN]\[ScriptL]\[ScriptH]\[ScriptS]], Apply[identityForm, \[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]], Apply[identityForm, \[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]]]]]]]

Set[MessageName[Notation, "internalPatternNotUsed"], "Warning: The pattern(s) \"`1`\" appearing in the internal representation \"`2`\" are not used in the external representation \"`3`\"."]

SetDelayed[checkNotationPatterns[Pattern[\[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], Blank[]], Pattern[\[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptS], Blank[]], Pattern[\[ScriptT]\[ScriptY]\[ScriptP]\[ScriptE], Blank[]], Pattern[\[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], Blank[]], Pattern[\[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptS], Blank[]], Pattern[\[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS], BlankNullSequence[]]], With[List[Set[\[ScriptP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptE]\[ScriptD]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], boxedStringPatternsToPatterns[Apply[cleanBoxes, \[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]], ReplaceAll[ReplaceAll[Rule[WorkingForm, WorkingForm], List[\[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS]]], adjustedOptions[Notation]]]]], Condition[CompoundExpression[Message[MessageName[Notation, "externalPatternToGeneral"], \[ScriptP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptE]\[ScriptD]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], \[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], identityForm[\[ScriptT]\[ScriptY]\[ScriptP]\[ScriptE]], \[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]], $Failed], patternToGeneralQ[\[ScriptP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptE]\[ScriptD]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]]]]]

Set[MessageName[Notation, "externalPatternToGeneral"], "The external pattern `1` appearing in Notation[`2` `3` `4`] is too general to be used. Almost anything will match the external pattern `1`."]

SetDelayed[checkNotationPatterns[Pattern[\[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], Blank[]], Pattern[\[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptS], Blank[]], Pattern[\[ScriptT]\[ScriptY]\[ScriptP]\[ScriptE], Blank[]], Pattern[\[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], Blank[]], Pattern[\[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptS], Blank[]], Pattern[\[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS], BlankNullSequence[]]], With[List[Set[\[ScriptP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptE]\[ScriptD]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], boxedStringPatternsToPatterns[Apply[cleanBoxes, \[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]], ReplaceAll[ReplaceAll[Rule[WorkingForm, WorkingForm], List[\[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS]]], adjustedOptions[Notation]]]]], Condition[CompoundExpression[Message[MessageName[Notation, "internalPatternToGeneral"], \[ScriptP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptE]\[ScriptD]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], \[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], identityForm[\[ScriptT]\[ScriptY]\[ScriptP]\[ScriptE]], \[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]], $Failed], patternToGeneralQ[\[ScriptP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptE]\[ScriptD]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]]]]]

Set[MessageName[Notation, "internalPatternToGeneral"], "The internal pattern `1` appearing in Notation[`2` `3` `4`] is too general to be used. Almost anything will match the internal pattern `1`."]

checkNotationPatterns[\[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]_, \[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptS]_, \[ScriptT]\[ScriptY]\[ScriptP]\[ScriptE]_, \[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]_, \[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptS]_, \[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS]___] := executeNotation[\[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], \[ScriptT]\[ScriptY]\[ScriptP]\[ScriptE], \[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], \[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS]]

\[ScriptA]\[ScriptL]\[ScriptL]\[ScriptO]\[ScriptK]:executeNotation[\[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]_, "\[DoubleLongLeftRightArrow]", \[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]_, \[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS]___] := With[{\[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS] = stripNotationBoxTag[\[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]], \[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS] = stripNotationBoxTag[\[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]]}, createExternalToInternalRule[\[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], \[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], \[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS]]; createInternalToExternalRule[\[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], \[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], \[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS]]; ]

\[ScriptA]\[ScriptL]\[ScriptL]\[ScriptO]\[ScriptK]:executeNotation[\[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]_, "\[DoubleLongRightArrow]", \[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]_, \[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS]___] := With[{\[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS] = stripNotationBoxTag[\[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]], \[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS] = stripNotationBoxTag[\[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]]}, createExternalToInternalRule[\[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], \[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], \[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS]]]

\[ScriptA]\[ScriptL]\[ScriptL]\[ScriptO]\[ScriptK]:executeNotation[\[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]_, "\[DoubleLongLeftArrow]", \[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]_, \[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS]___] := With[{\[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS] = stripNotationBoxTag[\[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]], \[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS] = stripNotationBoxTag[\[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]]}, createInternalToExternalRule[\[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], \[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], \[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS]]]

SetDelayed[Notation[Pattern[\[ScriptO]\[ScriptT]\[ScriptH]\[ScriptE]\[ScriptR], BlankNullSequence[]]], CompoundExpression[Message[MessageName[Notation, "unknownParseError"]], StylePrint[identityForm[colorizeStructuralBoxes[HoldForm[Notation][\[ScriptO]\[ScriptT]\[ScriptH]\[ScriptE]\[ScriptR]], 1]], "Output"], $Failed]]

Set[MessageName[Notation, "unknownParseError"], "Unknown error occurred in parsing the notation statement. Please report this to jasonh@wri.com, Please carefully examine the following box structures for spurious characters weird groupings etc."]

SetDelayed[checkNotationPatterns[Pattern[\[ScriptO]\[ScriptT]\[ScriptH]\[ScriptE]\[ScriptR], BlankNullSequence[]]], CompoundExpression[Message[MessageName[Notation, "unknownPatternUsageError"]], StylePrint[identityForm[colorizeStructuralBoxes[HoldForm[Notation][\[ScriptO]\[ScriptT]\[ScriptH]\[ScriptE]\[ScriptR]], 1]], "Output"], $Failed]]

Set[MessageName[Notation, "unknownPatternUsageError"], "Unknown error occurred in checking the pattern used in the notation statement. It appears to have parsed ok. Please report this to jasonh@wri.com, Please carefully examine the following box structures for spurious characters weird groupings etc."]

Set[MessageName[Notation, "unknownExecutionError"], "Unknown error occurred in executing the notation statement. It appears to have parsed and been processed ok. Please report this to jasonh@wri.com, Please carefully examine the following box structures for spurious characters weird groupings etc."]

SetDelayed[convertInternalPatternsForInternalToExternal[Pattern[\[ScriptP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], Blank[]], PatternTest[Pattern[\[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS], BlankNullSequence[]], OptionQ]], With[List[Set[\[ScriptCapitalW]\[ScriptO]\[ScriptR]\[ScriptK]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM], ReplaceAll[ReplaceAll[WorkingForm, List[\[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS]]], adjustedOptions[Notation]]]], ReplaceRepeated[cleanBoxes[\[ScriptP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]], List[RuleDelayed[TagBox[Pattern[\[ScriptS]\[ScriptT]\[ScriptR]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], Blank[]], NotationPatternTag, BlankNullSequence[]], Apply[Function[MakeBoxes[Slot[1], \[ScriptCapitalW]\[ScriptO]\[ScriptR]\[ScriptK]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM]]], toInert[toMyHeldExpression[\[ScriptS]\[ScriptT]\[ScriptR]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], \[ScriptCapitalW]\[ScriptO]\[ScriptR]\[ScriptK]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM]]]]], RuleDelayed[TagBox[Pattern[\[ScriptS]\[ScriptT]\[ScriptR]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], Blank[]], NotationMadeBoxesTag, BlankNullSequence[]], Apply[Function[MakeBoxes[Slot[1], \[ScriptCapitalW]\[ScriptO]\[ScriptR]\[ScriptK]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM]]], toInert[toMyHeldExpression[\[ScriptS]\[ScriptT]\[ScriptR]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], \[ScriptCapitalW]\[ScriptO]\[ScriptR]\[ScriptK]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM]]]]]]]]]

SetDelayed[convertInternalBoxesForInternalToExternal[Pattern[\[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], Blank[]], PatternTest[Pattern[\[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS], BlankNullSequence[]], OptionQ]], With[List[Set[\[ScriptCapitalW]\[ScriptO]\[ScriptR]\[ScriptK]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM], ReplaceAll[ReplaceAll[WorkingForm, List[\[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS]]], adjustedOptions[Notation]]]], With[List[Set[\[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL], toMyHeldExpression[convertInternalPatternsForInternalToExternal[\[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], \[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS]], \[ScriptCapitalW]\[ScriptO]\[ScriptR]\[ScriptK]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM]]]], fromInert[transformNotationalPatterns[flattenAllMyHold[myHold[NotationMakeBoxes[\[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL], \[ScriptCapitalW]\[ScriptO]\[ScriptR]\[ScriptK]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM]]]]]]]]]

toInert[expr_] := expr /. {Pattern -> Symbol[StringJoin[Context[], "inert`Pattern"]], PatternTest -> Symbol[StringJoin[Context[], "inert`PatternTest"]], Condition -> Symbol[StringJoin[Context[], "inert`Condition"]], Alternatives -> Symbol[StringJoin[Context[], "inert`Alternatives"]], Optional -> Symbol[StringJoin[Context[], "inert`Optional"]], Repeated -> Symbol[StringJoin[Context[], "inert`Repeated"]], RepeatedNull -> Symbol[StringJoin[Context[], "inert`RepeatedNull"]]}
fromInert[expr_] := expr /. {Symbol[StringJoin[Context[], "inert`Pattern"]] -> Pattern, Symbol[StringJoin[Context[], "inert`PatternTest"]] -> PatternTest, Symbol[StringJoin[Context[], "inert`Condition"]] -> Condition, Symbol[StringJoin[Context[], "inert`Alternatives"]] -> Alternatives, Symbol[StringJoin[Context[], "inert`Optional"]] -> Optional, Symbol[StringJoin[Context[], "inert`Repeated"]] -> Repeated, Symbol[StringJoin[Context[], "inert`RepeatedNull"]] -> RepeatedNull}
SetAttributes[inertHold, HoldAll]

SetDelayed[transformNotationalPatterns[Pattern[\[ScriptP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptS], Blank[]]], ReplaceRepeated[ReplaceRepeated[\[ScriptP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptS], Rule[HoldPattern[HoldPattern[HoldPattern][Pattern[\[ScriptP]\[ScriptA]\[ScriptT]\[ScriptT], Blank[]]]], Verbatim[HoldPattern][\[ScriptP]\[ScriptA]\[ScriptT]\[ScriptT]]]], List[Rule[Condition[Condition[HoldPattern[HoldPattern[Pattern][Pattern[\[ScriptP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptCapitalV]\[ScriptA]\[ScriptR]\[ScriptI]\[ScriptA]\[ScriptB]\[ScriptL]\[ScriptE], Blank[]], Pattern[\[ScriptP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptCapitalC]\[ScriptO]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptN]\[ScriptT], Blank[]]]], Not[MatchQ[\[ScriptP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptCapitalC]\[ScriptO]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptN]\[ScriptT], HoldPattern[Alternatives[Blank, BlankSequence, BlankNullSequence]][]]]], CompoundExpression[Message[MessageName[Notation, "notationalPatternsUsed"], HoldForm[HoldForm[Pattern][\[ScriptP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptCapitalV]\[ScriptA]\[ScriptR]\[ScriptI]\[ScriptA]\[ScriptB]\[ScriptL]\[ScriptE], \[ScriptP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptCapitalC]\[ScriptO]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptN]\[ScriptT]]]], True]], Pattern[patt, Pattern][\[ScriptP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptCapitalV]\[ScriptA]\[ScriptR]\[ScriptI]\[ScriptA]\[ScriptB]\[ScriptL]\[ScriptE], \[ScriptP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptCapitalC]\[ScriptO]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptN]\[ScriptT]]], Rule[Condition[HoldPattern[HoldPattern[PatternTest][Pattern[\[ScriptP]\[ScriptA]\[ScriptT]\[ScriptT], Blank[]], Pattern[\[ScriptP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptCapitalT]\[ScriptE]\[ScriptS]\[ScriptT], Blank[]]]], CompoundExpression[Message[MessageName[Notation, "notationalPatternsUsed"], HoldForm[PatternTest[\[ScriptP]\[ScriptA]\[ScriptT]\[ScriptT], \[ScriptP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptCapitalT]\[ScriptE]\[ScriptS]\[ScriptT]]]], True]], HoldPattern[PatternTest][\[ScriptP]\[ScriptA]\[ScriptT]\[ScriptT], HoldPattern[\[ScriptP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptCapitalT]\[ScriptE]\[ScriptS]\[ScriptT]]]], Rule[Condition[HoldPattern[HoldPattern[Condition][Pattern[\[ScriptP]\[ScriptA]\[ScriptT]\[ScriptT], Blank[]], Pattern[\[ScriptC]\[ScriptO]\[ScriptN]\[ScriptD], Blank[]]]], CompoundExpression[Message[MessageName[Notation, "notationalPatternsUsed"], HoldForm[Condition[\[ScriptP]\[ScriptA]\[ScriptT]\[ScriptT], \[ScriptC]\[ScriptO]\[ScriptN]\[ScriptD]]]], True]], HoldPattern[HoldPattern[Condition][\[ScriptP]\[ScriptA]\[ScriptT]\[ScriptT], \[ScriptC]\[ScriptO]\[ScriptN]\[ScriptD]]]], Rule[Condition[HoldPattern[HoldPattern[Alternatives][Pattern[\[ScriptP]\[ScriptA]\[ScriptT]\[ScriptT], BlankSequence[]]]], CompoundExpression[Message[MessageName[Notation, "notationalPatternsUsed"], HoldForm[Alternatives[\[ScriptP]\[ScriptA]\[ScriptT]\[ScriptT]]]], True]], HoldPattern[Alternatives][\[ScriptP]\[ScriptA]\[ScriptT]\[ScriptT]]], Rule[Condition[HoldPattern[HoldPattern[Optional][Pattern[\[ScriptP]\[ScriptA]\[ScriptT]\[ScriptT], BlankSequence[]]]], CompoundExpression[Message[MessageName[Notation, "notationalPatternsUsed"], HoldForm[Optional[\[ScriptP]\[ScriptA]\[ScriptT]\[ScriptT]]]], True]], HoldPattern[Optional][\[ScriptP]\[ScriptA]\[ScriptT]\[ScriptT]]], Rule[Condition[HoldPattern[HoldPattern[Repeated][Pattern[\[ScriptP]\[ScriptA]\[ScriptT]\[ScriptT], BlankSequence[]]]], CompoundExpression[Message[MessageName[Notation, "notationalPatternsUsed"], HoldForm[Repeated[\[ScriptP]\[ScriptA]\[ScriptT]\[ScriptT]]]], True]], HoldPattern[Repeated][\[ScriptP]\[ScriptA]\[ScriptT]\[ScriptT]]], Rule[Condition[HoldPattern[HoldPattern[RepeatedNull][Pattern[\[ScriptP]\[ScriptA]\[ScriptT]\[ScriptT], BlankSequence[]]]], CompoundExpression[Message[MessageName[Notation, "notationalPatternsUsed"], HoldForm[RepeatedNull[\[ScriptP]\[ScriptA]\[ScriptT]\[ScriptT]]]], True]], HoldPattern[RepeatedNull][\[ScriptP]\[ScriptA]\[ScriptT]\[ScriptT]]]]]]

Set[MessageName[Notation, "notationalPatternsUsed"], "Warning: The pattern `1` is being interpreted as a notation and not a pattern. Use an embedded NotationPatternTag TagBox wrapper if you want this pattern to be treated as a genuine pattern."]

SetDelayed[convertExternalPatternsForInternalToExternal[Pattern[\[ScriptP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], Blank[]], PatternTest[Pattern[\[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS], BlankNullSequence[]], OptionQ]], Module[List[Set[\[ScriptCapitalW]\[ScriptO]\[ScriptR]\[ScriptK]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM], ReplaceAll[ReplaceAll[WorkingForm, List[\[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS]]], adjustedOptions[Notation]]]], flattenAllMyHold[Apply[myHold, List[ReplaceRepeated[\[ScriptP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], List[RuleDelayed[TagBox[Pattern[\[ScriptS]\[ScriptT]\[ScriptR]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], Blank[]], NotationMadeBoxesTag, BlankNullSequence[]], Apply[myHold, removePatternsAndBlanks[Apply[complexPattern, toMyHeldExpression[\[ScriptS]\[ScriptT]\[ScriptR]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], \[ScriptCapitalW]\[ScriptO]\[ScriptR]\[ScriptK]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM]]]]]], RuleDelayed[TagBox[Pattern[\[ScriptS]\[ScriptT]\[ScriptR]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], Blank[]], NotationPatternTag, BlankNullSequence[]], removePatternsAndBlanks[Apply[complexPattern, toMyHeldExpression[\[ScriptS]\[ScriptT]\[ScriptR]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], \[ScriptCapitalW]\[ScriptO]\[ScriptR]\[ScriptK]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM]]]]], RuleDelayed[TagBox[Pattern[\[ScriptS]\[ScriptT]\[ScriptR]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], Blank[]], NotationBoxTag, BlankNullSequence[]], \[ScriptS]\[ScriptT]\[ScriptR]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]], RuleDelayed[Condition[Pattern[\[ScriptS]\[ScriptT]\[ScriptR]\[ScriptI]\[ScriptN]\[ScriptG], Blank[String]], StringMatchQ[\[ScriptS]\[ScriptT]\[ScriptR]\[ScriptI]\[ScriptN]\[ScriptG], "*_"]], convertPatterns[toMyHeldExpression[\[ScriptS]\[ScriptT]\[ScriptR]\[ScriptI]\[ScriptN]\[ScriptG], \[ScriptCapitalW]\[ScriptO]\[ScriptR]\[ScriptK]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM]]]]]]]]]]]

\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]:convertExternalPatternsForInternalToExternal[_, ___, (\[ScriptN]\[ScriptO]\[ScriptT]\[ScriptCapitalO]\[ScriptP]\[ScriptT]\[ScriptI]\[ScriptO]\[ScriptN]_)?(isNot[_?OptionQ]), ___] := $Failed /; Message[convertExternalPatternsForInternalToExternal::nonopt, HoldForm[\[ScriptN]\[ScriptO]\[ScriptT]\[ScriptCapitalO]\[ScriptP]\[ScriptT]\[ScriptI]\[ScriptO]\[ScriptN]], 1, HoldForm[\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]]]

SetDelayed[convertExternalBoxesForInternalToExternal[Pattern[\[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], Blank[]], PatternTest[Pattern[\[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS], BlankNullSequence[]], OptionQ]], Module[List[\[ScriptCapitalC]\[ScriptO]\[ScriptM]\[ScriptM]\[ScriptA]\[ScriptCapitalQ]], CompoundExpression[SetDelayed[\[ScriptCapitalC]\[ScriptO]\[ScriptM]\[ScriptM]\[ScriptA]\[ScriptCapitalQ][Alternatives[",", "\[InvisibleComma]"]], True], SetDelayed[\[ScriptCapitalC]\[ScriptO]\[ScriptM]\[ScriptM]\[ScriptA]\[ScriptCapitalQ][Pattern[\[ScriptO]\[ScriptT]\[ScriptH]\[ScriptE]\[ScriptR], Blank[]]], False], With[List[Set[\[ScriptCapitalR]\[ScriptCapitalB], RowBox], Set[\[ScriptCapitalB], singleBlank], Set[\[ScriptCapitalB]\[ScriptCapitalB], Alternatives[doubleBlank, tripleBlank]], Set[\[ScriptCapitalC]\[ScriptCapitalP], complexPattern], Set[\[ScriptCapitalO]\[ScriptP]\[ScriptCapitalQ], operatorQ], Set[\[ScriptCapitalI]\[ScriptN]\[ScriptCapitalQ], infixOperatorQ], Set[\[ScriptCapitalP]\[ScriptR]\[ScriptE]\[ScriptCapitalQ], prefixOperatorQ], Set[\[ScriptCapitalP]\[ScriptO]\[ScriptS]\[ScriptT]\[ScriptCapitalQ], postfixOperatorQ], Set[\[ScriptCapitalD]\[ScriptE]\[ScriptL]\[ScriptI]\[ScriptM]\[ScriptCapitalQ], delimiterQ], Set[\[ScriptCapitalE]\[ScriptF]\[ScriptF]\[ScriptCapitalO]\[ScriptP], effectiveOperator], Set[\[ScriptCapitalP]\[ScriptA]\[ScriptR]\[ScriptE]\[ScriptN], Parenthesize], Set[\[ScriptCapitalW]\[ScriptH]\[ScriptCapitalQ], whiteSpaceQ], Set[\[ScriptF]\[ScriptO]\[ScriptR]\[ScriptM], ReplaceAll[ReplaceAll[WorkingForm, List[\[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS]]], adjustedOptions[Notation]]]], ReplaceRepeated[convertExternalPatternsForInternalToExternal[tidyBoxes[\[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]], \[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS]], List[RuleDelayed[\[ScriptCapitalR]\[ScriptCapitalB][List[Pattern[\[ScriptL], BlankNullSequence[]], PatternTest[Pattern[\[ScriptO]\[ScriptP], Blank[]], \[ScriptCapitalP]\[ScriptR]\[ScriptE]\[ScriptCapitalQ]], PatternTest[Pattern[\[ScriptW], BlankNullSequence[]], \[ScriptCapitalW]\[ScriptH]\[ScriptCapitalQ]], \[ScriptCapitalB][Pattern[\[ScriptS]\[ScriptY]\[ScriptM]\[ScriptB], Blank[]]], Pattern[\[ScriptR], BlankNullSequence[]]]], With[List[Set[\[ScriptP]\[ScriptR]\[ScriptE]\[ScriptC], \[ScriptCapitalE]\[ScriptF]\[ScriptF]\[ScriptCapitalO]\[ScriptP][\[ScriptO]\[ScriptP]]]], Condition[\[ScriptCapitalR]\[ScriptCapitalB][List[\[ScriptL], \[ScriptO]\[ScriptP], \[ScriptW], \[ScriptCapitalP]\[ScriptA]\[ScriptR]\[ScriptE]\[ScriptN][\[ScriptS]\[ScriptY]\[ScriptM]\[ScriptB], \[ScriptF]\[ScriptO]\[ScriptR]\[ScriptM], \[ScriptP]\[ScriptR]\[ScriptE]\[ScriptC]], \[ScriptR]]], True]]], RuleDelayed[\[ScriptCapitalR]\[ScriptCapitalB][List[Pattern[\[ScriptL], BlankNullSequence[]], \[ScriptCapitalB][Pattern[\[ScriptS]\[ScriptY]\[ScriptM]\[ScriptB], Blank[]]], PatternTest[Pattern[\[ScriptW], BlankNullSequence[]], \[ScriptCapitalW]\[ScriptH]\[ScriptCapitalQ]], PatternTest[Pattern[\[ScriptO]\[ScriptP], Blank[]], \[ScriptCapitalI]\[ScriptN]\[ScriptCapitalQ]], Pattern[\[ScriptR], BlankNullSequence[]]]], With[List[Set[\[ScriptP]\[ScriptR]\[ScriptE]\[ScriptC], \[ScriptCapitalE]\[ScriptF]\[ScriptF]\[ScriptCapitalO]\[ScriptP][\[ScriptO]\[ScriptP]]]], Condition[\[ScriptCapitalR]\[ScriptCapitalB][List[\[ScriptL], \[ScriptCapitalP]\[ScriptA]\[ScriptR]\[ScriptE]\[ScriptN][\[ScriptS]\[ScriptY]\[ScriptM]\[ScriptB], \[ScriptF]\[ScriptO]\[ScriptR]\[ScriptM], \[ScriptP]\[ScriptR]\[ScriptE]\[ScriptC]], \[ScriptW], \[ScriptO]\[ScriptP], \[ScriptR]]], True]]], RuleDelayed[\[ScriptCapitalR]\[ScriptCapitalB][List[Pattern[\[ScriptL], BlankNullSequence[]], PatternTest[Pattern[\[ScriptO]\[ScriptP], Blank[]], \[ScriptCapitalI]\[ScriptN]\[ScriptCapitalQ]], PatternTest[Pattern[\[ScriptW], BlankNullSequence[]], \[ScriptCapitalW]\[ScriptH]\[ScriptCapitalQ]], \[ScriptCapitalB][Pattern[\[ScriptS]\[ScriptY]\[ScriptM]\[ScriptB], Blank[]]], Pattern[\[ScriptR], BlankNullSequence[]]]], With[List[Set[\[ScriptP]\[ScriptR]\[ScriptE]\[ScriptC], \[ScriptCapitalE]\[ScriptF]\[ScriptF]\[ScriptCapitalO]\[ScriptP][\[ScriptO]\[ScriptP]]]], Condition[\[ScriptCapitalR]\[ScriptCapitalB][List[\[ScriptL], \[ScriptO]\[ScriptP], \[ScriptW], \[ScriptCapitalP]\[ScriptA]\[ScriptR]\[ScriptE]\[ScriptN][\[ScriptS]\[ScriptY]\[ScriptM]\[ScriptB], \[ScriptF]\[ScriptO]\[ScriptR]\[ScriptM], \[ScriptP]\[ScriptR]\[ScriptE]\[ScriptC]], \[ScriptR]]], True]]], RuleDelayed[\[ScriptCapitalR]\[ScriptCapitalB][List[Pattern[\[ScriptL], BlankNullSequence[]], \[ScriptCapitalB][Pattern[\[ScriptS]\[ScriptY]\[ScriptM]\[ScriptB], Blank[]]], PatternTest[Pattern[\[ScriptW], BlankNullSequence[]], \[ScriptCapitalW]\[ScriptH]\[ScriptCapitalQ]], PatternTest[Pattern[\[ScriptO]\[ScriptP], Blank[]], \[ScriptCapitalP]\[ScriptO]\[ScriptS]\[ScriptT]\[ScriptCapitalQ]], Pattern[\[ScriptR], BlankNullSequence[]]]], With[List[Set[\[ScriptP]\[ScriptR]\[ScriptE]\[ScriptC], \[ScriptCapitalE]\[ScriptF]\[ScriptF]\[ScriptCapitalO]\[ScriptP][\[ScriptO]\[ScriptP]]]], Condition[\[ScriptCapitalR]\[ScriptCapitalB][List[\[ScriptL], \[ScriptCapitalP]\[ScriptA]\[ScriptR]\[ScriptE]\[ScriptN][\[ScriptS]\[ScriptY]\[ScriptM]\[ScriptB], \[ScriptF]\[ScriptO]\[ScriptR]\[ScriptM], \[ScriptP]\[ScriptR]\[ScriptE]\[ScriptC]], \[ScriptW], \[ScriptO]\[ScriptP], \[ScriptR]]], True]]], RuleDelayed[\[ScriptCapitalR]\[ScriptCapitalB][List[PatternTest[Pattern[\[ScriptD]1, Blank[]], \[ScriptCapitalD]\[ScriptE]\[ScriptL]\[ScriptI]\[ScriptM]\[ScriptCapitalQ]], PatternTest[Pattern[\[ScriptW]3, BlankNullSequence[]], \[ScriptCapitalW]\[ScriptH]\[ScriptCapitalQ]], \[ScriptCapitalB][Pattern[\[ScriptS]\[ScriptY]\[ScriptM]\[ScriptB], Blank[]]], PatternTest[Pattern[\[ScriptW]4, BlankNullSequence[]], \[ScriptCapitalW]\[ScriptH]\[ScriptCapitalQ]], PatternTest[Pattern[\[ScriptD]2, Blank[]], \[ScriptCapitalD]\[ScriptE]\[ScriptL]\[ScriptI]\[ScriptM]\[ScriptCapitalQ]]]], \[ScriptCapitalR]\[ScriptCapitalB][List[\[ScriptD]1, \[ScriptW]3, MakeBoxes[\[ScriptS]\[ScriptY]\[ScriptM]\[ScriptB], \[ScriptF]\[ScriptO]\[ScriptR]\[ScriptM]], \[ScriptW]4, \[ScriptD]2]]], RuleDelayed[\[ScriptCapitalR]\[ScriptCapitalB][List[Pattern[\[ScriptL], BlankSequence[]], \[ScriptCapitalB][Pattern[\[ScriptS]\[ScriptY]\[ScriptM]\[ScriptB], Blank[]]], Pattern[\[ScriptR], BlankNullSequence[]]]], \[ScriptCapitalR]\[ScriptCapitalB][List[\[ScriptL], \[ScriptCapitalP]\[ScriptA]\[ScriptR]\[ScriptE]\[ScriptN][\[ScriptS]\[ScriptY]\[ScriptM]\[ScriptB], \[ScriptF]\[ScriptO]\[ScriptR]\[ScriptM], Times], \[ScriptR]]]], RuleDelayed[\[ScriptCapitalR]\[ScriptCapitalB][List[Pattern[\[ScriptL], BlankNullSequence[]], \[ScriptCapitalB][Pattern[\[ScriptS]\[ScriptY]\[ScriptM]\[ScriptB], Blank[]]], Pattern[\[ScriptR], BlankSequence[]]]], \[ScriptCapitalR]\[ScriptCapitalB][List[\[ScriptL], \[ScriptCapitalP]\[ScriptA]\[ScriptR]\[ScriptE]\[ScriptN][\[ScriptS]\[ScriptY]\[ScriptM]\[ScriptB], \[ScriptF]\[ScriptO]\[ScriptR]\[ScriptM], Times], \[ScriptR]]]], RuleDelayed[\[ScriptCapitalB][Pattern[\[ScriptS]\[ScriptY]\[ScriptM]\[ScriptB], Blank[]]], MakeBoxes[\[ScriptS]\[ScriptY]\[ScriptM]\[ScriptB], \[ScriptF]\[ScriptO]\[ScriptR]\[ScriptM]]], RuleDelayed[\[ScriptCapitalR]\[ScriptCapitalB][List[Pattern[\[ScriptL], BlankNullSequence[]], PatternTest[Pattern[\[ScriptD], Blank[]], \[ScriptCapitalC]\[ScriptO]\[ScriptM]\[ScriptM]\[ScriptA]\[ScriptCapitalQ]], PatternTest[Pattern[\[ScriptW], BlankNullSequence[]], \[ScriptCapitalW]\[ScriptH]\[ScriptCapitalQ]], \[ScriptCapitalB]\[ScriptCapitalB][Pattern[\[ScriptS]\[ScriptY]\[ScriptM]\[ScriptB], Blank[]]], Pattern[\[ScriptR], BlankNullSequence[]]]], \[ScriptCapitalR]\[ScriptCapitalB][List[\[ScriptL], \[ScriptD], \[ScriptW], makeHeldSequenceOfBoxes[List[\[ScriptS]\[ScriptY]\[ScriptM]\[ScriptB]], \[ScriptF]\[ScriptO]\[ScriptR]\[ScriptM], None], \[ScriptR]]]], RuleDelayed[\[ScriptCapitalR]\[ScriptCapitalB][List[Pattern[\[ScriptL], BlankNullSequence[]], \[ScriptCapitalB]\[ScriptCapitalB][Pattern[\[ScriptS]\[ScriptY]\[ScriptM]\[ScriptB], Blank[]]], PatternTest[Pattern[\[ScriptW], BlankNullSequence[]], \[ScriptCapitalW]\[ScriptH]\[ScriptCapitalQ]], PatternTest[Pattern[\[ScriptD], Blank[]], \[ScriptCapitalC]\[ScriptO]\[ScriptM]\[ScriptM]\[ScriptA]\[ScriptCapitalQ]], Pattern[\[ScriptR], BlankNullSequence[]]]], \[ScriptCapitalR]\[ScriptCapitalB][List[\[ScriptL], makeHeldSequenceOfBoxes[List[\[ScriptS]\[ScriptY]\[ScriptM]\[ScriptB]], \[ScriptF]\[ScriptO]\[ScriptR]\[ScriptM], None], \[ScriptW], \[ScriptD], \[ScriptR]]]], RuleDelayed[\[ScriptCapitalR]\[ScriptCapitalB][List[Pattern[\[ScriptL], BlankNullSequence[]], PatternTest[Pattern[\[ScriptD], Blank[]], \[ScriptCapitalD]\[ScriptE]\[ScriptL]\[ScriptI]\[ScriptM]\[ScriptCapitalQ]], PatternTest[Pattern[\[ScriptW], BlankNullSequence[]], \[ScriptCapitalW]\[ScriptH]\[ScriptCapitalQ]], \[ScriptCapitalB]\[ScriptCapitalB][Pattern[\[ScriptS]\[ScriptY]\[ScriptM]\[ScriptB], Blank[]]], Pattern[\[ScriptR], BlankNullSequence[]]]], \[ScriptCapitalR]\[ScriptCapitalB][List[\[ScriptL], \[ScriptD], \[ScriptW], makeHeldRowBoxOfBoxes[List[\[ScriptS]\[ScriptY]\[ScriptM]\[ScriptB]], \[ScriptF]\[ScriptO]\[ScriptR]\[ScriptM], None], \[ScriptR]]]], RuleDelayed[\[ScriptCapitalR]\[ScriptCapitalB][List[Pattern[\[ScriptL], BlankNullSequence[]], \[ScriptCapitalB]\[ScriptCapitalB][Pattern[\[ScriptS]\[ScriptY]\[ScriptM]\[ScriptB], Blank[]]], PatternTest[Pattern[\[ScriptW], BlankNullSequence[]], \[ScriptCapitalW]\[ScriptH]\[ScriptCapitalQ]], PatternTest[Pattern[\[ScriptD], Blank[]], \[ScriptCapitalD]\[ScriptE]\[ScriptL]\[ScriptI]\[ScriptM]\[ScriptCapitalQ]], Pattern[\[ScriptR], BlankNullSequence[]]]], \[ScriptCapitalR]\[ScriptCapitalB][List[\[ScriptL], makeHeldRowBoxOfBoxes[List[\[ScriptS]\[ScriptY]\[ScriptM]\[ScriptB]], \[ScriptF]\[ScriptO]\[ScriptR]\[ScriptM], None], \[ScriptW], \[ScriptD], \[ScriptR]]]], RuleDelayed[\[ScriptCapitalB]\[ScriptCapitalB][Pattern[\[ScriptS]\[ScriptY]\[ScriptM]\[ScriptB], Blank[]]], makeHeldRowBoxOfBoxes[List[\[ScriptS]\[ScriptY]\[ScriptM]\[ScriptB]], \[ScriptF]\[ScriptO]\[ScriptR]\[ScriptM], None]], RuleDelayed[\[ScriptCapitalR]\[ScriptCapitalB][List[Pattern[\[ScriptL], BlankNullSequence[]], PatternTest[Pattern[\[ScriptD], Blank[]], \[ScriptCapitalC]\[ScriptO]\[ScriptM]\[ScriptM]\[ScriptA]\[ScriptCapitalQ]], PatternTest[Pattern[\[ScriptW], BlankNullSequence[]], \[ScriptCapitalW]\[ScriptH]\[ScriptCapitalQ]], \[ScriptCapitalC]\[ScriptCapitalP][Pattern[\[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR], Blank[]]], Pattern[\[ScriptR], BlankNullSequence[]]]], \[ScriptCapitalR]\[ScriptCapitalB][List[\[ScriptL], \[ScriptD], \[ScriptW], makeEvaluatedSequenceOfBoxes[List[\[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR]], \[ScriptF]\[ScriptO]\[ScriptR]\[ScriptM], None], \[ScriptR]]]], RuleDelayed[\[ScriptCapitalR]\[ScriptCapitalB][List[Pattern[\[ScriptL], BlankNullSequence[]], \[ScriptCapitalC]\[ScriptCapitalP][Pattern[\[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR], Blank[]]], PatternTest[Pattern[\[ScriptW], BlankNullSequence[]], \[ScriptCapitalW]\[ScriptH]\[ScriptCapitalQ]], PatternTest[Pattern[\[ScriptD], Blank[]], \[ScriptCapitalC]\[ScriptO]\[ScriptM]\[ScriptM]\[ScriptA]\[ScriptCapitalQ]], Pattern[\[ScriptR], BlankNullSequence[]]]], \[ScriptCapitalR]\[ScriptCapitalB][List[\[ScriptL], makeEvaluatedSequenceOfBoxes[List[\[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR]], \[ScriptF]\[ScriptO]\[ScriptR]\[ScriptM], None], \[ScriptW], \[ScriptD], \[ScriptR]]]], RuleDelayed[\[ScriptCapitalR]\[ScriptCapitalB][List[Pattern[\[ScriptL], BlankNullSequence[]], PatternTest[Pattern[\[ScriptD], Blank[]], \[ScriptCapitalD]\[ScriptE]\[ScriptL]\[ScriptI]\[ScriptM]\[ScriptCapitalQ]], PatternTest[Pattern[\[ScriptW], BlankNullSequence[]], \[ScriptCapitalW]\[ScriptH]\[ScriptCapitalQ]], \[ScriptCapitalC]\[ScriptCapitalP][Pattern[\[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR], Blank[]]], Pattern[\[ScriptR], BlankNullSequence[]]]], \[ScriptCapitalR]\[ScriptCapitalB][List[\[ScriptL], \[ScriptD], \[ScriptW], makeEvaluatedRowBoxOfBoxes[List[\[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR]], \[ScriptF]\[ScriptO]\[ScriptR]\[ScriptM], None], \[ScriptR]]]], RuleDelayed[\[ScriptCapitalR]\[ScriptCapitalB][List[Pattern[\[ScriptL], BlankNullSequence[]], \[ScriptCapitalC]\[ScriptCapitalP][Pattern[\[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR], Blank[]]], PatternTest[Pattern[\[ScriptW], BlankNullSequence[]], \[ScriptCapitalW]\[ScriptH]\[ScriptCapitalQ]], PatternTest[Pattern[\[ScriptD], Blank[]], \[ScriptCapitalD]\[ScriptE]\[ScriptL]\[ScriptI]\[ScriptM]\[ScriptCapitalQ]], Pattern[\[ScriptR], BlankNullSequence[]]]], \[ScriptCapitalR]\[ScriptCapitalB][List[\[ScriptL], makeEvaluatedRowBoxOfBoxes[List[\[ScriptE]\[ScriptX]\[ScriptP]\[ScriptR]], \[ScriptF]\[ScriptO]\[ScriptR]\[ScriptM], None], \[ScriptW], \[ScriptD], \[ScriptR]]]], RuleDelayed[\[ScriptCapitalC]\[ScriptCapitalP][Pattern[\[ScriptP]\[ScriptA]\[ScriptT]\[ScriptT], Blank[]]], makeEvaluatedRowBoxOfBoxes[List[\[ScriptP]\[ScriptA]\[ScriptT]\[ScriptT]], \[ScriptF]\[ScriptO]\[ScriptR]\[ScriptM], None]]]]]]]]

\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]:convertExternalBoxesForInternalToExternal[_, ___, (\[ScriptN]\[ScriptO]\[ScriptT]\[ScriptCapitalO]\[ScriptP]\[ScriptT]\[ScriptI]\[ScriptO]\[ScriptN]_)?(isNot[_?OptionQ]), ___] := $Failed /; Message[convertExternalBoxesForInternalToExternal::nonopt, HoldForm[\[ScriptN]\[ScriptO]\[ScriptT]\[ScriptCapitalO]\[ScriptP]\[ScriptT]\[ScriptI]\[ScriptO]\[ScriptN]], 1, HoldForm[\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]]]

SetDelayed[createInternalToExternalRule[Pattern[\[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], Blank[]], Pattern[\[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], Blank[]], Pattern[\[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS], BlankNullSequence[]]], With[List[Set[\[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL], convertExternalBoxesForInternalToExternal[\[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], \[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS]]], Set[\[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL], convertInternalBoxesForInternalToExternal[\[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], \[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS]]], Set[\[ScriptCapitalW]\[ScriptO]\[ScriptR]\[ScriptK]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM], ReplaceAll[ReplaceAll[WorkingForm, List[\[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS]]], adjustedOptions[Notation]]], Set[\[ScriptCapitalA]\[ScriptC]\[ScriptT]\[ScriptI]\[ScriptO]\[ScriptN], ReplaceAll[ReplaceAll[Action, List[\[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS]]], adjustedOptions[Notation]]]], CompoundExpression[executeInternalToExternalAction[\[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL], \[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL], \[ScriptCapitalW]\[ScriptO]\[ScriptR]\[ScriptK]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM], \[ScriptCapitalA]\[ScriptC]\[ScriptT]\[ScriptI]\[ScriptO]\[ScriptN]], Null]]]

executeInternalToExternalAction[\[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]_, \[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]_, \[ScriptCapitalW]\[ScriptO]\[ScriptR]\[ScriptK]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM]_, CreateNotationRules] := releaseMyHold[\[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL] := \[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]]
executeInternalToExternalAction[\[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]_, \[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]_, \[ScriptCapitalW]\[ScriptO]\[ScriptR]\[ScriptK]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM]_, RemoveNotationRules] := releaseMyHold[silentEvaluate[\[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL] =. ]]
executeInternalToExternalAction[\[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]_, \[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]_, \[ScriptCapitalW]\[ScriptO]\[ScriptR]\[ScriptK]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM]_, PrintNotationRules] := releaseMyHold[CellPrint[Cell[BoxData[MakeBoxes[\[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL] := \[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL], StandardForm]], "Output", ShowStringCharacters -> True]]]

convertInternalPatternsForExternalToInternal[\[ScriptP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]_, (\[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS]___)?OptionQ] := convertPatterns[flattenAllMyHold[boxedStringPatternsToPatterns[\[ScriptP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], \[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS]]]] //. {singleBlank[\[ScriptA]_] -> \[ScriptA], doubleBlank[\[ScriptA]_] :> stripSpuriousRowBox[\[ScriptA]], tripleBlank[\[ScriptA]_] :> stripSpuriousRowBox[\[ScriptA]], complexPattern[\[ScriptA]_] :> stripSpuriousRowBox[\[ScriptA]]}

\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]:convertInternalPatternsForExternalToInternal[_, ___, (\[ScriptN]\[ScriptO]\[ScriptT]\[ScriptCapitalO]\[ScriptP]\[ScriptT]\[ScriptI]\[ScriptO]\[ScriptN]_)?(isNot[_?OptionQ]), ___] := $Failed /; Message[convertInternalPatternsForExternalToInternal::nonopt, HoldForm[\[ScriptN]\[ScriptO]\[ScriptT]\[ScriptCapitalO]\[ScriptP]\[ScriptT]\[ScriptI]\[ScriptO]\[ScriptN]], 1, HoldForm[\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]]]

stripSpuriousRowBox[RowBox[{\[ScriptA]\[ScriptR]\[ScriptG]\[ScriptS]___}]] /; MemberQ[{\[ScriptA]\[ScriptR]\[ScriptG]\[ScriptS]}, "," | "\[InvisibleComma]"] := \[ScriptA]\[ScriptR]\[ScriptG]\[ScriptS]
stripSpuriousRowBox[\[ScriptO]\[ScriptT]\[ScriptH]\[ScriptE]\[ScriptR]___] := \[ScriptO]\[ScriptT]\[ScriptH]\[ScriptE]\[ScriptR]

SetDelayed[convertInternalBoxesForExternalToInternal[Pattern[\[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], Blank[]], Pattern[\[ScriptH]\[ScriptE]\[ScriptA]\[ScriptD]\[ScriptCapitalI]\[ScriptS]\[ScriptCapitalR]\[ScriptO]\[ScriptW]\[ScriptCapitalB]\[ScriptO]\[ScriptX], Blank[]], PatternTest[Pattern[\[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS], BlankNullSequence[]], OptionQ]], With[List[Set[\[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL], convertInternalPatternsForExternalToInternal[cleanBoxes[\[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]], \[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS]]], Set[\[ScriptCapitalW]\[ScriptO]\[ScriptR]\[ScriptK]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM], ReplaceAll[ReplaceAll[WorkingForm, List[\[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS]]], adjustedOptions[Notation]]]], If[\[ScriptH]\[ScriptE]\[ScriptA]\[ScriptD]\[ScriptCapitalI]\[ScriptS]\[ScriptCapitalR]\[ScriptO]\[ScriptW]\[ScriptCapitalB]\[ScriptO]\[ScriptX], myHold[MakeExpression[RowBox[List[l, \[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL], r]], \[ScriptCapitalW]\[ScriptO]\[ScriptR]\[ScriptK]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM]]], myHold[MakeExpression[\[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL], \[ScriptCapitalW]\[ScriptO]\[ScriptR]\[ScriptK]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM]]]]]]

convertExternalPatternsForExternalToInternal[\[ScriptP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]_, (\[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS]___)?OptionQ] := boxedStringPatternsToPatterns[\[ScriptP]\[ScriptA]\[ScriptT]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], \[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS]]

\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]:convertExternalPatternsForExternalToInternal[_, ___, (\[ScriptN]\[ScriptO]\[ScriptT]\[ScriptCapitalO]\[ScriptP]\[ScriptT]\[ScriptI]\[ScriptO]\[ScriptN]_)?(isNot[_?OptionQ]), ___] := $Failed /; Message[convertExternalPatternsForExternalToInternal::nonopt, HoldForm[\[ScriptN]\[ScriptO]\[ScriptT]\[ScriptCapitalO]\[ScriptP]\[ScriptT]\[ScriptI]\[ScriptO]\[ScriptN]], 1, HoldForm[\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]]]

SetDelayed[convertExternalBoxesForExternalToInternal[Pattern[\[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], Blank[]], Pattern[\[ScriptH]\[ScriptE]\[ScriptA]\[ScriptD]\[ScriptCapitalI]\[ScriptS]\[ScriptCapitalR]\[ScriptO]\[ScriptW]\[ScriptCapitalB]\[ScriptO]\[ScriptX], Blank[]], PatternTest[Pattern[\[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS], BlankNullSequence[]], OptionQ]], With[List[Set[\[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL], convertExternalPatternsForExternalToInternal[cleanBoxes[\[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]], \[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS]]], Set[\[ScriptCapitalW]\[ScriptO]\[ScriptR]\[ScriptK]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM], ReplaceAll[ReplaceAll[WorkingForm, List[\[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS]]], adjustedOptions[Notation]]]], If[\[ScriptH]\[ScriptE]\[ScriptA]\[ScriptD]\[ScriptCapitalI]\[ScriptS]\[ScriptCapitalR]\[ScriptO]\[ScriptW]\[ScriptCapitalB]\[ScriptO]\[ScriptX], With[List[Set[\[ScriptN]\[ScriptE]\[ScriptW]\[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL], RowBox[List[Pattern[l, BlankNullSequence[]], Apply[Sequence, Apply[Sequence, \[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]]], Pattern[r, BlankNullSequence[]]]]]], myHold[NotationMakeExpression[\[ScriptN]\[ScriptE]\[ScriptW]\[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL], \[ScriptCapitalW]\[ScriptO]\[ScriptR]\[ScriptK]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM]]]], myHold[NotationMakeExpression[\[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL], \[ScriptCapitalW]\[ScriptO]\[ScriptR]\[ScriptK]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM]]]]]]

SetDelayed[createExternalToInternalRule[Pattern[\[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], Blank[]], Pattern[\[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], Blank[]], Pattern[\[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS], BlankNullSequence[]]], With[List[Set[\[ScriptH]\[ScriptE]\[ScriptA]\[ScriptD]\[ScriptCapitalI]\[ScriptS]\[ScriptCapitalR]\[ScriptO]\[ScriptW]\[ScriptCapitalB]\[ScriptO]\[ScriptX], SameQ[Head[convertExternalPatternsForExternalToInternal[cleanBoxes[\[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]]]], RowBox]]], With[List[Set[\[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL], convertInternalBoxesForExternalToInternal[\[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], \[ScriptH]\[ScriptE]\[ScriptA]\[ScriptD]\[ScriptCapitalI]\[ScriptS]\[ScriptCapitalR]\[ScriptO]\[ScriptW]\[ScriptCapitalB]\[ScriptO]\[ScriptX], \[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS]]], Set[\[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL], convertExternalBoxesForExternalToInternal[\[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]\[ScriptCapitalB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], \[ScriptH]\[ScriptE]\[ScriptA]\[ScriptD]\[ScriptCapitalI]\[ScriptS]\[ScriptCapitalR]\[ScriptO]\[ScriptW]\[ScriptCapitalB]\[ScriptO]\[ScriptX], \[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS]]], Set[\[ScriptCapitalW]\[ScriptO]\[ScriptR]\[ScriptK]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM], ReplaceAll[ReplaceAll[WorkingForm, List[\[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS]]], adjustedOptions[Notation]]], Set[\[ScriptCapitalA]\[ScriptC]\[ScriptT]\[ScriptI]\[ScriptO]\[ScriptN], ReplaceAll[ReplaceAll[Action, List[\[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS]]], adjustedOptions[Notation]]]], CompoundExpression[executeExternalToInternalAction[\[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL], \[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL], \[ScriptCapitalW]\[ScriptO]\[ScriptR]\[ScriptK]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM], \[ScriptCapitalA]\[ScriptC]\[ScriptT]\[ScriptI]\[ScriptO]\[ScriptN]], Null]]]]

executeExternalToInternalAction[\[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]_, \[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]_, \[ScriptCapitalW]\[ScriptO]\[ScriptR]\[ScriptK]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM]_, CreateNotationRules] := releaseMyHold[\[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL] := \[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]]

executeExternalToInternalAction[\[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]_, \[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]_, \[ScriptCapitalW]\[ScriptO]\[ScriptR]\[ScriptK]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM]_, RemoveNotationRules] := releaseMyHold[\[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL] =. ]

executeExternalToInternalAction[\[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]_, \[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL]_, \[ScriptCapitalW]\[ScriptO]\[ScriptR]\[ScriptK]\[ScriptI]\[ScriptN]\[ScriptG]\[ScriptCapitalF]\[ScriptO]\[ScriptR]\[ScriptM]_, PrintNotationRules] := releaseMyHold[CellPrint[Cell[BoxData[MakeBoxes[\[ScriptE]\[ScriptX]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL] := \[ScriptI]\[ScriptN]\[ScriptT]\[ScriptE]\[ScriptR]\[ScriptN]\[ScriptA]\[ScriptL], StandardForm]], "Output", ShowStringCharacters -> True]]]

If[$NewVersion, ClearNotations[] := (Clear[NotationMakeExpression, NotationMakeBoxes]; NotationMakeExpression[TagBox[\[ScriptB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]_, NotationBoxTag, \[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS]___], \[ScriptA]\[ScriptN]\[ScriptY]_] := HoldComplete[NotationBoxTag[\[ScriptB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]]]; NotationMakeBoxes[NotationBoxTag[\[ScriptA]\[ScriptN]\[ScriptY]__], \[ScriptF]\[ScriptO]\[ScriptR]\[ScriptM]_] := TagBox[\[ScriptA]\[ScriptN]\[ScriptY], NotationBoxTag, Rule[TagStyle, "NotationTemplateStyle"]]; NotationMakeBoxes[identityForm[\[ScriptA]\[ScriptN]\[ScriptY]___], \[ScriptF]\[ScriptO]\[ScriptR]\[ScriptM]_] := \[ScriptA]\[ScriptN]\[ScriptY]; ), ClearNotations[] := (Clear[NotationMakeExpression, NotationMakeBoxes]; NotationMakeExpression[TagBox[\[ScriptB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]_, NotationBoxTag, \[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS]___], \[ScriptA]\[ScriptN]\[ScriptY]_] := HoldComplete[NotationBoxTag[\[ScriptB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]]]; NotationMakeBoxes[NotationBoxTag[\[ScriptA]\[ScriptN]\[ScriptY]__], \[ScriptF]\[ScriptO]\[ScriptR]\[ScriptM]_] := TagBox[\[ScriptA]\[ScriptN]\[ScriptY], NotationBoxTag]; NotationMakeBoxes[identityForm[\[ScriptA]\[ScriptN]\[ScriptY]___], \[ScriptF]\[ScriptO]\[ScriptR]\[ScriptM]_] := \[ScriptA]\[ScriptN]\[ScriptY]; )]

\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]:ClearNotations[_] := $Failed /; Message[ClearNotations::argr, HoldForm[ClearNotations], 0]
\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]:ClearNotations[_, __] := $Failed /; Message[ClearNotations::argrx, HoldForm[ClearNotations], heldLength[\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]], 0]

UpdateNotebookStyles[] := UpdateNotebookStyles[SelectedNotebook[]]

UpdateNotebookStyles[\[ScriptN]\[ScriptO]\[ScriptT]\[ScriptE]\[ScriptB]\[ScriptO]\[ScriptO]\[ScriptK]_NotebookObject] := If[AddStylesToNotebook[notationPackageStyles, \[ScriptN]\[ScriptO]\[ScriptT]\[ScriptE]\[ScriptB]\[ScriptO]\[ScriptO]\[ScriptK]], SelectionMove[MessagesNotebook[], After, Notebook]; NotebookWrite[MessagesNotebook[], Cell[TextData[StyleBox["Adding the Notation styles to the current style sheet. You might want to execute the command UpdateNotationsInNotebook[] to update any legacy notations present in the current notebook.", "Message"]], "Output", CellLabel -> StringJoin["From In[", ToString[$Line], "]:="]]]; SetOptions[MessagesNotebook[], Visible -> True]; AddInputAlias[NotationBoxTag @@ {\(Notation[\(\*TagBox["\[Placeholder]", NotationBoxTag, Rule[TagStyle, "NotationTemplateStyle"]]\ \[DoubleLongLeftRightArrow]\ \*TagBox["\[Placeholder]", NotationBoxTag, Rule[TagStyle, "NotationTemplateStyle"]]\)]\)}, "notation"]; AddInputAlias[NotationBoxTag @@ {\(Notation[\(\*TagBox["\[Placeholder]", NotationBoxTag, Rule[TagStyle, "NotationTemplateStyle"]]\ \[DoubleLongRightArrow]\ \*TagBox["\[Placeholder]", NotationBoxTag, Rule[TagStyle, "NotationTemplateStyle"]]\)]\)}, "notation>"]; AddInputAlias[NotationBoxTag @@ {\(Notation[\(\*TagBox["\[Placeholder]", NotationBoxTag, Rule[TagStyle, "NotationTemplateStyle"]]\ \[DoubleLongLeftArrow]\ \*TagBox["\[Placeholder]", NotationBoxTag, Rule[TagStyle, "NotationTemplateStyle"]]\)]\)}, "notation<"]; AddInputAlias[NotationBoxTag @@ {\(Symbolize[\(\*TagBox["\[Placeholder]", NotationBoxTag, Rule[TagStyle, "NotationTemplateStyle"]]\)]\)}, "symb"]; AddInputAlias[NotationBoxTag @@ {\(InfixNotation[\(\*TagBox["\[Placeholder]", NotationBoxTag, Rule[TagStyle, "NotationTemplateStyle"]], \[Placeholder]\)]\)}, "infixnotation"]; AddInputAlias[NotationBoxTag @@ {\(AddInputAlias[\(\*TagBox["\[Placeholder]", NotationBoxTag, Rule[TagStyle, "NotationTemplateStyle"]], \[Placeholder]\)]\)}, "addia"]; AddInputAlias[NotationBoxTag @@ {TagBox["\[Placeholder]", NotationPatternTag, Rule[TagStyle, "NotationPatternWrapperStyle"]]}, "pattwraper"]; AddInputAlias[NotationBoxTag @@ {TagBox["\[Placeholder]", NotationMadeBoxesTag, Rule[TagStyle, "NotationMadeBoxesWrapperStyle"]]}, "madeboxeswraper"]; ]

\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]:UpdateNotebookStyles[(\[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalA]\[ScriptR]\[ScriptG]_)?(headIsNot[NotebookObject]), ___] := $Failed /; Message[UpdateNotebookStyles::badarg, NotebookObject, 1, HoldForm[\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]]]

\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]:UpdateNotebookStyles[_, __] := $Failed /; Message[UpdateNotebookStyles::argt, HoldForm[UpdateNotebookStyles], heldLength[\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]], 0, 1]

\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]:AddStylesToNotebook[(\[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalA]\[ScriptR]\[ScriptG]_)?(headIsNot[Cell]), ___] := $Failed /; Message[AddStylesToNotebook::badarg, Cell, 1, HoldForm[\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]]]

\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]:AddStylesToNotebook[_, (\[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalA]\[ScriptR]\[ScriptG]_)?(headIsNot[NotebookObject]), ___] := $Failed /; Message[AddStylesToNotebook::badarg, NotebookObject, 2, HoldForm[\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]]]

\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]:AddStylesToNotebook[_, _, (\[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalA]\[ScriptR]\[ScriptG]_)?(headIsNot[Notebook]), ___] := $Failed /; Message[AddStylesToNotebook::badarg, Notebook, 3, HoldForm[\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]]]

\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]:AddStylesToNotebook[___] := With[{\[ScriptN]\[ScriptU]\[ScriptM] = heldLength[\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]]}, $Failed /; Which[1 > \[ScriptN]\[ScriptU]\[ScriptM] || \[ScriptN]\[ScriptU]\[ScriptM] > 3, Message[AddStylesToNotebook::argb, HoldForm[AddStylesToNotebook], \[ScriptN]\[ScriptU]\[ScriptM], 1, 3], True, False]]

AddStylesToNotebook::usage = "AddStylesToNotebook[\[ScriptC]\[ScriptE]\[ScriptL]\[ScriptL]], adds the styles in the cell \[ScriptC]\[ScriptE]\[ScriptL]\[ScriptL] to the curret notebook. \[ScriptC]\[ScriptE]\[ScriptL]\[ScriptL] can consist of a single cell or a cellgroup of other cells. AddStylesToNotebook[\[ScriptC]\[ScriptE]\[ScriptL]\[ScriptL],\[ScriptN]\[ScriptO]\[ScriptT]\[ScriptE]\[ScriptB]\[ScriptO]\[ScriptO]\[ScriptK]] adds the styles to the notebook \[ScriptN]\[ScriptO]\[ScriptT]\[ScriptE]\[ScriptB]\[ScriptO]\[ScriptO]\[ScriptK]. This function is mainly intended as a utility for package desginers who use the Notation package."

AddStylesToNotebook[\[ScriptC]\[ScriptE]\[ScriptL]\[ScriptL]_Cell] := AddStylesToNotebook[\[ScriptC]\[ScriptE]\[ScriptL]\[ScriptL], SelectedNotebook[]]

AddStylesToNotebook[\[ScriptC]\[ScriptE]\[ScriptL]\[ScriptL]_Cell, \[ScriptN]\[ScriptO]\[ScriptT]\[ScriptE]\[ScriptB]\[ScriptO]\[ScriptO]\[ScriptK]_NotebookObject] := AddStylesToNotebook[\[ScriptC]\[ScriptE]\[ScriptL]\[ScriptL], \[ScriptN]\[ScriptO]\[ScriptT]\[ScriptE]\[ScriptB]\[ScriptO]\[ScriptO]\[ScriptK], getStyleSheet[\[ScriptN]\[ScriptO]\[ScriptT]\[ScriptE]\[ScriptB]\[ScriptO]\[ScriptO]\[ScriptK]]]

AddStylesToNotebook[\[ScriptC]\[ScriptE]\[ScriptL]\[ScriptL]_Cell, \[ScriptN]\[ScriptB]_NotebookObject, \[ScriptS]\[ScriptT]\[ScriptY]\[ScriptL]\[ScriptE]\[ScriptCapitalS]\[ScriptH]\[ScriptE]\[ScriptE]\[ScriptT]_Notebook] := If[Or @@ (FreeQ[{\[ScriptS]\[ScriptT]\[ScriptY]\[ScriptL]\[ScriptE]\[ScriptCapitalS]\[ScriptH]\[ScriptE]\[ScriptE]\[ScriptT]}, #1] & ) /@ Union[Cases[\[ScriptC]\[ScriptE]\[ScriptL]\[ScriptL], StyleData[_String], {0, Infinity}]], Module[{\[ScriptT]\[ScriptE]\[ScriptM]\[ScriptP]\[ScriptCapitalN]\[ScriptB]}, Begin["Global`"]; \[ScriptT]\[ScriptE]\[ScriptM]\[ScriptP]\[ScriptCapitalN]\[ScriptB] = NotebookCreate[Visible -> False]; NotebookPut[\[ScriptS]\[ScriptT]\[ScriptY]\[ScriptL]\[ScriptE]\[ScriptCapitalS]\[ScriptH]\[ScriptE]\[ScriptE]\[ScriptT], \[ScriptT]\[ScriptE]\[ScriptM]\[ScriptP]\[ScriptCapitalN]\[ScriptB]]; SelectionMove[\[ScriptT]\[ScriptE]\[ScriptM]\[ScriptP]\[ScriptCapitalN]\[ScriptB], After, Notebook]; NotebookWrite[\[ScriptT]\[ScriptE]\[ScriptM]\[ScriptP]\[ScriptCapitalN]\[ScriptB], \[ScriptC]\[ScriptE]\[ScriptL]\[ScriptL]]; SetOptions[\[ScriptN]\[ScriptB], StyleDefinitions -> NotebookGet[\[ScriptT]\[ScriptE]\[ScriptM]\[ScriptP]\[ScriptCapitalN]\[ScriptB]], Visible -> True]; NotebookClose[\[ScriptT]\[ScriptE]\[ScriptM]\[ScriptP]\[ScriptCapitalN]\[ScriptB]]; End[]; ]; True, False]

getStyleSheet[\[ScriptCapitalC]\[ScriptU]\[ScriptR]\[ScriptR]\[ScriptE]\[ScriptN]\[ScriptT]\[ScriptCapitalN]\[ScriptB]_NotebookObject] := getStyleSheetAux[SilentCheck[StyleDefinitions /. AbsoluteOptions[\[ScriptCapitalC]\[ScriptU]\[ScriptR]\[ScriptR]\[ScriptE]\[ScriptN]\[ScriptT]\[ScriptCapitalN]\[ScriptB], StyleDefinitions], "Default.nb"]]

getStyleSheetAux[$Failed] := getStyleSheetAux["Default.nb"]
getStyleSheetAux[Notebook[\[ScriptS]\[ScriptT]\[ScriptY]\[ScriptL]\[ScriptE]\[ScriptCapitalS]\[ScriptH]\[ScriptE]\[ScriptE]\[ScriptT]_List, (\[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS]___)?OptionQ]] := Notebook[\[ScriptS]\[ScriptT]\[ScriptY]\[ScriptL]\[ScriptE]\[ScriptCapitalS]\[ScriptH]\[ScriptE]\[ScriptE]\[ScriptT], Visible -> False, \[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS]]
getStyleSheetAux[\[ScriptS]\[ScriptT]\[ScriptY]\[ScriptL]\[ScriptE]\[ScriptCapitalN]\[ScriptA]\[ScriptM]\[ScriptE]_String] := Block[{result}, Begin["Global`"]; result = Get[FileNames[\[ScriptS]\[ScriptT]\[ScriptY]\[ScriptL]\[ScriptE]\[ScriptCapitalN]\[ScriptA]\[ScriptM]\[ScriptE], StyleSheetPath /. AbsoluteOptions[$FrontEnd, StyleSheetPath] /. FrontEnd`FileName[{___, Verbatim[_], ___}, _] :> Sequence @@ {} /. FrontEnd`FileName[\[ScriptP]\[ScriptA]\[ScriptT]\[ScriptH]_List, _] :> ToFileName[\[ScriptP]\[ScriptA]\[ScriptT]\[ScriptH]]][[1]]]; End[]; getStyleSheetAux[result]]

\[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalU]\[ScriptP]\[ScriptD]\[ScriptA]\[ScriptT]\[ScriptE]\[ScriptCapitalN]\[ScriptO]\[ScriptT]\[ScriptA]\[ScriptT]\[ScriptI]\[ScriptO]\[ScriptN]\[ScriptS]:UpdateNotationsInNotebook[\[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalN]\[ScriptO]\[ScriptT]\[ScriptE]\[ScriptB]\[ScriptO]\[ScriptO]\[ScriptK]_, ___] := (Message[UpdateNotationsInNotebook::badNotebook, HoldForm[\[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalN]\[ScriptO]\[ScriptT]\[ScriptE]\[ScriptB]\[ScriptO]\[ScriptO]\[ScriptK]], HoldForm[\[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalU]\[ScriptP]\[ScriptD]\[ScriptA]\[ScriptT]\[ScriptE]\[ScriptCapitalN]\[ScriptO]\[ScriptT]\[ScriptA]\[ScriptT]\[ScriptI]\[ScriptO]\[ScriptN]\[ScriptS]]]; $Failed) /; Head[\[ScriptB]\[ScriptA]\[ScriptD]\[ScriptCapitalN]\[ScriptO]\[ScriptT]\[ScriptE]\[ScriptB]\[ScriptO]\[ScriptO]\[ScriptK]] =!= NotebookObject

UpdateNotationsInNotebook::badNotebook = "The first argument of `2` is not a notebook object."

\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]:UpdateNotationsInNotebook[_, __] := $Failed /; Message[UpdateNotationsInNotebook::argt, HoldForm[UpdateNotationsInNotebook], heldLength[\[ScriptE]\[ScriptR]\[ScriptR]\[ScriptO]\[ScriptR]], 0, 1]

UpdateNotationsInNotebook[] := UpdateNotationsInNotebook[SelectedNotebook[]]

UpdateNotationsInNotebook[HoldPattern[\[ScriptN]\[ScriptB]_NotebookObject]] := If[$NewVersion &&  !FreeQ[NotebookGet[\[ScriptN]\[ScriptB]], TagBox[\[ScriptB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]_, NotationBoxTag, \[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS]___] /; FreeQ[{\[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS]}, TagStyle -> "NotationTemplateStyle"]], Module[{\[ScriptN]\[ScriptE]\[ScriptW]\[ScriptCapitalN]\[ScriptB] = NotebookCreate[Visible -> False]}, SetOptions[\[ScriptN]\[ScriptE]\[ScriptW]\[ScriptCapitalN]\[ScriptB], Sequence @@ DeleteCases[AbsoluteOptions[\[ScriptN]\[ScriptB]], (ScreenRectangle -> _) | (WindowSize -> _) | (WindowMargins -> _) | (Visible -> _), 1]]; NotebookPut[massageNotebook[NotebookGet[\[ScriptN]\[ScriptB]]], \[ScriptN]\[ScriptE]\[ScriptW]\[ScriptCapitalN]\[ScriptB]]; SetOptions[\[ScriptN]\[ScriptE]\[ScriptW]\[ScriptCapitalN]\[ScriptB], Sequence @@ MapAt[StringJoin["Updated Notations - ", #1] & , AbsoluteOptions[\[ScriptN]\[ScriptB], WindowTitle], {1, 2}]]; SetOptions[\[ScriptN]\[ScriptE]\[ScriptW]\[ScriptCapitalN]\[ScriptB], Visible -> True]; SetSelectedNotebook[\[ScriptN]\[ScriptE]\[ScriptW]\[ScriptCapitalN]\[ScriptB]]; ]]

massageNotebook[\[ScriptN]\[ScriptO]\[ScriptT]\[ScriptE]\[ScriptB]\[ScriptO]\[ScriptO]\[ScriptK]_Notebook] := DeleteCases[\[ScriptN]\[ScriptO]\[ScriptT]\[ScriptE]\[ScriptB]\[ScriptO]\[ScriptO]\[ScriptK], (ScreenRectangle -> _) | (WindowSize -> _) | (WindowMargins -> _), 1] //. TagBox[\[ScriptB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS]_, NotationBoxTag, \[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS]___] /; FreeQ[{\[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS]}, TagStyle -> "NotationTemplateStyle"] :> TagBox[\[ScriptB]\[ScriptO]\[ScriptX]\[ScriptE]\[ScriptS], NotationBoxTag, Rule[TagStyle, "NotationTemplateStyle"], \[ScriptO]\[ScriptP]\[ScriptT]\[ScriptS]]

If[ !ValueQ[AutoLoadNotationPalette], AutoLoadNotationPalette = True]

If[ !ValueQ[AutoUpdateNotationStyleSheet], AutoUpdateNotationStyleSheet = True]

If[AutoLoadNotationPalette === True, Module[{\[ScriptN]\[ScriptB] = SelectedNotebook[], \[ScriptD]\[ScriptI]\[ScriptR] = {$TopDirectory, "AddOns", "ExtraPackages", "Utilities"}}, If[$Remote, NotebookPut[Get[ToFileName[\[ScriptD]\[ScriptI]\[ScriptR], "NotationPalette.nb"]]], NotebookOpen[ToFileName[\[ScriptD]\[ScriptI]\[ScriptR], "NotationPalette.nb"]]]; SetSelectedNotebook[\[ScriptN]\[ScriptB]]; ]]

notationPackageStyles := Cell[CellGroupData[{Cell["Notation Package Styles", "Section", GeneratedCell -> True, CellTags -> "NotationPackage"], Cell["The cells below define certain styles needed by the Notation package. These styles serve to make visible otherwise invisible tagboxes.", "Text", GeneratedCell -> True, CellTags -> "NotationPackage"], Cell[StyleData["NotationTemplateStyle"], GeneratedCell -> True, StyleMenuListing -> None, Background -> RGBColor[1, 1, 0.85], TagBoxOptions -> {SyntaxForm -> "symbol"}, CellTags -> "NotationPackage"], Cell[StyleData["NotationPatternWrapperStyle"], GeneratedCell -> True, StyleMenuListing -> None, Background -> RGBColor[1, 0.9, 0.98], TagBoxOptions -> {SyntaxForm -> "symbol"}, CellTags -> "NotationPackage"], Cell[StyleData["NotationMadeBoxesWrapperStyle"], GeneratedCell -> True, StyleMenuListing -> None, Background -> RGBColor[0.9, 0.89, 1], TagBoxOptions -> {SyntaxForm -> "symbol"}, CellTags -> "NotationPackage"]}, Closed]]

If[$NewVersion && AutoUpdateNotationStyleSheet, UpdateNotebookStyles[SelectedNotebook[]]; ]

End[]

SetAttributes[List[ClearNotations, InfixNotation, Notation, NotationBoxTag, RemoveInfixNotation, RemoveNotation, RemoveSymbolize, Symbolize, AddInputAlias, ActiveInputAliases, UpdateNotationsInNotebook], List[ReadProtected, Protected]]

SetAttributes[{Action, CreateNotationRules, NotationBoxTag, NotationPatternTag, NotationMadeBoxesTag, PrintNotationRules, RemoveNotationRules, SymbolizeRootName, WorkingForm}, {Protected}]

EndPackage[]

