-
-#
-# Reverse Rules
-#
-$EndGorp = ($Term | $ATerm | $Sep | $Close | $Extend | $Format | $Sp);
-$RevEndSequence = $EndGorp* $InteriorChars* $EndGorp* | $Sep [^$ATerm $Term]*;
-$ReverseLowerWordFollows = $Lower [^$OLetter $Upper $Lower $Sep]* $ATerm $InteriorChars*;
-$ReverseUpperSurround = $Upper $Format* $Extend* $ATerm $Format* $Extend* $Upper $InteriorChars*;
-$ReverseNumberFollows = $Numeric $Format* $Extend* $ATerm $InteriorChars*;
-
-! $RevEndSequence ($ReverseLowerWordFollows | $ReverseUpperSurround | $ReverseNumberFollows)* .?;
-#! .*;
-
+# rule 6
+
+$RULE6 = $Numeric $Format* $Extend* $ATerm;
+
+# rule 7
+
+$RULE7 = $Upper $Format* $Extend* $ATerm $Format* $Extend* $Upper;
+
+# rule 8
+
+$RULE8 = $Lower ($Format* $Extend* [^$OLetter $Upper $Lower $Sep])*
+ ($Format* $Extend* $Sp)* ($Format* $Extend* $Close)*
+ $Format* $Extend* $ATerm;
+
+# rule 9, 10, 11
+
+# $CR $LF
+$End = $Sep | \u000a\u000d
+ | $Format* $Extend* $Sp* $Format* $Extend* $Close* $Format*
+ $Extend* ($Term | $ATerm)
+ | $Sep $Format* $Extend* $Sp* $Format* $Extend* $Close* $Format*
+ $Extend* ($Term | $ATerm);
+
+# rule 12
+
+$RULE12 = [^$Sep $Term $ATerm];
+
+$Join = ($RULE6 | $RULE7 | $RULE8 | $RULE12)*;
+
+$End;
+
+$End? $Join [$RULE12 - $Sp - $Close];
+
+# forces a break at the beginning of text "$Sp blah blah blah"
+# remember the break iterators takes the longest match
+$End? $Join $Sp / [^$Term $ATerm $Sp $Close];
+
+# forces a break at the beginning of text "$Close blah blah blah"
+$End? $Join $Close / [^$Term $ATerm $Close];
+
+## -------------------------------------------------
+
+!!safe_reverse;
+
+# rule 4
+$Extend+ [^$Extend];
+
+# rule 7
+$Extend* $ATerm $Format* $Extend* $Upper;
+
+# rule 8
+($Extend* $Term)+ ($Extend* $Sp $Format*)* ($Extend* $Close $Format*)* $Extend* $ATerm;
+
+# rule 11
+($Extend* $Sp $Format*)* ($Extend* $Close $Format*)*;
+($Extend* $Sp $Format*)* ($Extend* $Close $Format*)* $Extend* ($Term | $ATerm);
+
+## -------------------------------------------------
+
+!!safe_forward;
+
+# rule 7
+
+$ATerm $Extend* $Format* $Upper;
+
+# rule 8
+
+$Lower .;
+
+# rule 11
+
+($Close $Extend* $Format*)* ($Sp $Extend* $Format*)*;