diff --git a/language-reference-manual/lrm.trlc b/language-reference-manual/lrm.trlc index d399dfb5..290888be 100644 --- a/language-reference-manual/lrm.trlc +++ b/language-reference-manual/lrm.trlc @@ -1070,7 +1070,6 @@ section "Expressions" { is recommended that a linter warns whenever a unary minus is encountered that has a non-trivial `term` or `factor` as its operand.''' - untraced_reason = "Non-normative recommendation" } Example Expression_Examples { diff --git a/tests-system/unary-ops-1/example.rsl b/tests-system/rbt-unary-minus-parsing/example.rsl similarity index 100% rename from tests-system/unary-ops-1/example.rsl rename to tests-system/rbt-unary-minus-parsing/example.rsl diff --git a/tests-system/rbt-unary-minus-parsing/output b/tests-system/rbt-unary-minus-parsing/output new file mode 100644 index 00000000..bdbe57a4 --- /dev/null +++ b/tests-system/rbt-unary-minus-parsing/output @@ -0,0 +1,3 @@ +-a * b > 0, "potato" +^ rbt-unary-minus-parsing/example.rsl:9: issue: expression means -(a * b), place explicit brackets to clarify intent [unary_minus_precedence] +Processed 1 model(s), 0 check(s) and 0 requirement file(s) and found 1 warning(s) diff --git a/tests-system/unary-ops-1/output.brief b/tests-system/rbt-unary-minus-parsing/output.brief similarity index 100% rename from tests-system/unary-ops-1/output.brief rename to tests-system/rbt-unary-minus-parsing/output.brief diff --git a/tests-system/unary-ops-1/output.json b/tests-system/rbt-unary-minus-parsing/output.json similarity index 100% rename from tests-system/unary-ops-1/output.json rename to tests-system/rbt-unary-minus-parsing/output.json diff --git a/tests-system/rbt-unary-minus-parsing/output.smtlib b/tests-system/rbt-unary-minus-parsing/output.smtlib new file mode 100644 index 00000000..bdbe57a4 --- /dev/null +++ b/tests-system/rbt-unary-minus-parsing/output.smtlib @@ -0,0 +1,3 @@ +-a * b > 0, "potato" +^ rbt-unary-minus-parsing/example.rsl:9: issue: expression means -(a * b), place explicit brackets to clarify intent [unary_minus_precedence] +Processed 1 model(s), 0 check(s) and 0 requirement file(s) and found 1 warning(s) diff --git a/tests-system/unary-ops-1/output b/tests-system/unary-ops-1/output deleted file mode 100644 index d478f463..00000000 --- a/tests-system/unary-ops-1/output +++ /dev/null @@ -1,3 +0,0 @@ --a * b > 0, "potato" -^ unary-ops-1/example.rsl:9: issue: expression means -(a * b), place explicit brackets to clarify intent [unary_minus_precedence] -Processed 1 model(s), 0 check(s) and 0 requirement file(s) and found 1 warning(s) diff --git a/tests-system/unary-ops-1/output.smtlib b/tests-system/unary-ops-1/output.smtlib deleted file mode 100644 index d478f463..00000000 --- a/tests-system/unary-ops-1/output.smtlib +++ /dev/null @@ -1,3 +0,0 @@ --a * b > 0, "potato" -^ unary-ops-1/example.rsl:9: issue: expression means -(a * b), place explicit brackets to clarify intent [unary_minus_precedence] -Processed 1 model(s), 0 check(s) and 0 requirement file(s) and found 1 warning(s) diff --git a/trlc/ast.py b/trlc/ast.py index 858fc0a1..f9dd7adf 100644 --- a/trlc/ast.py +++ b/trlc/ast.py @@ -591,6 +591,7 @@ def to_python_object(self): class Null_Literal(Literal): + # lobster-trace: LRM.Primary """The null literal This can appear in check expressions:: @@ -603,14 +604,12 @@ class Null_Literal(Literal): """ def __init__(self, token): - # lobster-exclude: Constructor only declares variables assert isinstance(token, Token) assert token.kind == "KEYWORD" assert token.value == "null" super().__init__(token.location, None) def dump(self, indent=0): # pragma: no cover - # lobster-exclude: Debugging feature self.write_indent(indent, "Null Literal") def to_string(self): @@ -630,6 +629,7 @@ def can_be_null(self): class Integer_Literal(Literal): # lobster-trace: LRM.Integer_Values + # lobster-trace: LRM.Primary """Integer literals Note that these are always positive. A negative integer is @@ -676,6 +676,7 @@ def can_be_null(self): class Decimal_Literal(Literal): # lobster-trace: LRM.Decimal_Values + # lobster-trace: LRM.Primary """Decimal literals Note that these are always positive. A negative decimal is @@ -723,6 +724,7 @@ def can_be_null(self): class String_Literal(Literal): # lobster-trace: LRM.String_Values # lobster-trace: LRM.Markup_String_Values + # lobster-trace: LRM.Primary """String literals Note the value of the string does not include the quotation marks, @@ -778,6 +780,7 @@ def can_be_null(self): class Boolean_Literal(Literal): # lobster-trace: LRM.Boolean_Values + # lobster-trace: LRM.Primary """Boolean values :attribute value: the boolean value @@ -1166,6 +1169,9 @@ class Unary_Expression(Expression): """ def __init__(self, mh, location, typ, operator, n_operand): + # lobster-trace: LRM.Simple_Expression + # lobster-trace: LRM.Relation + # lobster-trace: LRM.Factor super().__init__(location, typ) assert isinstance(mh, Message_Handler) assert isinstance(operator, Unary_Operator) @@ -1329,6 +1335,11 @@ class Binary_Expression(Expression): """ def __init__(self, mh, location, typ, operator, n_lhs, n_rhs): + # lobster-trace: LRM.Expression + # lobster-trace: LRM.Relation + # lobster-trace: LRM.Simple_Expression + # lobster-trace: LRM.Term + # lobster-trace: LRM.Factor super().__init__(location, typ) assert isinstance(mh, Message_Handler) assert isinstance(operator, Binary_Operator) @@ -1731,6 +1742,7 @@ class Range_Test(Expression): """ def __init__(self, mh, location, typ, n_lhs, n_lower, n_upper): + # lobster-trace: LRM.Relation super().__init__(location, typ) assert isinstance(mh, Message_Handler) assert isinstance(n_lhs, Expression) diff --git a/trlc/parser.py b/trlc/parser.py index ab806733..9162c2f6 100644 --- a/trlc/parser.py +++ b/trlc/parser.py @@ -675,6 +675,7 @@ def parse_expression(self, scope): def parse_relation(self, scope): # lobster-trace: LRM.Relation + # lobster-trace: LRM.Operators assert isinstance(scope, ast.Scope) relop_mapping = {"==" : ast.Binary_Operator.COMP_EQ, "!=" : ast.Binary_Operator.COMP_NEQ, @@ -760,6 +761,8 @@ def parse_relation(self, scope): def parse_simple_expression(self, scope): # lobster-trace: LRM.Simple_Expression + # lobster-trace: LRM.Operators + # lobster-trace: LRM.Unary_Minus_Parsing assert isinstance(scope, ast.Scope) un_add_map = {"+" : ast.Unary_Operator.PLUS, "-" : ast.Unary_Operator.MINUS} @@ -816,6 +819,7 @@ def parse_simple_expression(self, scope): def parse_term(self, scope): # lobster-trace: LRM.Term + # lobster-trace: LRM.Operators assert isinstance(scope, ast.Scope) mul_map = {"*" : ast.Binary_Operator.TIMES, "/" : ast.Binary_Operator.DIVIDE,