Unsorted parts
Each character in an LSD heading has a flag indicating whether it’s sorted or unsorted.
The unsorted characters are ignored during lookup. They are only used when displaying the heading to the user.
I will use s and u to indicate this distinction.
In the DSL format braces are used to indicate the sortedness of a heading part.
The DSL heading ‘Some{thing}’ can be represented in LSD as
Something
ssssuuuuu
For indexing purposes this heading’s name is ‘Some’, while its extended name is ‘Something’. There can be any number of unsorted characters in a heading.
A few examples
DSL | ab |
Some{thing} |
S{o}m{e}thin{g} |
ab\\c |
ab\\c |
LSD | ss |
ssss uuuuu |
s u s u ssss u |
ssuss |
ssuus |
Name | ab | Some | Smthin | ab\c | abc |
Extended name | ab | Something | Something | ab\c | ab\c |
A special case is the backslash (\
), that is always unsorted, but it is used to escape the subsequent character (either sorted or unsorted) and thus requires special handling.
Optional parts (variants)
A single DSL heading can be used as a template to produce multiple other (DSL) headings by using the variant encoding.
The DSL heading aa(bb)cc
will be expanded into two different headings
aa{(bb)}cc and aa{(}bb{)}cc
ss uuuu ss ss u ss u ss
Notice that in both cases the parentheses are unsorted.
Several such parts are allowed, producing 2^n headings as a result, where n is the number of variant parts.
There exists a rule that helps combine two headings that were produced using this feature. Here u(
and u)
denote unsorted parentheses.
(A) ??? u( u*n u) ??? -> ??? u( s|u*n u) ???
(B) ??? u( s|u*n u) ???
The optional part can also contain an unsorted part, so this rule allows for a
combination of sorted/unsorted parts inside an optional part (denoted as s|u*n
, meaning n characters with preserved sortedness).
The rule becomes insufficient in the presence of spaces adjacent to the parentheses. Here are two examples of such headings (the upper case is used to denote spaces):
abc (123)
abc{ (123)} and abc {(}123{)}
sss Uuuuuu sssS u sss u
bbb (123) z
bbb {(123) }z and bbb {(}123{)} z
sssS uuuuuU s sssS u sss u Ss
Two more rules account for these special cases.
(C) ??? Uu( u*n u) -> ??? Su( s|u*n u)
(D) ??? Su( s|u*n u)
(E) ??? Su( u*n u)U ??? -> ??? Su( s|u*n u)S ???
(F) ??? Su( s|u*n u)S ???
lsd2dsl applies the above rules to reverse the expansion of variant headings. This makes the resulting DSL dictionary look closer to the source DSL, from which the LSD was compiled.
If this behavior is inappropriate, the --dumb
switch of the console version disables the heading collapsing and preserves all LSD heading as is.