input: 1
;
output: 1
;
states:
NEWBOOK
;
aliases:
AST = 42
;
SPACE = 32
;
DAGESH = 46
;
LCONS = (65-90|97-122) % latin consonants
;
CONSONANT = (`('|`)'|`+'|`#'|`&'|`$'| % $
`B'|`G'|`D'|`H'|`W'|`Z'|`X'|`Y'|`K'|`L'|`M'|`N'|
`S'|`P'|`C'|`Q'|`R'|`T')
;
VOWEL = ( `A'|`F'|`I'|`E'|`"'|`O'|`U'|`.'|`:'|`-'|
`.'|`''|`*'|`]')
;
DIGIT = (`0'-`9')
;
PRINTABLE = ({CONSONANT}|{VOWEL}|{DIGIT})
;
BHS_ARG = (`q'|`a'|`y'|`m') % letters following the right
; % square bracket
expressions:
%% The limited markup in the BHS file always begins with a tilde.
`@'`c'`"'{LCONS}<1,>`"'`x'`"'`t'`"'=> "{\clearocplists\NewBook{"
<push: NEWBOOK>
;
<NEWBOOK>`@'`x' => "}}\NewChapter \NewVerse " <pop:>
;
`@' `x' => "\NewChapter \NewVerse "
;
`@' `y' => "\NewVerse "
;
%% We need to deal with ketiv (*) and qere (**) variants.
{AST}{AST} => "\qere*"
;
{AST} => "\ketiv "
;
%% BHS uses a lonely P and S to indicate a `new par' or large space in
%% the text.
`P' 32 `@' => "\NewParAfterVerse "
<= `@'
;
`S' 32 `@' => "\LargeHSpace "
<= `@'
;
%% cantorial trope.
%% Special cases first...
%%
%% For some reason, the telisha gedola sometimes precedes the initial
%% consonant of its word. Makor cannot handle this.
{SPACE}`1'`4' {CONSONANT} {DAGESH} =>
32
<= \4 `.' `1' `4'
;
{SPACE}`1'`4' {CONSONANT} =>
32
<= \4 `1' `4'
;
%% In BHS, the meteg follows a vowel. In Makor, it precedes the vowel.
%% So we need to bring BHS in line with Makor.
`F'`7'`5' => `|'`+'
;
`A'`7'`5' => `|'`a'
;
`I'`7'`5' => `|'`i'
;
`:'`7'`5' => `|'`:'
;
`E'`7'`5' => `|'`e'
;
34 `7'`5' => `|'`"'
;
`"'`7'`5' => `|'`"'
;
%% In BHS, the holamdot is considered a vowel belonging to the
%% preceding letter. Trope can therefore follow a holamdot. This is
%% not the case in Makor, where the holamdot---admittedly occupying a
%% funny position in a no-man's-land between vowelness and
%% consonantness---comes after all vowels, etc of the letter. The
%% following code helps bring BHS in line with Makor conventions.
`O'`0'`1' => `['`s'`e'`g'`o'`l'`]'
<= \1
;
`O'`0'`2' => `['`z'`a'`r'`q'`a'`]'
<= \1
;
`O'`0'`3' => `['`p'`a'`s'`h'`t'`a'`]'
<= \1
;
`O'`0'`5' => `|'`|'
<= \1
;
`O'`1'`0' => `['`y'`e'`t'`i'`v'`]'
<= \1
;
`O'`1'`3' => `['`t'`i'`p'`e'`h'`a'`]'
<= \1
;
`O'`1'`4' => `['`t'`e'`l'`i'`s'`h'`a'`g'`e'`d'`o'`l'`a'`]'
<= \1
;
`O'`2'`4' => `['`t'`e'`l'`i'`s'`h'`a'`q'`e'`t'`a'`n'`a'`]'
<= \1
;
`O'`4'`4' => `['`t'`e'`l'`i'`s'`h'`a'`g'`e'`d'`o'`l'`a'`]'
<= \1
;
`O'`6'`0' => `['`m'`a'`h'`a'`p'`a'`k'`h'`]'
<= \1
;
`O'`6'`1' => `['`g'`e'`r'`e'`s'`h'`]'
<= \1
;
`O'`6'`2' => `['`g'`e'`r'`s'`h'`a'`y'`i'`m'`]'
<= \1
;
`O'`6'`3' => `['`q'`a'`d'`m'`a'`]'
<= \1
;
`O'`6'`4' => `['`i'`l'`u'`y'`]'
<= \1
;
`O'`6'`5' => `['`s'`h'`a'`l'`s'`h'`e'`l'`e'`t'`]'
<= \1
;
`O'`8'`0' => `['`z'`a'`q'`e'`f'`q'`a'`t'`a'`n'`]'
<= \1
;
`O'`8'`1' => `['`r'`e'`v'`i'`a'`]'
<= \1
;
`O'`8'`2' => `['`z'`i'`n'`o'`r'`]'
<= \1
;
`O'`8'`3' => `['`p'`a'`z'`e'`r'`]'
<= \1
;
`O'`8'`4' => `['`q'`a'`r'`n'`e'`y'`p'`a'`r'`a'`]'
<= \1
;
`O'`8'`5' => `['`z'`a'`q'`e'`f'`g'`a'`d'`o'`l'`]'
<= \1
;
`O'`7'`0' => `['`m'`a'`h'`a'`p'`a'`k'`h'`]'
<= \1
;
`O'`7'`1' => `['`m'`e'`r'`k'`h'`a'`]'
<= \1
;
`O'`7'`2' => `['`m'`e'`r'`k'`h'`a'`k'`e'`f'`u'`l'`a'`]'
<= \1
;
`O'`7'`3' => `['`t'`i'`p'`e'`h'`a'`]'
<= \1
;
`O'`7'`4' => `['`m'`u'`n'`a'`h'`]'
<= \1
;
`O'`7'`5' => `|'
<= \1
;
`O'`9'`1' => `['`t'`e'`v'`i'`r'`]'
<= \1
;
`O'`9'`2' => `['`e'`t'`n'`a'`h'`t'`a'`]'
<= \1
;
`O'`9'`3' => `['`d'`e'`h'`i'`]'
<= \1
;
`O'`9'`4' => `['`d'`a'`r'`g'`a'`]'
<= \1
;
`O'`9'`5' => `|'
<= \1
;
%% Here are the straightforward trope conventions, now that the
%% special cases have been dealt with.
`3'`3' =>
;
`0'`1' => `['`s'`e'`g'`o'`l'`]'
;
`0'`2' => `['`z'`a'`r'`q'`a'`]'
;
`0'`3' => `['`p'`a'`s'`h'`t'`a'`]'
;
`0'`4' => `['`t'`e'`l'`i'`s'`h'`a'`q'`e'`t'`a'`n'`a'`]'
;
`0'`5' => 32 `|'`|'
;
`1'`0' => `['`y'`e'`t'`i'`v'`]'
;
`1'`3' => `['`t'`i'`p'`e'`h'`a'`]'
;
`1'`1' =>
;
`1'`4' => `['`t'`e'`l'`i'`s'`h'`a'`g'`e'`d'`o'`l'`a'`]'
;
`2'`4' => `['`t'`e'`l'`i'`s'`h'`a'`q'`e'`t'`a'`n'`a'`]'
;
`4'`4' => `['`t'`e'`l'`i'`s'`h'`a'`g'`e'`d'`o'`l'`a'`]'
;
`6'`0' => `['`m'`a'`h'`a'`p'`a'`k'`h'`]'
;
`6'`1' => `['`g'`e'`r'`e'`s'`h'`]'
;
`6'`2' => `['`g'`e'`r'`s'`h'`a'`y'`i'`m'`]'
;
`6'`3' => `['`q'`a'`d'`m'`a'`]'
;
`6'`4' => `['`i'`l'`u'`y'`]'
;
`6'`5' => `['`s'`h'`a'`l'`s'`h'`e'`l'`e'`t'`]'
;
`8'`0' => `['`z'`a'`q'`e'`f'`q'`a'`t'`a'`n'`]'
;
`8'`1' => `['`r'`e'`v'`i'`a'`]'
;
`8'`2' => `['`z'`i'`n'`o'`r'`]'
;
`8'`3' => `['`p'`a'`z'`e'`r'`]'
;
`8'`4' => `['`q'`a'`r'`n'`e'`y'`p'`a'`r'`a'`]'
;
`8'`5' => `['`z'`a'`q'`e'`f'`g'`a'`d'`o'`l'`]'
;
`7'`0' => `['`m'`a'`h'`a'`p'`a'`k'`h'`]'
;
`7'`1' => `['`m'`e'`r'`k'`h'`a'`]'
;
`7'`2' => `['`m'`e'`r'`k'`h'`a'`k'`e'`f'`u'`l'`a'`]'
;
`7'`3' => `['`t'`i'`p'`e'`h'`a'`]'
;
`7'`4' => `['`m'`u'`n'`a'`h'`]'
;
`7'`5' => `|'
;
`9'`1' => `['`t'`e'`v'`i'`r'`]'
;
`9'`2' => `['`e'`t'`n'`a'`h'`t'`a'`]'
;
`9'`3' => `['`d'`e'`h'`i'`]'
;
`9'`4' => `['`d'`a'`r'`g'`a'`]'
;
`9'`5' => `|'
;
%% BHS also uses an unattached right square bracket as an indicator
%% for miscellaneous items. Most of them get zero-ed out.
`]' `8' => 136 % reflected nun
;
`]' {DIGIT} =>
;
`]' {BHS_ARG} =>
;
`A'`9'`5' => `|'`"'
;
`E'`9'`5' => `|'`e'
;
`F'`9'`5' => `|'`+'
;
`I'`9'`5' => `|'`i'
;
`9'`5' => `|'
;
`0'`0' end: => `:' 32 32 %<push: ENDVERSE>
;
`0'`0'{SPACE}<0,9> => `:' 32 32 %<push: ENDVERSE>
;
`W'`.' => `o'`o'
;
`O'`W' => `O'
;
`:'`A' => `:'`a'
;
`:'`F' => `:'`+'
;
`:'`E' => `:'`e'
;
%% Dagesh forms...
`)'`.' => `^' 39 `^' 39 % alef;
;
`B'`.' => `b'
;
`G'`.' => `g'`g'
;
`D'`.' => `d'`d'
;
`H'`.' => `h'`h'
;
`W'`.' => `o'`o'
;
`Z'`.' => `z'`z'
;
`X'`.' => `c'`h'`*'
;
`+'`.' => `.' `t' `.' `t'
;
`Y'`.' => `y'`y'
;
`K'`.' => `k'
;
`L'`.' => `l'`l'
;
`M'`.' => `m'`m'
;
`N'`.' => `n'`n'
;
`S'`.' => `.'`s'`.'`s'
;
`('`.' => 96 96
;
`P'`.' => `p'
;
`C'`.' => `t'`s'`t'`s'
;
`Q'`.' => `q'`q'
;
`R'`.' => `r'`r'
;
`#'`.' => `s'`h'`s'`h'
;
`&'`.' => `^'`s'`h'`s'`h'
;
36 `.' => `s'`h'`s'`h'`^'
;
`T'`.' => `t'
;
%% Single char input for consonants.
`O' `)' => `o' `^' 39
;
`)' => `^' 39 % alef;
;
`B' => `v'
;
`G' => `g'
;
`D' => `d'
;
`H' => `h'
;
`W' => `w'
;
`Z' => `z'
;
`X' => `c'`h'
;
`+' => `.' `t'
;
`Y' => `y'
;
`K' => `k'`h'
;
`L' => `l'
;
`M' => `m'
;
`N' => `n'
;
`S' => `.'`s'
;
`(' => 96
;
`P' => `f'
;
`C' => `t'`s'
;
`Q' => `q'
;
`R' => `r'
;
`#' => `s'`h'
;
`&' => `^'`s'`h'
;
36 => `s'`h'`^'
;
`T' => `t'`h'
;
%% Vowels
`A' => `a'
;
`F' => `a'`u'
;
`I' => `i'
;
`E' => `e'
;
`"' => `e' `i'
;
`O' => `o'
;
`U' => `u'
;
`:' => `_' 39
;
`-' => `-'
;