[voltLib] fix parsing device tables, add parse_adjust_by_
This commit is contained in:
parent
8d193ddc53
commit
296de366d5
@ -353,7 +353,16 @@ class Parser(object):
|
||||
component, locked, pos)
|
||||
return anchor
|
||||
|
||||
def parse_adjust_by_(self):
|
||||
self.advance_lexer_()
|
||||
assert self.is_cur_keyword_("ADJUST_BY")
|
||||
adjustment = self.expect_number_()
|
||||
self.expect_keyword_("AT")
|
||||
size = self.expect_number_()
|
||||
return adjustment, size
|
||||
|
||||
def parse_pos_(self):
|
||||
# VOLT syntax doesn't seem to take device Y advance
|
||||
self.advance_lexer_()
|
||||
location = self.cur_token_location_
|
||||
assert self.is_cur_keyword_("POS"), location
|
||||
@ -367,22 +376,19 @@ class Parser(object):
|
||||
self.advance_lexer_()
|
||||
adv = self.expect_number_()
|
||||
while self.next_token_ == "ADJUST_BY":
|
||||
adjustment = self.expect_number_()
|
||||
size = self.expect_number_()
|
||||
adjustment, size = self.parse_adjust_by_()
|
||||
adv_adjust_by[size] = adjustment
|
||||
if self.next_token_ == "DX":
|
||||
self.advance_lexer_()
|
||||
dx = self.expect_number_()
|
||||
while self.next_token_ == "ADJUST_BY":
|
||||
adjustment = self.expect_number_()
|
||||
size = self.expect_number_()
|
||||
adjustment, size = self.parse_adjust_by_()
|
||||
dx_adjust_by[size] = adjustment
|
||||
if self.next_token_ == "DY":
|
||||
self.advance_lexer_()
|
||||
dy = self.expect_number_()
|
||||
while self.next_token_ == "ADJUST_BY":
|
||||
adjustment = self.expect_number_()
|
||||
size = self.expect_number_()
|
||||
adjustment, size = self.parse_adjust_by_()
|
||||
dy_adjust_by[size] = adjustment
|
||||
self.expect_keyword_("END_POS")
|
||||
return (adv, dx, dy, adv_adjust_by, dx_adjust_by, dy_adjust_by)
|
||||
|
@ -592,6 +592,16 @@ class ParserTest(unittest.TestCase):
|
||||
False, (None, 0, 450, {}, {}, {}))
|
||||
)
|
||||
|
||||
def test_anchor_adjust_device(self):
|
||||
[anchor] = self.parse(
|
||||
'DEF_ANCHOR "MARK_top" ON 123 GLYPH diacglyph '
|
||||
'COMPONENT 1 AT POS DX 0 DY 456 ADJUST_BY 12 AT 34 ADJUST_BY 56 AT 78 END_POS END_ANCHOR'
|
||||
).statements
|
||||
self.assertEqual(
|
||||
(anchor.name, anchor.pos),
|
||||
("MARK_top", (None, 0, 456, {}, {}, {34: 12, 78: 56}))
|
||||
)
|
||||
|
||||
def test_ppem(self):
|
||||
[grid_ppem, pres_ppem, ppos_ppem] = self.parse(
|
||||
'GRID_PPEM 20\n'
|
||||
|
Loading…
x
Reference in New Issue
Block a user