Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detecting duplicated components #121

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

phiwuu
Copy link
Member

@phiwuu phiwuu commented Dec 12, 2024

Add check to detect duplicated components of a record when parsing a TRLC file.

Example:

Something duplicated
{
	description = "This is fine!"
	description = "This is the duplicate."
}

The behavior of the Record_Object class is changed such that the assign method only assigns components to the record if it has not been assigned already. This is implemented by checking if the field type is different from Implicit_Null.

The Parser class asks the Record_Object if the component is Implicit_Null. If no, then an error is sent to the message handler.

@phiwuu phiwuu requested a review from a team as a code owner December 12, 2024 11:02
Add check to detect duplicated components of a record
when parsing a TRLC file.

Example:
```
Something duplicated
{
	description = "This is fine!"
	description = "This is the duplicate."
}
```

The behavior of the `Record_Object` class is changed such that the `assign` method only
assigns components to the record if it has not been assigned already.
This is implemented by checking if the field type is different from `Implicit_Null`.

The `Parser` class asks the `Record_Object` if the component is `Implicit_Null`.
If no, then an error is sent to the message handler.
@phiwuu phiwuu force-pushed the feature/detect_duplicate_components branch from ad15258 to debad86 Compare December 12, 2024 11:03
Diego Fernandez added 11 commits December 13, 2024 09:24
(venv) qxz0tge@cmucr000556:~/Repos/trlc$  cd /home/qxz0tge/Repos/trlc ; /usr/bin/env /home/qxz0tge/Repos/trlc/venv/bin/python /home/qxz0tge/.vscode/extensions/ms-python.debugpy-2024.14.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher 43939 -- /home/qxz0tge/Repos/trlc/trlc.py /home/qxz0tge/Repos/trlc_test_duplicate
DEBUG: Current value of description: <trlc.ast.Implicit_Null object at 0x7f2b48c61930>
DEBUG: Current value of critical: <trlc.ast.Implicit_Null object at 0x7f2b48c61990>
DEBUG: Current value of critical: <trlc.ast.Implicit_Null object at 0x7f2b48c62d70>
DEBUG: Current value of description: <trlc.ast.Implicit_Null object at 0x7f2b48c625c0>
critical    = true
^^^^^^^^ /home/qxz0tge/Repos/trlc_test_duplicate/lrm_dummy.trlc:10: error: component 'critical' already assigned at line 8
DEBUG: Current value of description: <trlc.ast.Implicit_Null object at 0x7f2b48c63190>
DEBUG: Current value of critical: <trlc.ast.Implicit_Null object at 0x7f2b48c63130>
DEBUG: Current value of description: <trlc.ast.Implicit_Null object at 0x7f2b48c635b0>
DEBUG: Current value of critical: <trlc.ast.Implicit_Null object at 0x7f2b48c63610>
description = "This is not fine anymore"
^^^^^^^^^^^ /home/qxz0tge/Repos/trlc_test_duplicate/lrm_dummy.trlc:19: error: component 'description' already assigned at line 17
Processed 1 model and 1 requirement file and found 2 errors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant