c74773f5ec
X-SVN-Rev: 13488
222 lines
5.2 KiB
Plaintext
222 lines
5.2 KiB
Plaintext
# Copyright (c) 2002-2003 International Business Machines Corporation and
|
|
# others. All Rights Reserved.
|
|
#
|
|
# file: line.txt
|
|
#
|
|
# Line Breaking Rules
|
|
# Implement default line breaking as defined by Unicode TR 14.
|
|
#
|
|
|
|
|
|
#
|
|
# Character Classes defined by TR 14.
|
|
#
|
|
|
|
!!chain ;
|
|
!!LBCMNoChain;
|
|
|
|
$AI = [:LineBreak = Ambiguous:];
|
|
$AL = [:LineBreak = Alphabetic:];
|
|
$BA = [:LineBreak = Break_After:];
|
|
$BB = [:LineBreak = Break_Before:];
|
|
$BK = [:LineBreak = Mandatory_Break:];
|
|
$B2 = [:LineBreak = Break_Both:];
|
|
$CB = [:LineBreak = Contingent_Break:];
|
|
$CL = [:LineBreak = Close_Punctuation:];
|
|
$CM = [:LineBreak = Combining_Mark:];
|
|
$CR = [:LineBreak = Carriage_Return:];
|
|
$EX = [:LineBreak = Exclamation:];
|
|
$GL = [:LineBreak = Glue:];
|
|
$HY = [:LineBreak = Hyphen:];
|
|
$ID = [:LineBreak = Ideographic:];
|
|
$IN = [:LineBreak = Inseperable:];
|
|
$IS = [:LineBreak = Infix_Numeric:];
|
|
$LF = [:LineBreak = Line_Feed:];
|
|
$NL = [:LineBreak = Next_Line:];
|
|
$NS = [:LineBreak = Nonstarter:];
|
|
$NU = [:LineBreak = Numeric:];
|
|
$OP = [:LineBreak = Open_Punctuation:];
|
|
$PO = [:LineBreak = Postfix_Numeric:];
|
|
$PR = [:LineBreak = Prefix_Numeric:];
|
|
$QU = [:LineBreak = Quotation:];
|
|
$SA = [:LineBreak = Complex_Context:];
|
|
$SG = [:LineBreak = Surrogate:];
|
|
$SP = [:LineBreak = Space:];
|
|
$SY = [:LineBreak = Break_Symbols:];
|
|
$XX = [:LineBreak = Unknown:];
|
|
$ZW = [:LineBreak = ZWSpace:];
|
|
|
|
|
|
#
|
|
# Korean Syllable Definitions
|
|
#
|
|
$L = [:Hangul_Syllable_Type = L:];
|
|
$V = [:Hangul_Syllable_Type = V:];
|
|
$T = [:Hangul_Syllable_Type = T:];
|
|
|
|
$LV = [:Hangul_Syllable_Type = LV:];
|
|
$LVT = [:Hangul_Syllable_Type = LVT:];
|
|
|
|
$HangulSyllable = $L+ | ($L* ($LV? $V+ | $LV | $LVT) $T*) | $T+;
|
|
|
|
|
|
#
|
|
# Rule LB1. By default, treat AI (characters with ambiguous east Asian width),
|
|
# SA (South East Asian: Thai, Lao, Khmer)
|
|
# XX (Unknown, unassigned)
|
|
# as $AL (Alphabetic)
|
|
#
|
|
$ALPlus = $AL | $AI | $SA | $XX;
|
|
|
|
#
|
|
# Combining Marks. X $CM* behaves as if it were X. Rule LB6.
|
|
#
|
|
$ALcm = $ALPlus $CM*;
|
|
$BAcm = $BA $CM*;
|
|
$BBcm = $BB $CM*;
|
|
$B2cm = $B2 $CM*;
|
|
$CLcm = $CL $CM*;
|
|
$EXcm = $EX $CM*;
|
|
$GLcm = $GL $CM*;
|
|
$HYcm = $HY $CM*;
|
|
$IDcm = ($ID | $HangulSyllable) $CM*;
|
|
$INcm = $IN $CM*;
|
|
$IScm = $IS $CM*;
|
|
$NScm = $NS $CM*;
|
|
$NUcm = $NU $CM*;
|
|
$OPcm = $OP $CM*;
|
|
$POcm = $PO $CM*;
|
|
$PRcm = $PR $CM*;
|
|
$QUcm = $QU $CM*;
|
|
$SPcm = $SP $CM*;
|
|
$SYcm = $SY $CM*;
|
|
|
|
#
|
|
# Each class of character can stand by itself as an unbroken token, with trailing combining stuff
|
|
#
|
|
$ALPlus $CM+;
|
|
$BA $CM+;
|
|
$BB $CM+;
|
|
$B2 $CM+;
|
|
$CL $CM+;
|
|
$EX $CM+;
|
|
$GL $CM+;
|
|
$HY $CM+;
|
|
$ID $CM+;
|
|
$IN $CM+;
|
|
$IS $CM+;
|
|
$NS $CM+;
|
|
$NU $CM+;
|
|
$OP $CM+;
|
|
$PO $CM+;
|
|
$PR $CM+;
|
|
$QU $CM+;
|
|
$SP $CM+;
|
|
$SY $CM+;
|
|
|
|
|
|
#
|
|
# Rule LB 3
|
|
$LB3NonBreaks = [^$BK $CR $LF $NL];
|
|
$LB5NonBreaks = [[$LB3NonBreaks] - [$ZW]];
|
|
|
|
$LB3NonBreaks? ($BK | $CR | $LF | $NL){100};
|
|
$LB5NonBreaks $CM* ($BK | $CR | $LF | $NL){100};
|
|
$CR $LF {100};
|
|
|
|
# LB 4 x SP
|
|
# x ZW
|
|
$LB3NonBreaks [$SP $ZW];
|
|
$LB5NonBreaks $CM* [$SP $ZW];
|
|
|
|
# LB 5 Break after zero width space
|
|
|
|
|
|
# LB 7 Combining marks. TODO: get it right!
|
|
# $SP $CM needs to behave like $ID.
|
|
# X $CM needs to behave like X, where X is not $SP.
|
|
# $CM not covered by the above needs to behave like $AL
|
|
[$LB5NonBreaks] $CM+; # Stick together any combining sequences that don't match other rules.
|
|
|
|
# LB 8
|
|
[$LB5NonBreaks] $CM* $CL;
|
|
[$LB5NonBreaks] $CM* $EX;
|
|
[$LB5NonBreaks] $CM* $IS;
|
|
[$LB5NonBreaks] $CM* $SY;
|
|
|
|
# LB 9
|
|
$OPcm $SP* .?;
|
|
$OPcm $SP* [$LB5NonBreaks] $CM*;
|
|
|
|
# LB 10
|
|
$QUcm $SP* $OPcm;
|
|
|
|
# LB 11
|
|
$CLcm $SP* $NScm;
|
|
|
|
# LB 11a
|
|
($B2cm)+;
|
|
|
|
# LB 11b
|
|
$LB5NonBreaks $CM* $GLcm .?;
|
|
$LB5NonBreaks $CM* $GLcm [$LB5NonBreaks] $CM*;
|
|
$GLcm $LB3NonBreaks?;
|
|
$GLcm [$LB5NonBreaks] $CM*;
|
|
|
|
# LB 12
|
|
$LB12NonBreaks = [[$LB5NonBreaks] - [$SP]];
|
|
|
|
# LB 14
|
|
$LB12NonBreaks $CM* $QUcm+ .?;
|
|
$LB12NonBreaks $CM* $QUcm+ [$LB5NonBreaks] $CM*;
|
|
$SP $CM+ $QUcm+ .?; # LB7a SP CM+ behaves as ID
|
|
$SP $CM+ $QUcm+ [$LB5NonBreaks] $CM*;
|
|
|
|
$QUcm $LB3NonBreaks?;
|
|
$QUcm [$LB5NonBreaks] $CM*; # Don't let a combining mark go onto $CR, $BK, etc.
|
|
|
|
# LB 14a
|
|
$LB14NonBreaks = [[$LB12NonBreaks] - [$CB]];
|
|
$LB14CanBreakAfter = $LB14NonBreaks $CM* | $SP $CM+;
|
|
|
|
|
|
# LB 15
|
|
$LB14CanBreakAfter ($BAcm | $HYcm | $NScm);
|
|
$BBcm [^$CB];
|
|
$BBcm [^$CB $CR $LF $BK $NL $ZW] $CM*;
|
|
|
|
# LB 16
|
|
#($ALcm | $IDcm | $SP $CM+ | $INcm | $NUcm) $INcm;
|
|
$ALcm $INcm;
|
|
$CM+ $INcm; # by rule 7c, any otherwise unattached CM behaves as AL
|
|
$IDcm $INcm;
|
|
$SP $CM+ $INcm; # by rule 7a, $SP $CM behaves like ID
|
|
$INcm $INcm;
|
|
$NUcm $INcm;
|
|
|
|
|
|
# $LB 17
|
|
($IDcm | $SP $CM+) $POcm;
|
|
$ALcm+ $NUcm; # includes $LB19
|
|
$CM+ $NUcm; # Rule 7c
|
|
$NUcm $ALcm+;
|
|
|
|
|
|
|
|
# LB 18
|
|
$PRcm? ($OPcm | $HYcm)? $NUcm ($NUcm | $IScm)* $CLcm? $POcm?;
|
|
#$PRcm? ($OPcm | $HYcm)? $NUcm ($NUcm | $IScm)* $CLcm?;
|
|
|
|
# LB 19
|
|
$CM* $ALcm+; # The $CM* is from rule 7C, and unattached CM is treated as AL
|
|
|
|
#
|
|
# Reverse Rules.
|
|
# TODO: Something more efficient. These rules just back up to hard breaks
|
|
# Note that the initial .. is to back over both halves of a CR/LF sequence
|
|
# at the current position.
|
|
#
|
|
|
|
!. . [^$LF $CR $NL $BK]* [$BK $CR $LF $NL];
|
|
#!.*;
|