From 9fc89ee611059d3b125e1d8a44c41f1bb60dd901 Mon Sep 17 00:00:00 2001 From: christophkloeffel Date: Tue, 10 Sep 2024 13:59:28 +0200 Subject: [PATCH] fixes remove of deprecated builtin function syntax --- .../foo.rsl | 0 .../foo.trlc | 0 tests-system/rbt-builtin-functions-1/output | 7 +++++ .../output.brief | 0 .../output.json | 0 .../rbt-builtin-functions-1/output.smtlib | 7 +++++ tests-system/rbt-builtin-functions-2/foo.rsl | 11 +++++++ tests-system/rbt-builtin-functions-2/output | 3 ++ .../rbt-builtin-functions-2/output.brief | 1 + .../rbt-builtin-functions-2/output.json | 3 ++ .../rbt-builtin-functions-2/output.smtlib | 3 ++ tests-system/rbt-builtin-functions/output | 7 ----- .../rbt-builtin-functions/output.smtlib | 7 ----- trlc/parser.py | 31 +++++++++---------- 14 files changed, 50 insertions(+), 30 deletions(-) rename tests-system/{rbt-builtin-functions => rbt-builtin-functions-1}/foo.rsl (100%) rename tests-system/{rbt-builtin-functions => rbt-builtin-functions-1}/foo.trlc (100%) create mode 100644 tests-system/rbt-builtin-functions-1/output rename tests-system/{rbt-builtin-functions => rbt-builtin-functions-1}/output.brief (100%) rename tests-system/{rbt-builtin-functions => rbt-builtin-functions-1}/output.json (100%) create mode 100644 tests-system/rbt-builtin-functions-1/output.smtlib create mode 100644 tests-system/rbt-builtin-functions-2/foo.rsl create mode 100644 tests-system/rbt-builtin-functions-2/output create mode 100644 tests-system/rbt-builtin-functions-2/output.brief create mode 100644 tests-system/rbt-builtin-functions-2/output.json create mode 100644 tests-system/rbt-builtin-functions-2/output.smtlib delete mode 100644 tests-system/rbt-builtin-functions/output delete mode 100644 tests-system/rbt-builtin-functions/output.smtlib diff --git a/tests-system/rbt-builtin-functions/foo.rsl b/tests-system/rbt-builtin-functions-1/foo.rsl similarity index 100% rename from tests-system/rbt-builtin-functions/foo.rsl rename to tests-system/rbt-builtin-functions-1/foo.rsl diff --git a/tests-system/rbt-builtin-functions/foo.trlc b/tests-system/rbt-builtin-functions-1/foo.trlc similarity index 100% rename from tests-system/rbt-builtin-functions/foo.trlc rename to tests-system/rbt-builtin-functions-1/foo.trlc diff --git a/tests-system/rbt-builtin-functions-1/output b/tests-system/rbt-builtin-functions-1/output new file mode 100644 index 00000000..d0a7f840 --- /dev/null +++ b/tests-system/rbt-builtin-functions-1/output @@ -0,0 +1,7 @@ +len("foo") == 3, warning "len is broken" + ^^ rbt-builtin-functions-1/foo.rsl:6: issue: expression is always true [vcg-always-true] +startswith("foo", "f"), warning "startswith is broken" +^^^^^^^^^^ rbt-builtin-functions-1/foo.rsl:7: issue: expression is always true [vcg-always-true] +endswith("foo", "o"), warning "endswith is broken" +^^^^^^^^ rbt-builtin-functions-1/foo.rsl:8: issue: expression is always true [vcg-always-true] +Processed 1 model and 1 requirement file and found 3 warnings diff --git a/tests-system/rbt-builtin-functions/output.brief b/tests-system/rbt-builtin-functions-1/output.brief similarity index 100% rename from tests-system/rbt-builtin-functions/output.brief rename to tests-system/rbt-builtin-functions-1/output.brief diff --git a/tests-system/rbt-builtin-functions/output.json b/tests-system/rbt-builtin-functions-1/output.json similarity index 100% rename from tests-system/rbt-builtin-functions/output.json rename to tests-system/rbt-builtin-functions-1/output.json diff --git a/tests-system/rbt-builtin-functions-1/output.smtlib b/tests-system/rbt-builtin-functions-1/output.smtlib new file mode 100644 index 00000000..d0a7f840 --- /dev/null +++ b/tests-system/rbt-builtin-functions-1/output.smtlib @@ -0,0 +1,7 @@ +len("foo") == 3, warning "len is broken" + ^^ rbt-builtin-functions-1/foo.rsl:6: issue: expression is always true [vcg-always-true] +startswith("foo", "f"), warning "startswith is broken" +^^^^^^^^^^ rbt-builtin-functions-1/foo.rsl:7: issue: expression is always true [vcg-always-true] +endswith("foo", "o"), warning "endswith is broken" +^^^^^^^^ rbt-builtin-functions-1/foo.rsl:8: issue: expression is always true [vcg-always-true] +Processed 1 model and 1 requirement file and found 3 warnings diff --git a/tests-system/rbt-builtin-functions-2/foo.rsl b/tests-system/rbt-builtin-functions-2/foo.rsl new file mode 100644 index 00000000..8b88f46f --- /dev/null +++ b/tests-system/rbt-builtin-functions-2/foo.rsl @@ -0,0 +1,11 @@ +package Foo + +type Requirement { + name String + description String + +} + +checks Requirement { + name != , warning "bar" +} diff --git a/tests-system/rbt-builtin-functions-2/output b/tests-system/rbt-builtin-functions-2/output new file mode 100644 index 00000000..47cd8608 --- /dev/null +++ b/tests-system/rbt-builtin-functions-2/output @@ -0,0 +1,3 @@ +name != , warning "bar" + ^ rbt-builtin-functions-2/foo.rsl:10: error: expected identifier, encountered comma ',' instead +Processed 1 model and 0 requirement files and found 1 error diff --git a/tests-system/rbt-builtin-functions-2/output.brief b/tests-system/rbt-builtin-functions-2/output.brief new file mode 100644 index 00000000..195694fe --- /dev/null +++ b/tests-system/rbt-builtin-functions-2/output.brief @@ -0,0 +1 @@ +rbt-builtin-functions-2/foo.rsl:10:13: trlc error: expected identifier, encountered comma ',' instead diff --git a/tests-system/rbt-builtin-functions-2/output.json b/tests-system/rbt-builtin-functions-2/output.json new file mode 100644 index 00000000..47cd8608 --- /dev/null +++ b/tests-system/rbt-builtin-functions-2/output.json @@ -0,0 +1,3 @@ +name != , warning "bar" + ^ rbt-builtin-functions-2/foo.rsl:10: error: expected identifier, encountered comma ',' instead +Processed 1 model and 0 requirement files and found 1 error diff --git a/tests-system/rbt-builtin-functions-2/output.smtlib b/tests-system/rbt-builtin-functions-2/output.smtlib new file mode 100644 index 00000000..47cd8608 --- /dev/null +++ b/tests-system/rbt-builtin-functions-2/output.smtlib @@ -0,0 +1,3 @@ +name != , warning "bar" + ^ rbt-builtin-functions-2/foo.rsl:10: error: expected identifier, encountered comma ',' instead +Processed 1 model and 0 requirement files and found 1 error diff --git a/tests-system/rbt-builtin-functions/output b/tests-system/rbt-builtin-functions/output deleted file mode 100644 index 9df7a0b2..00000000 --- a/tests-system/rbt-builtin-functions/output +++ /dev/null @@ -1,7 +0,0 @@ -len("foo") == 3, warning "len is broken" - ^^ rbt-builtin-functions/foo.rsl:6: issue: expression is always true [vcg-always-true] -startswith("foo", "f"), warning "startswith is broken" -^^^^^^^^^^ rbt-builtin-functions/foo.rsl:7: issue: expression is always true [vcg-always-true] -endswith("foo", "o"), warning "endswith is broken" -^^^^^^^^ rbt-builtin-functions/foo.rsl:8: issue: expression is always true [vcg-always-true] -Processed 1 model and 1 requirement file and found 3 warnings diff --git a/tests-system/rbt-builtin-functions/output.smtlib b/tests-system/rbt-builtin-functions/output.smtlib deleted file mode 100644 index 9df7a0b2..00000000 --- a/tests-system/rbt-builtin-functions/output.smtlib +++ /dev/null @@ -1,7 +0,0 @@ -len("foo") == 3, warning "len is broken" - ^^ rbt-builtin-functions/foo.rsl:6: issue: expression is always true [vcg-always-true] -startswith("foo", "f"), warning "startswith is broken" -^^^^^^^^^^ rbt-builtin-functions/foo.rsl:7: issue: expression is always true [vcg-always-true] -endswith("foo", "o"), warning "endswith is broken" -^^^^^^^^ rbt-builtin-functions/foo.rsl:8: issue: expression is always true [vcg-always-true] -Processed 1 model and 1 requirement file and found 3 warnings diff --git a/trlc/parser.py b/trlc/parser.py index aae52cf1..15a67388 100644 --- a/trlc/parser.py +++ b/trlc/parser.py @@ -1310,22 +1310,21 @@ def parse_name(self, scope): # components the true grammar for function calls is always # IDENTIFIER '('; so we can slightly special case this. - if self.peek("IDENTIFIER"): - # lobster-trace: LRM.Builtin_Functions - # lobster-trace: LRM.Builtin_Type_Conversion_Functions - self.match("IDENTIFIER") - if self.peek("BRA"): - # If we follow our name with brackets - # immediately, we have a builtin function call. - n_name = self.stab.lookup(self.mh, - self.ct) - if not isinstance(n_name, (ast.Builtin_Function, - ast.Builtin_Numeric_Type)): - self.mh.error(self.ct.location, - "not a valid builtin function " - "or numeric type") - else: - n_name = self.parse_qualified_name(scope, match_ident=False) + # lobster-trace: LRM.Builtin_Functions + # lobster-trace: LRM.Builtin_Type_Conversion_Functions + self.match("IDENTIFIER") + if self.peek("BRA"): + # If we follow our name with brackets + # immediately, we have a builtin function call. + n_name = self.stab.lookup(self.mh, + self.ct) + if not isinstance(n_name, (ast.Builtin_Function, + ast.Builtin_Numeric_Type)): + self.mh.error(self.ct.location, + "not a valid builtin function " + "or numeric type") + else: + n_name = self.parse_qualified_name(scope, match_ident=False) # Enum literals are a bit different, so we deal with them # first.