#------------------------------
# How to write the sandhi rules
#------------------------------
# Lines beginning with a # or empty lines are skipped
# Each line should contain one rule
# (Can be written in devanagari easier to read/check for a human)
# Each rule is typically left_1 + left_2 = right_1 / right_2 / ...
# left_1 and left_2 can specify lists. These will be 
# expanded by the parser to generate a product of all possible combinations
# E.g. [अ, इ, उ, ऋ][ ङ्, ञ्, न्] + [अ, आ, इ, ई, उ, ऊ, ऋ, ॠ, ए, ऐ, ओ, औ]
# right uses Python's format string specification to refer to
# elements from the left expression. 
# Note that even a single character on the left is treated as a list, so be 
# careful with indexing in the right expression.
# E.g. एचोऽयवायावः / यान्तवान्तादेशः would be specified as 
#  ए + [आ, इ, ई, उ, ऊ, ऋ, ॠ, ऌ, ए, ऐ, ओ, औ] = अय्{1} (the ए would be considered as list 0)
# Multiple right expressions can be specified by separating them with "/"
# Spaces at the beginning and end of expressions are stripped,
# but if they appear inside an expression, they will be preserved
# E.g. the space in अ {1}  for एचोऽयवायावः + लोपः शाकल्यस्य will be retained
# mAheswara-sutra pratyAhAras can be included in the rules by preceding them with a *
# To exclude certain varnas from a pratyAhAra, you can use set notation
# E.g. [*अच् - इई] 
# Note that pratyAhAras with vowels will be expanded to include dIrghas as well

# Encoding the अच्-सन्धिः rules "as is" leads to a lot of false 
# splits with two consecutive vowels at the start or end of a word. 
# As this should never happen in a proper split, we add a *हल् before
# and after the sandhi rule to prevent such incorrect splits
# While this is not strictly how the Panini sutras state the sandhis
# they are still followed in spirit, because two consecutive svaras
# at the beginning or end of a valid word would not happen with Panini
# rules

# यण्-सन्धिः
# इको यणचि (६.१.७७)
[*हल्][इ, ई] + [*अच् - इई][*हल्+ं] = {0}य्{2}{3}
[*हल्][उ, ऊ] + [*अच् - उऊ][*हल्+ं] = {0}व्{2}{3}
[*हल्][ऋ, ॠ] + [*अच् -ऋॠऌ][*हल्+ं] = {0}र्{2}{3}
[*हल्][ऌ]+ [*अच् -ऋॠऌ][*हल्+ं] = {0}ल्{2}{3}

# Do we want वान्तो यि प्रत्यये (६.१.७१) for गो + यम् = गव्यम्, नौ + यम् = नाव्यम् etc. ?
# No, because we will not split pratyayas

# यान्तवान्तादेशः
# एचोऽयवायावः  (६.१.७८) + लोपः शाकल्यस्य (८.३.१९)
[*हल्]ए + [*अच् - अ][*हल्+ं] = {0}अय्{2}{3} / {0}अ {2}{3} / {0}अ{2}{3}
[*हल्]ऐ + [*अच्][*हल्+ं] = {0}आय्{2}{3} / {0}आ {2}{3} / {0}आ{2}{3}
[*हल्]ओ + [*अच् - अ][*हल्+ं] = {0}अव्{2}{3} / {0}अ {2}{3} / {0}अ{2}{3}
[*हल्]औ + [*अच्][*हल्+ं] = {0}आव्{2}{3} / {0}आ {2}{3} / {0}आ{2}{3}

# गुण-सन्धिः
# आद्गुणः (६.१.८७)
[*हल्][अ, आ] + [इ, ई][*हल्+ं] = {0}ए{3}
[*हल्][अ, आ]+ [उ, ऊ][*हल्+ं] = {0}ओ{3}
[*हल्][अ, आ] + [ऋ, ॠ][*हल्+ं] = {0}अर्{3}
[*हल्][अ, आ] + [ऌ, ॡ][*हल्+ं] = {0}अल्{3}

# वृद्धि-सन्धिः
# वृद्धिरेचि (६.१.८८)
[*हल्][अ, आ] + [ए, ऐ][*हल्+ं] = {0}ऐ{3}
[*हल्][अ, आ]+ [ओ, औ][*हल्+ं] = {0}औ{3}

# वार्तिकम्
# अक्षादूहिन्याम् उपसंख्यानम्
अक्ष + ऊहिन् = अक्षौहिण्

# ऋते च त्रीतीयासमासे
अ + ऋत् = आर्त्

# सवर्णदीर्घः
# अकः सवर्णे दीर्घः
[*हल्][अ, आ] + [अ, आ][*हल्+ं] = {0}आ{3}
[*हल्][इ, ई] + [इ, ई][*हल्+ं] ={0}ई{3}
[*हल्][उ, ऊ] + [उ, ऊ][*हल्+ं] = {0}ऊ{3}
[*हल्][ऋ, ॠ, ऌ] + [ऋ, ॠ, ऌ][*हल्+ं] = {0}ॠ{3}

# पूर्वरूपः
# एङः पदान्तादति (६.१.१०१)
[*हल्][ए, ओ] + अ[*हल्+ं] = {0}{1}{3} / {0}{1}ऽ{3}

# प्रकृतिभावः
# ऋत्यकः (६.१.१२८)
# There is a space in the optional expression
[*हल्][अ, इ, उ, ऋ] + [ऋ][*हल्+ं] = {0}{1}{2}{3} / {0}{1} {2}{3}
[*हल्]आ + ऋ[*हल्+ं] = {0}अऋ{3} / {0}अ ऋ{3}
[*हल्]ई + ऋ[*हल्+ं] = {0}इऋ{3} / {0}इस् ऋ{3}
[*हल्]ऊ + ऋ[*हल्+ं] = {0}उऋ{3} / {0}उ ऋ{3}
