# - - - N o n S p T a i l . _ _ i n i t _ _
def __init__ ( self, scan ):
'''Scan the non-species tail.
'''
The non-species tail has only three parts: the scientific name; a slash; and the English name. Here are two examples:
-f Anatinae/Ducks t Tadornini/True Shelducks and Sheldgeese
The regular expression that matches the scientific name is
defined in Section 6.23, “HT_NAME_RE”.
#-- 1 --
# [ if the line in scan begins with a scientific name
# matching HT_NAME_RE ->
# scan := scan advanced past the matching part
# self.sci := the matching part
# else ->
# scan := scan advanced no further than end of line
# Log() +:= error message(s)
# raise SyntaxError ]
m = scan.tabReMatch ( HT_NAME_RE )
if m is None:
scan.syntax ( "Expecting a scientific name with the first "
"letter capitalized, the rest lowercase." )
else:
self.sci = m.group()
We'll skip whitespace before and after checking for the
separating slash, just to be forgiving. The pattern that
matches all that is defined in Section 6.24, “SLASH_RE”.
#-- 2 --
# [ if scan starts with zero or more whitespace characters,
# then a slash, then zero or more whitespace characters
# again ->
# scan := scan advanced past all that
# else ->
# scan := scan advanced no further than end of line
# Log() +:= error message(s)
# raise SyntaxError ]
m = scan.tabReMatch ( SLASH_RE )
if m is None:
scan.syntax ( "Expecting the '/' between the scientific "
"and English names." )
The English name is the balance of the line. The only check we do is that there must be at least two characters.
#-- 3 --
# [ if the line in scan has at least two characters ->
# scan := scan advanced to end of line
# self.eng := remainder of the line, stripped
# else ->
# scan := scan advanced no further than end of line
# Log() +:= error message(s)
# raise SyntaxError ]
self.eng = scan.tab(-1)
if len(self.eng) < 2:
scan.syntax ( "Expecting the English name." )