[voltLib] parse REVERSAL for reverse chaining context singl substitution
This commit is contained in:
parent
319b4cc227
commit
b70ef7accd
@ -62,7 +62,7 @@ class FeatureDefinition(ast.Statement):
|
|||||||
|
|
||||||
class LookupDefinition(ast.Statement):
|
class LookupDefinition(ast.Statement):
|
||||||
def __init__(self, location, name, base, marks, process_marks, all_flag,
|
def __init__(self, location, name, base, marks, process_marks, all_flag,
|
||||||
direction, comments, context, sub, pos):
|
direction, reversal, comments, context, sub, pos):
|
||||||
ast.Statement.__init__(self, location)
|
ast.Statement.__init__(self, location)
|
||||||
self.name = name
|
self.name = name
|
||||||
self.base = base
|
self.base = base
|
||||||
@ -70,6 +70,7 @@ class LookupDefinition(ast.Statement):
|
|||||||
self.process_marks = process_marks
|
self.process_marks = process_marks
|
||||||
self.all = all_flag
|
self.all = all_flag
|
||||||
self.direction = direction
|
self.direction = direction
|
||||||
|
self.reversal = reversal
|
||||||
self.comments = comments
|
self.comments = comments
|
||||||
self.context = context
|
self.context = context
|
||||||
self.sub = sub
|
self.sub = sub
|
||||||
|
@ -177,6 +177,10 @@ class Parser(object):
|
|||||||
self.expect_keyword_("DIRECTION")
|
self.expect_keyword_("DIRECTION")
|
||||||
direction = self.expect_name_()
|
direction = self.expect_name_()
|
||||||
assert direction in ("LTR", "RTL")
|
assert direction in ("LTR", "RTL")
|
||||||
|
reversal = None
|
||||||
|
if self.next_token_ == "REVERSAL":
|
||||||
|
self.expect_keyword_("REVERSAL")
|
||||||
|
reversal = True
|
||||||
comments = None
|
comments = None
|
||||||
if self.next_token_ == "COMMENTS":
|
if self.next_token_ == "COMMENTS":
|
||||||
self.expect_keyword_("COMMENTS")
|
self.expect_keyword_("COMMENTS")
|
||||||
@ -193,7 +197,7 @@ class Parser(object):
|
|||||||
pos = self.parse_position_()
|
pos = self.parse_position_()
|
||||||
def_lookup = ast.LookupDefinition(
|
def_lookup = ast.LookupDefinition(
|
||||||
location, name, base, marks, process_marks, all_flag, direction,
|
location, name, base, marks, process_marks, all_flag, direction,
|
||||||
comments, context, sub, pos)
|
reversal, comments, context, sub, pos)
|
||||||
return def_lookup
|
return def_lookup
|
||||||
|
|
||||||
def parse_context_(self):
|
def parse_context_(self):
|
||||||
|
@ -429,6 +429,42 @@ class ParserTest(unittest.TestCase):
|
|||||||
(lookup.name, process_marks, all_marks),
|
(lookup.name, process_marks, all_marks),
|
||||||
("SomeSub", "SomeMarks", False))
|
("SomeSub", "SomeMarks", False))
|
||||||
|
|
||||||
|
def test_substitution_no_reversal(self):
|
||||||
|
[lookup] = self.parse(
|
||||||
|
'DEF_LOOKUP "Lookup" PROCESS_BASE PROCESS_MARKS ALL '
|
||||||
|
'DIRECTION LTR\n'
|
||||||
|
'IN_CONTEXT\n'
|
||||||
|
'RIGHT ENUM GLYPH "a" GLYPH "b" END_ENUM\n'
|
||||||
|
'END_CONTEXT\n'
|
||||||
|
'AS_SUBSTITUTION\n'
|
||||||
|
'SUB GLYPH "a"\n'
|
||||||
|
'WITH GLYPH "a.alt"\n'
|
||||||
|
'END_SUB\n'
|
||||||
|
'END_SUBSTITUTION'
|
||||||
|
).statements
|
||||||
|
self.assertEqual(
|
||||||
|
(lookup.name, lookup.reversal),
|
||||||
|
("Lookup", None)
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_substitution_reversal(self):
|
||||||
|
[lookup] = self.parse(
|
||||||
|
'DEF_LOOKUP "RevLookup" PROCESS_BASE PROCESS_MARKS ALL '
|
||||||
|
'DIRECTION LTR REVERSAL\n'
|
||||||
|
'IN_CONTEXT\n'
|
||||||
|
'RIGHT ENUM GLYPH "a" GLYPH "b" END_ENUM\n'
|
||||||
|
'END_CONTEXT\n'
|
||||||
|
'AS_SUBSTITUTION\n'
|
||||||
|
'SUB GROUP "DFLT_Num_standardFigures"\n'
|
||||||
|
'WITH GROUP "DFLT_Num_numerators"\n'
|
||||||
|
'END_SUB\n'
|
||||||
|
'END_SUBSTITUTION'
|
||||||
|
).statements
|
||||||
|
self.assertEqual(
|
||||||
|
(lookup.name, lookup.reversal),
|
||||||
|
("RevLookup", True)
|
||||||
|
)
|
||||||
|
|
||||||
# GPOS
|
# GPOS
|
||||||
# ATTACH_CURSIVE
|
# ATTACH_CURSIVE
|
||||||
# ATTACH
|
# ATTACH
|
||||||
|
Loading…
x
Reference in New Issue
Block a user