Skip to content

Commit

Permalink
adds tracing for check files (bmw-software-engineering#35)
Browse files Browse the repository at this point in the history
adds tracing for chapter 9
  • Loading branch information
christophkloeffel authored Oct 11, 2023
1 parent 24bd39b commit da14749
Show file tree
Hide file tree
Showing 15 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests-system/rbt-cannot-declare-in-check-file/foo.check
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package Foo
3 changes: 3 additions & 0 deletions tests-system/rbt-cannot-declare-in-check-file/output
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package Foo
^^^ rbt-cannot-declare-in-check-file/foo.check:1: error: unknown symbol Foo
Processed 0 model(s), 1 check(s) and 0 requirement file(s) and found 1 error(s)
1 change: 1 addition & 0 deletions tests-system/rbt-cannot-declare-in-check-file/output.brief
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rbt-cannot-declare-in-check-file/foo.check:1:9: trlc error: unknown symbol Foo
3 changes: 3 additions & 0 deletions tests-system/rbt-cannot-declare-in-check-file/output.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package Foo
^^^ rbt-cannot-declare-in-check-file/foo.check:1: error: unknown symbol Foo
Processed 0 model(s), 1 check(s) and 0 requirement file(s) and found 1 error(s)
3 changes: 3 additions & 0 deletions tests-system/rbt-cannot-declare-in-check-file/output.smtlib
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package Foo
^^^ rbt-cannot-declare-in-check-file/foo.check:1: error: unknown symbol Foo
Processed 0 model(s), 1 check(s) and 0 requirement file(s) and found 1 error(s)
1 change: 1 addition & 0 deletions tests-system/rbt-import-in-check/bar.rsl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package Bar
3 changes: 3 additions & 0 deletions tests-system/rbt-import-in-check/foo.check
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package Foo

import Bar
1 change: 1 addition & 0 deletions tests-system/rbt-import-in-check/foo.rsl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package Foo
3 changes: 3 additions & 0 deletions tests-system/rbt-import-in-check/output
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Bar
^^^^^^ rbt-import-in-check/foo.check:3: error: expected keyword checks, encountered keyword import instead
Processed 2 model(s), 1 check(s) and 0 requirement file(s) and found 1 error(s)
1 change: 1 addition & 0 deletions tests-system/rbt-import-in-check/output.brief
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rbt-import-in-check/foo.check:3:1: trlc error: expected keyword checks, encountered keyword import instead
3 changes: 3 additions & 0 deletions tests-system/rbt-import-in-check/output.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Bar
^^^^^^ rbt-import-in-check/foo.check:3: error: expected keyword checks, encountered keyword import instead
Processed 2 model(s), 1 check(s) and 0 requirement file(s) and found 1 error(s)
3 changes: 3 additions & 0 deletions tests-system/rbt-import-in-check/output.smtlib
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Bar
^^^^^^ rbt-import-in-check/foo.check:3: error: expected keyword checks, encountered keyword import instead
Processed 2 model(s), 1 check(s) and 0 requirement file(s) and found 1 error(s)
2 changes: 2 additions & 0 deletions tests-system/simple/tracing
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ LRM.Layout
LRM.File_Parsing_Order
LRM.Preamble
LRM.RSL_File
LRM.Check_File
LRM.Deprecated_Check_Files
4 changes: 4 additions & 0 deletions trlc/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -1583,6 +1583,7 @@ def parse_preamble(self, kind):
assert kind in ("rsl", "check", "trlc")
# lobster-trace: LRM.Layout
# lobster-trace: LRM.Preamble
# lobster-trace: LRM.Cannot_Declare_In_Check_File

# First, parse package indication, declaring the package if
# needed
Expand Down Expand Up @@ -1665,6 +1666,7 @@ def parse_rsl_file(self):
return ok

def parse_check_file(self):
# lobster-trace: LRM.Check_File
self.parse_preamble("check")
self.cu.resolve_imports(self.mh, self.stab)

Expand All @@ -1674,6 +1676,7 @@ def parse_check_file(self):
try:
n_block = self.parse_check_block()
self.cu.add_item(n_block)
# lobster-trace: LRM.Deprecated_Check_Files
if self.lint_mode:
self.mh.check(
n_block.location,
Expand All @@ -1689,6 +1692,7 @@ def parse_check_file(self):
# Recovery strategy is to look for the next check
# block
self.skip_until_newline()
# lobster-trace: LRM.Import_In_Check
while not self.peek_eof() and not self.peek_kw("checks"):
self.advance()
self.skip_until_newline()
Expand Down
1 change: 1 addition & 0 deletions trlc/trlc.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ def parse_rsl_files(self):

def parse_check_files(self):
# lobster-trace: LRM.Preamble
# lobster-trace: LRM.Check_File

ok = True
for name in sorted(self.check_files):
Expand Down

0 comments on commit da14749

Please sign in to comment.