feat: adds consume.sections

This commit is contained in:
Johann Dreo 2026-04-05 19:00:18 +02:00
commit 70661d39b8

View file

@ -49,6 +49,26 @@ class consume:
current = ""
return pars
class sections(Consume):
def __init__(self, mark = r"^#", skip = "False"):
self.mark = mark
self.skip = bool(skip)
def __call__(self, stream):
sec = []
current = ""
for item in stream.readlines():
if re.match(self.mark, item[0]):
sec.append( current )
if self.skip:
current = ""
else:
current = item
else:
current += item
sec.append( current )
return sec
class format:
class Format:
def __call__(self, items):
@ -317,8 +337,11 @@ def main():
asked.lift = ["stdout"]
logger.debug("Chosen operators:")
cop,cargs = list(operator([asked.consume]))[0]
forthlift = Forthlifter(
consumer = consumers[asked.consume](),
consumer = consumers[cop](*cargs),
streamers = [streamers[op](*args) for op,args in operator(asked.stream)],
formatters = [formaters[op](*args) for op,args in operator(asked.format)],
lifters = [ lifters[op](*args) for op,args in operator(asked.lift )],