Skip to content

Commit

Permalink
fixes remove of deprecated builtin function syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
christophkloeffel committed Sep 10, 2024
1 parent 2cfed0b commit 9fc89ee
Show file tree
Hide file tree
Showing 14 changed files with 50 additions and 30 deletions.
File renamed without changes.
File renamed without changes.
7 changes: 7 additions & 0 deletions tests-system/rbt-builtin-functions-1/output
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions tests-system/rbt-builtin-functions-1/output.smtlib
Original file line number Diff line number Diff line change
@@ -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
11 changes: 11 additions & 0 deletions tests-system/rbt-builtin-functions-2/foo.rsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package Foo

type Requirement {
name String
description String

}

checks Requirement {
name != , warning "bar"
}
3 changes: 3 additions & 0 deletions tests-system/rbt-builtin-functions-2/output
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions tests-system/rbt-builtin-functions-2/output.brief
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rbt-builtin-functions-2/foo.rsl:10:13: trlc error: expected identifier, encountered comma ',' instead
3 changes: 3 additions & 0 deletions tests-system/rbt-builtin-functions-2/output.json
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions tests-system/rbt-builtin-functions-2/output.smtlib
Original file line number Diff line number Diff line change
@@ -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
7 changes: 0 additions & 7 deletions tests-system/rbt-builtin-functions/output

This file was deleted.

7 changes: 0 additions & 7 deletions tests-system/rbt-builtin-functions/output.smtlib

This file was deleted.

31 changes: 15 additions & 16 deletions trlc/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 9fc89ee

Please sign in to comment.