[voltLib] Add ranges to GroupDefinition
This commit is contained in:
parent
b92829351d
commit
7ab01f730c
@ -93,7 +93,7 @@ class Parser(object):
|
||||
def parse_enum_(self):
|
||||
assert self.is_cur_keyword_("ENUM")
|
||||
location = self.cur_token_location_
|
||||
enum = {'glyphs': [], 'groups': []}
|
||||
enum = {'glyphs': [], 'groups': [], 'ranges': []}
|
||||
while self.next_token_ != "END_ENUM":
|
||||
if self.next_token_ == "GLYPH":
|
||||
self.expect_keyword_("GLYPH")
|
||||
@ -103,6 +103,10 @@ class Parser(object):
|
||||
self.expect_keyword_("GROUP")
|
||||
name = self.expect_string_()
|
||||
enum['groups'].append(name)
|
||||
elif self.next_token_ == "RANGE":
|
||||
self.expect_keyword_("RANGE")
|
||||
start, end = self.expect_string_(), self.expect_string_()
|
||||
enum['ranges'].append((start, end))
|
||||
self.expect_keyword_("END_ENUM")
|
||||
return enum
|
||||
|
||||
|
@ -63,7 +63,8 @@ class ParserTest(unittest.TestCase):
|
||||
{"glyphs": ["a", "aacute", "abreve", "acircumflex",
|
||||
"adieresis", "ae", "agrave", "amacron",
|
||||
"aogonek", "aring", "atilde"],
|
||||
"groups": []}))
|
||||
"groups": [],
|
||||
"ranges": []}))
|
||||
[def_group] = self.parse(
|
||||
'DEF_GROUP "KERN_lc_a_2ND"\n'
|
||||
'ENUM GLYPH "a" GROUP "aaccented" END_ENUM\n'
|
||||
@ -72,7 +73,20 @@ class ParserTest(unittest.TestCase):
|
||||
self.assertEqual((def_group.name, def_group.enum),
|
||||
("KERN_lc_a_2ND",
|
||||
{"glyphs": ["a"],
|
||||
"groups": ["aaccented"]}))
|
||||
"groups": ["aaccented"],
|
||||
"ranges": []}))
|
||||
[def_group] = self.parse(
|
||||
'DEF_GROUP "KERN_lc_a_2ND"\n'
|
||||
'ENUM RANGE "a" "atilde" GLYPH "b" RANGE "c" "cdotaccent" '
|
||||
'END_ENUM\n'
|
||||
'END_GROUP'
|
||||
).statements
|
||||
self.assertEqual((def_group.name, def_group.enum),
|
||||
("KERN_lc_a_2ND",
|
||||
{"glyphs": ["b"],
|
||||
"groups": [],
|
||||
"ranges": [("a", "atilde"),
|
||||
("c", "cdotaccent")]}))
|
||||
|
||||
def test_group_duplicate(self):
|
||||
self.assertRaisesRegex(
|
||||
|
Loading…
x
Reference in New Issue
Block a user