Commit f223aead authored by Fabrice Salvaire's avatar Fabrice Salvaire

improved Ast

parent 7e4acd86
......@@ -381,11 +381,26 @@ class Line(MachineMixin):
if isinstance(item, Word):
yield item
def iter_on_gm_word(self):
for item in self:
if isinstance(item, Word) and item.is_gm_gcode:
yield item
def iter_on_x_word(self):
for item in self:
if isinstance(item, Word) and not item.is_gm_gcode:
yield item
def iter_on_setting(self):
for item in self:
if isinstance(item, ParameterSetting):
yield item
def iter_in_order(self):
words = [word for word in self.iter_on_gm_word()]
words.sort(key=lambda word: word.execution_order.index)
return words
##############################################
def toggle(self):
......
......@@ -63,6 +63,9 @@ program = machine.parser.parse_lines(lines)
#r# We dump the annotated program
def str_list(a_list):
return ' '.join([str(item) for item in a_list])
meaning_format = ' {:5}: {}'
for line in program:
print()
......@@ -77,4 +80,10 @@ for line in program:
print(margin + 'Valid G-code: {}'.format(word.is_valid_gcode))
else:
print(meaning_format.format(word.letter, word.meaning))
print(
' execution:',
str_list(line.iter_in_order()), '/',
str_list(line.iter_on_x_word()), '/',
str_list(line.iter_on_setting()),
)
#o#
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment