Skip to content

Commit

Permalink
Adding break; support
Browse files Browse the repository at this point in the history
Signed-off-by: Cervenka Dusan <[email protected]>
  • Loading branch information
Hadatko committed Nov 13, 2024
1 parent 7ed5d25 commit 71f13fb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/cfile/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,3 +511,8 @@ class Block(Sequence):
"""
A sequence wrapped in braces
"""

class Break(Element):
"""
Adding break into block
"""
6 changes: 6 additions & 0 deletions src/cfile/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,3 +227,9 @@ def declaration(self,

"""New declaration"""
return core.Declaration(element, init_value)

def breakBlock(self) -> core.Break:
"""
Adding break into block
"""
return core.Break()
5 changes: 5 additions & 0 deletions src/cfile/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,8 @@ def _write_sequence(self, sequence: core.Sequence) -> None:
elif isinstance(elem, core.Line):
self._start_line()
self._write_line_element(elem)
elif isinstance(elem, core.Break):
self._write_break(elem)
else:
self._start_line()
class_name = elem.__class__.__name__
Expand Down Expand Up @@ -709,3 +711,6 @@ def _write_endif_directive(self, elem: core.EndifDirective) -> None:
def _write_extern(self, elem: core.Extern) -> None:
self._write(f'extern "{elem.language}"')
self.last_element = ElementType.DIRECTIVE

def _write_break(self, elem: core.Break):
self._write("break")

0 comments on commit 71f13fb

Please sign in to comment.