[feaLib] Recognize empty statements in all table blocks

Before this change, some table statements would allow empty statements
(just a semicolon) while others would not allow them. After this change,
we're more consistent.
This commit is contained in:
Sascha Brawer 2017-03-09 13:56:47 +01:00
parent 3caeb3dab0
commit 04b1e8ada6
2 changed files with 9 additions and 0 deletions

View File

@ -803,6 +803,8 @@ class Parser(object):
statements.append(self.parse_ligatureCaretByIndex_())
elif self.is_cur_keyword_("LigatureCaretByPos"):
statements.append(self.parse_ligatureCaretByPos_())
elif self.cur_token_ == ";":
continue
else:
raise FeatureLibError(
"Expected Attach, LigatureCaretByIndex, "
@ -817,6 +819,8 @@ class Parser(object):
statements.append(self.ast.Comment(self.cur_token_location_, self.cur_token_))
elif self.is_cur_keyword_("FontRevision"):
statements.append(self.parse_FontRevision_())
elif self.cur_token_ == ";":
continue
else:
raise FeatureLibError("Expected FontRevision",
self.cur_token_location_)
@ -873,6 +877,8 @@ class Parser(object):
statement = self.parse_nameid_()
if statement:
statements.append(statement)
elif self.cur_token_ == ";":
continue
else:
raise FeatureLibError("Expected nameid",
self.cur_token_location_)

View File

@ -1437,6 +1437,9 @@ class ParserTest(unittest.TestCase):
self.assertFalse(doc.statements[0].statements)
doc = self.parse(";;;")
self.assertFalse(doc.statements)
for table in "BASE GDEF OS/2 head hhea name vhea".split():
doc = self.parse("table %s { ;;; } %s;" % (table, table))
self.assertEqual(doc.statements[0].statements, [])
def parse(self, text, glyphMap=GLYPHMAP, comments=False):
featurefile = UnicodeIO(text)