# - - - S p T a i l . _ _ c h e c k D i s a m b
def __checkDisamb ( self, scan ):
'''Validate and store the disambiguation, if any.
[ scan is a Scan instance ->
if scan is at end of line ->
self.disamb := None
else if the balance of the line in scan is a SLASH_RE
followed by a code matching abbrMod.RE_ABBR ->
scan := scan advanced to end of line
self.disamb := that code, stripped and uppercased
else ->
scan := scan advanced not past end of line
Log() +:= error message
raise SyntaxError ]
'''
First, eliminate the case where the line is empty.
#-- 1 --
# [ if scan is at end of line ->
# self.disamb := None
# return
# else -> I ]
if scan.atEndLine():
self.disamb = None
return
For the regular expression that matches a slash (and any
leading and following whitespace), see Section 6.24, “SLASH_RE”.
#-- 2 --
# [ if scan starts with a string matching SLASH_RE ->
# scan := scan advanced past that match
# else ->
# Log() +:= error message(s)
# raise SyntaxError ]
m = scan.tabReMatch ( SLASH_RE )
if m is None:
scan.syntax ( "Expecting a '/' followed by the "
"disambiguated code." )
The regular expression that matches a bird code is abbrMod.RE_ABBR, documented in the specification for the abbr.py module.
#-- 3 --
# [ if the line in scan starts with a string matching
# abbrMod.RE_ABBR ->
# scan := scan advanced past that match
# self.disamb := matching string, stripped and
# uppercased
# else ->
# Log() +:= error message(s)
# raise SyntaxError ]
m = scan.tabReMatch ( abbrMod.RE_ABBR )
if m is None:
scan.syntax ( "Expecting the disambiguated bird code." )
else:
self.disamb = m.group().upper()
If there's anything left on the line, that's an error.
#-- 3 --
# [ if any nonblank characters remain on the line in scan ->
# scan := scan advanced to next nonblank character
# Log() +:= error message
# raise SyntaxError ]
# else ->
# scan := scan advanced to end of line ]
scan.deblankLine()
if not scan.atEndLine():
scan.syntax ( "Unrecognized characters at the end of "
"the line." )