Skip to content

Commit

Permalink
Sync with florian's fork (#87)
Browse files Browse the repository at this point in the history
Sync with Florian's fork

Implements:
* #85
* #62
* #53

Also fixes up some documentation and adds design docs for a new feature.
  • Loading branch information
florianschanda authored Jun 10, 2024
1 parent 3188b09 commit 39b4e36
Show file tree
Hide file tree
Showing 598 changed files with 1,457 additions and 1,261 deletions.
39 changes: 32 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Language support

Up to date with version 2.9 of [TRLC language reference
Up to date with version 3.0 of [TRLC language reference
manual](https://bmw-software-engineering.github.io/trlc/lrm.html).

## Limitations
Expand All @@ -25,13 +25,38 @@ generated in the following situations:
## Changelog


### 1.2.3-dev
### 2.0.0-dev

* [TRLC] A warning is not issued by the tools when encountering
duplicate late package declarations.
This new major release includes a number of incompatible
changes. These have been tagged in the changelog.

* [Incompatible, TRLC, LRM, API] New major version as all deprecated
features have been removed:

* The deprecated builtin function syntax `trlc:foo` has been
removed. You should now use `foo` instead.

* Support for check files has been removed. You can simply move any
checks into the rsl file.

* API support surrounding check files in the Source_Manager has been
removed.

* [Incompatible, TRLC, LRM, API] The LRM had rules that names need to
be sufficiently distinct, for example having `Foo`, `foo` or `Fo_o`
in the same namespace would not be allowed. This was previously not
implemented at all.

The rules have been strengthened to apply to all names (packages,
types, literals, objects) and are now enforced. This is also a
backwards incompatible change as it may invalidate some previously
valid `.trlc` or `.rsl` files.

* [TRLC, LRM] New builtin function `oneof`. This can be used to test
if precisely one of a number of parameters is true. For example:

* [TRLC] The deprecated builtin function syntax `trlc:foo` has been
removed. You should now use `foo` instead.
* [TRLC] The warning about late package declarations is no longer
issued.

* [TRLC] New command-line flag `-I` which can be used to register
include directories. You can use this to automatically parse a
Expand All @@ -46,7 +71,7 @@ generated in the following situations:
Especially in large projects this will be much faster than
explicitly parsing everything.

* [API] The source manage has a new function
* [API] The source manager has a new function
[register_include](https://bmw-software-engineering.github.io/trlc/manual/infrastructure.html#trlc.trlc.Source_Manager.register_include)
which should be used before any `register_file` or `register_dir`
calls.
Expand Down
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ unit-tests.lobster: $(wildcard tests-unit/*.py)
lobster-python --activity --out unit-tests.lobster tests-unit

system-tests.lobster: $(wildcard tests-system/*/*.rsl) \
$(wildcard tests-system/*/*.check) \
$(wildcard tests-system/*/*.trlc) \
$(wildcard tests-system/*/tracing)
python3 lobster-trlc-system-test.py
Expand Down
2 changes: 1 addition & 1 deletion api-examples/filename-check/filename-1.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
mh = Message_Handler()
sm = Source_Manager(mh)

# Read all .rsl, .check, and .trlc files
# Read all .rsl and .trlc files
# in the given directory
sm.register_directory(".")

Expand Down
2 changes: 1 addition & 1 deletion api-examples/filename-check/filename-2.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
mh = Message_Handler()
sm = Source_Manager(mh)

# Read all .rsl, .check, and .trlc files
# Read all .rsl and .trlc files
# in the given directory
sm.register_directory(".")

Expand Down
2 changes: 1 addition & 1 deletion api-examples/filename-check/filename-3.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
mh = Message_Handler()
sm = Source_Manager(mh)

# Read all .rsl, .check, and .trlc files
# Read all .rsl and .trlc files
# in the given directory
sm.register_directory(".")

Expand Down
2 changes: 1 addition & 1 deletion api-examples/filename-check/filename-4.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
mh = Message_Handler()
sm = Source_Manager(mh)

# Read all .rsl, .check, and .trlc files
# Read all .rsl and .trlc files
# in the given directory
sm.register_directory(".")

Expand Down
13 changes: 9 additions & 4 deletions documentation/TUTORIAL-CI.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,17 @@ only). It is strongly suggested to turn this on in CI.

The TRLC tool goes beyond what the language definition requires and
produces additional messages that may be helpful. For example it warns
you about deprecated language features:
you if you're trying to unconditionally dereference an optional
component in a check.

```
checks MyType {
^^^^^^ enum-ok/checks.check:4: issue: move this check block into bar.rsl:1 [deprecated_feature]
Processed 1 model, 1 check and 1 requirement file and found 1 warning
len(description) >= 10, "too short"
^^^^^^^^^^^ evaluation_of_null.rsl:8: issue: expression could be null [vcg-evaluation-of-null]
| example record_type triggering error:
| Requirement bad_potato {
| /* description is null */
| }
Processed 1 model and 0 requirement files and found 1 warning
```

## Return code
Expand Down
1 change: 0 additions & 1 deletion documentation/TUTORIAL-INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,5 @@ it is better than nothing.
(add-hook 'trlc-mode-hook 'flyspell-buffer)
(add-to-list 'auto-mode-alist '("\\.rsl\\'" . trlc-mode))
(add-to-list 'auto-mode-alist '("\\.check\\'" . trlc-mode))
(add-to-list 'auto-mode-alist '("\\.trlc\\'" . trlc-mode))
```
12 changes: 5 additions & 7 deletions documentation/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ however there is significant overlap in dataflow.
determines the file set to process and mode of operation.

* The Source_Manager registers files and decides on the parse
order. For all modes of operation all `.rsl` files are parsed first,
and then all `.check` files.
order. For all modes of operation all `.rsl` files are parsed first.

* Then (unless `--no-lint` mode is active) the
[lint.py](../trlc/lint.py) and [vcg.py](../trlc/vcg.py) modules are
Expand Down Expand Up @@ -184,9 +183,9 @@ the `Source_Manager`.
message.

* During this we build a dependency graph, for each package we create
three nodes in a graph: a rsl node, a check node, and a trlc
node. Initially we link the check to the rsl; and the trlc to both
the check and rsl.
two nodes in a graph: a rsl node (representing the `.rsl` file) and
a trlc node (representing the set of all `.trlc` files for that
package). Initially we link the the trlc node to the rsl node.

* When we resolve imports we then add links in this graph. Note that
an import in an RSL only links to the RSL node of the imported
Expand All @@ -197,8 +196,7 @@ the `Source_Manager`.
all explicitly requested items.

* We then use that to expand into a final file list that is
required. Note that for check nodes, all check files are included,
and similarly for trlc nodes all trlc files are included.
required. Note that for trlc nodes all trlc files are included.

### Lexer and Parser overview

Expand Down
14 changes: 6 additions & 8 deletions documentation/linter.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,12 @@ abstract type T {

#### deprecated_feature

Some features in TRLC are deprecated, that are scheduled to be removed
for version 2.0.0. The linter can notify you when you're using such a
construct, and how it should be done in the future. Right now these
two features are:

* `.check` files (just move the check blocks into the `.rsl` file)
* The legacy `trlc:len` style of builtin functions (just use
e.g. `len` instead)
Some features in TRLC can be deprecated as the language
evolves. Features that are scheduled to be removed for version 3.0.0
are flagged by the linter. The linter can notify you when you're using
such a construct, and how it should be done in the future.

Currently there are no deprecated features in TRLC.

#### separator_based_literal_ambiguity

Expand Down
2 changes: 1 addition & 1 deletion index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ First you need to create a source manager and feed it files::
mh = Message_Handler()
sm = Source_Manager(mh)

# Read all .rsl, .check, and .trlc files
# Read all .rsl and .trlc files
# in the given directory
sm.register_directory("path/to/trlc_files")

Expand Down
76 changes: 23 additions & 53 deletions language-reference-manual/lrm.trlc
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package LRM

Versioning Version {
major = 2
minor = 9
major = 3
minor = 0
}

GFDL_License License {
Expand All @@ -24,8 +24,8 @@ section "Design Goals" {
requirements.''',
'''Language design should be extensible and flexible for future
changes.''',
'''Requirement files (but not necessarily model and check
files) should be human-readable with minimal
'''Requirement files (but not necessarily model) should
be human-readable with minimal
training or understanding of the language.''',
'''No business logic should be encoded in the language design.'''
]
Expand Down Expand Up @@ -206,22 +206,18 @@ section "Lexing" {
section "Layout and file structure" {

Text Layout {
text = "There are three types of files:"
text = "There are two types of files:"
bullets = [
'''`.rsl` They contains the user-defined type definitions and
optionally user-defined warnings or checks''',
'''(deprecated) `.check` They contain only user-defined warning
or error messages for types declared in `.rsl`
files''',
'''`.trlc` They contain instances of the types (this is where
your requirements go)'''
]
}

Dynamic_Semantics File_Parsing_Order {
text = '''
First, all `.rsl` files are parsed. Then, if no errors are
raised, all `.check` files are parsed. Finally, if no errors
First, all `.rsl` files are parsed. Then, if no errors
are raised, all `.trlc` files are parsed.
'''
}
Expand Down Expand Up @@ -360,7 +356,8 @@ section "Metamodel (RSL) files" {
"len",
"startswith",
"endswith",
"matches"
"matches",
"oneof"
]
}

Expand Down Expand Up @@ -791,43 +788,6 @@ section "Type declarations" {

}

section "Check Files" {

Grammar Check_File {
text = '''A `.check` file is simply a set of check blocks.'''
bnf = '''
check_file ::= file_preamble
{ check_block }
'''
}

Static_Semantics Cannot_Declare_In_Check_File {
text = '''It is an error to indicate a package that has not been
declared in an `.rsl` file.'''
}

Static_Semantics Import_In_Check {
text = '''A check file may not import any packages.'''
}

Recommendation Deprecated_Check_Files {
text = '''Check files are a deprecated feature that allows you to
specify checks separate from type
declarations. While this seems like a good
idea at first, in a large project this can
create confusion: consider a global definition
for your requirement type stored in a central
place which everyone is supposed to use. In
this example some random user can create in
their sub-project a check file that applies to
the global definitions, causing hassle for
everyone. It is recommended that an
implementation suggests moving any check from
a `.check` file into the package `.rsl` file.'''
}

}

section "Checks" {

Grammar Check_Block {
Expand Down Expand Up @@ -867,10 +827,7 @@ section "Checks" {

Note Only_Current_Package {
text = '''Note that it is never possible to add checks to a type from
a foreign package. In check files this is more
obvious as you cannot have an import clause,
but this is also true for checks declared in
`.rsl` files since it is not possible to
a foreign package since it is not possible to
specify a qualified name.'''
}

Expand Down Expand Up @@ -1104,7 +1061,7 @@ section "Names" {

parameter_list ::= expression { ',' expression }
'''
text = '''A name can be one of 5 things:'''
text = '''A name can be one of four things:'''
bullets = [
'''A qualified name referring to either some object, a component
(in a record) or field (in a tuple), or an enumeration type.''',
Expand Down Expand Up @@ -1177,6 +1134,14 @@ section "Names" {
variable.'''
}

Static_Semantics Signature_OneOf {
text = '''
The builtin function `oneof` is of arity >= 1. Its
parameter(s) must be of type `Boolean`. The return
type is `Boolean`.
'''
}

Static_Semantics Signature_Type_Conversion {
text = '''The numeric type conversion functions are of arity 1 and
polymorphic (they are defined for both integer and
Expand Down Expand Up @@ -1208,6 +1173,11 @@ section "Names" {
the second parameter.'''
}

Dynamic_Semantics OneOf_Semantics {
text = '''The `oneof` function returns true iff exactly one of its
parameters is true, and all others are false.'''
}

Dynamic_Semantics Integer_Conversion_Semantics {
text = '''The `Integer` type conversion rounds to the nearest
integral, away from zero in the case of ties.'''
Expand Down
Loading

0 comments on commit 39b4e36

Please sign in to comment.