[feaLib] Generalize FeatureNamesBlock
This commit is contained in:
parent
fd807bd70a
commit
a4c055c18a
@ -229,14 +229,15 @@ class FeatureBlock(Block):
|
||||
return res
|
||||
|
||||
|
||||
class FeatureNamesBlock(Block):
|
||||
def __init__(self, location=None):
|
||||
class NestedBlock(Block):
|
||||
def __init__(self, block_name, location=None):
|
||||
Block.__init__(self, location)
|
||||
self.block_name = block_name
|
||||
|
||||
def asFea(self, indent=""):
|
||||
res = indent + "featureNames {\n"
|
||||
res = "{}{} {{\n".format(indent, self.block_name)
|
||||
res += Block.asFea(self, indent=indent)
|
||||
res += indent + "};\n"
|
||||
res += "{}}};\n".format(indent)
|
||||
return res
|
||||
|
||||
|
||||
|
@ -1243,7 +1243,7 @@ class Parser(object):
|
||||
|
||||
def parse_featureNames_(self, tag):
|
||||
assert self.cur_token_ == "featureNames", self.cur_token_
|
||||
block = self.ast.FeatureNamesBlock(self.cur_token_location_)
|
||||
block = self.ast.NestedBlock(self.cur_token_location_, self.cur_token_)
|
||||
self.expect_symbol_("{")
|
||||
for symtab in self.symbol_tables_:
|
||||
symtab.enter_scope()
|
||||
|
@ -237,7 +237,7 @@ class ParserTest(unittest.TestCase):
|
||||
[feature] = self.parse(
|
||||
"feature ss01 { featureNames { # Comment\n }; } ss01;").statements
|
||||
[featureNames] = feature.statements
|
||||
self.assertIsInstance(featureNames, ast.FeatureNamesBlock)
|
||||
self.assertIsInstance(featureNames, ast.NestedBlock)
|
||||
[comment] = featureNames.statements
|
||||
self.assertIsInstance(comment, ast.Comment)
|
||||
self.assertEqual(comment.text, "# Comment")
|
||||
@ -246,7 +246,7 @@ class ParserTest(unittest.TestCase):
|
||||
[feature] = self.parse(
|
||||
"feature ss01 { featureNames { ;;; }; } ss01;").statements
|
||||
[featureNames] = feature.statements
|
||||
self.assertIsInstance(featureNames, ast.FeatureNamesBlock)
|
||||
self.assertIsInstance(featureNames, ast.NestedBlock)
|
||||
self.assertEqual(featureNames.statements, [])
|
||||
|
||||
def test_FontRevision(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user