[feaLib] Parse subtable
statements
This commit is contained in:
parent
e132741b2c
commit
f60d49471d
@ -65,6 +65,11 @@ class ScriptStatement(object):
|
||||
self.script = script
|
||||
|
||||
|
||||
class SubtableStatement(object):
|
||||
def __init__(self, location):
|
||||
self.location = location
|
||||
|
||||
|
||||
class SubstitutionRule(object):
|
||||
def __init__(self, location, old, new):
|
||||
self.location, self.old, self.new = (location, old, new)
|
||||
|
@ -232,6 +232,12 @@ class Parser(object):
|
||||
rule.lookups = lookups
|
||||
return rule
|
||||
|
||||
def parse_subtable_(self):
|
||||
assert self.is_cur_keyword_("subtable")
|
||||
location = self.cur_token_location_
|
||||
self.expect_symbol_(";")
|
||||
return ast.SubtableStatement(location)
|
||||
|
||||
def parse_valuerecord_(self, vertical):
|
||||
if self.next_token_type_ is Lexer.NUMBER:
|
||||
number, location = self.expect_number_(), self.cur_token_location_
|
||||
@ -308,6 +314,8 @@ class Parser(object):
|
||||
elif (self.is_cur_keyword_("substitute") or
|
||||
self.is_cur_keyword_("sub")):
|
||||
statements.append(self.parse_substitute_())
|
||||
elif self.is_cur_keyword_("subtable"):
|
||||
statements.append(self.parse_subtable_())
|
||||
elif self.is_cur_keyword_("valueRecordDef"):
|
||||
statements.append(self.parse_valuerecord_definition_(vertical))
|
||||
else:
|
||||
|
@ -299,6 +299,11 @@ class ParserTest(unittest.TestCase):
|
||||
ParserError, 'Expected "by" or explicit lookup references',
|
||||
self.parse, "feature liga {substitute f f i;} liga;")
|
||||
|
||||
def test_subtable(self):
|
||||
doc = self.parse("feature test {subtable;} test;")
|
||||
s = doc.statements[0].statements[0]
|
||||
self.assertEqual(type(s), ast.SubtableStatement)
|
||||
|
||||
def test_valuerecord_format_a_horizontal(self):
|
||||
doc = self.parse("feature liga {valueRecordDef 123 foo;} liga;")
|
||||
value = doc.statements[0].statements[0].value
|
||||
|
Loading…
x
Reference in New Issue
Block a user