Skip to content

Commit

Permalink
Add constants for maximum line length
Browse files Browse the repository at this point in the history
Ref. #1064, #1085
  • Loading branch information
treiher committed Jun 28, 2022
1 parent 733a946 commit e920fe3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 4 additions & 2 deletions rflx/ada.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
from rflx.common import Base, file_name, indent, indent_next, unique
from rflx.contract import invariant

MAX_LINE_LENGTH = 100


class ID(rflx.identifier.ID):
@property
Expand Down Expand Up @@ -702,7 +704,7 @@ def _update_str(self) -> None:
expression += f" else {else_expression}"
expression = " ".join(expression.split())

if len(expression) > 100:
if len(expression) > MAX_LINE_LENGTH:
expression = ""
expression = "".join(
f"if\n{indent(c, 4)}\n then\n{indent(e, 4)}"
Expand Down Expand Up @@ -1777,7 +1779,7 @@ def __init__(self, condition: Expr, statements: Sequence[Statement]) -> None:
def __str__(self) -> str:
condition = str(self.condition)
statements = indent("\n".join(str(s) for s in self.statements), 3)
if "\n" in condition or len(condition) > 100:
if "\n" in condition or len(condition) > MAX_LINE_LENGTH:
return f"while\n{indent(condition, 3)}\nloop\n{statements}\nend loop;"
return f"while {self.condition} loop\n{statements}\nend loop;"

Expand Down
4 changes: 3 additions & 1 deletion rflx/expression.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
from rflx.error import Location, RecordFluxError, Severity, Subsystem
from rflx.identifier import ID, StrID

MAX_LINE_LENGTH = 100


class Z3TypeError(TypeError):
pass
Expand Down Expand Up @@ -2066,7 +2068,7 @@ def _update_str(self) -> None:
expression += f" else {else_expression}"
expression = " ".join(expression.split())

if len(expression) > 100:
if len(expression) > MAX_LINE_LENGTH:
expression = ""
expression = "".join(
f"if\n{indent(c, 4)}\n then\n{indent(e, 4)}"
Expand Down

0 comments on commit e920fe3

Please sign in to comment.