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

Error Handling for Empty Encoding Type Containers in LDF Files #138

Open
eslam69 opened this issue May 8, 2024 · 0 comments · May be fixed by #139
Open

Error Handling for Empty Encoding Type Containers in LDF Files #138

eslam69 opened this issue May 8, 2024 · 0 comments · May be fixed by #139
Labels
bug Something isn't working

Comments

@eslam69
Copy link

eslam69 commented May 8, 2024

Describe the bug
Error when reading an ldf with and empty encoding type container in Signal_encoding_types, I want to mention that Vector's tool LDF explorer can handle this case, Can we support this use case, I think the tool might just ignore that encoding type container and continue parsing the file.
To Reproduce
Steps to reproduce the behavior:

  1. read an ldf file with any empty encoding type like this
Signal_encoding_types {
  empty_type{
    
  }
}
  1. you get error as the following:
ContextualLexer.lex(self, lexer_state, parser_state)
    [672](file:///C:/Python312/Lib/site-packages/lark/lexer.py:672)     last_token = lexer_state.last_token  # Save last_token. Calling root_lexer.next_token will change this to the wrong token
    [673](file:///C:/Python312/Lib/site-packages/lark/lexer.py:673)     token = self.root_lexer.next_token(lexer_state, parser_state)
--> [674](file:///C:/Python312/Lib/site-packages/lark/lexer.py:674)     raise UnexpectedToken(token, e.allowed, state=parser_state, token_history=[last_token], terminals_by_name=self.root_lexer.terminals_by_name)
    [675](file:///C:/Python312/Lib/site-packages/lark/lexer.py:675) except UnexpectedCharacters:
    [676](file:///C:/Python312/Lib/site-packages/lark/lexer.py:676)     raise e

UnexpectedToken: Unexpected token Token('RBRACE', '}') at line 227, column 3.
Expected one of: 
	* BCD_VALUE
	* PHYSICAL_VALUE
	* LOGICAL_VALUE
	* ASCII_VALUE
Previous tokens: [Token('LBRACE', '{')]

Expected behavior
I was expecting the parser to ignore empty containers.

Environment:

  • OS: Windows 11
  • Python version: 3.12.0
  • ldfparser version: 0.25.0
pipdeptree --warn silence -p ldfparser
ldfparser==0.25.0
├── bitstruct [required: Any, installed: 8.19.0]
├── Jinja2 [required: Any, installed: 3.1.3]
│   └── MarkupSafe [required: >=2.0, installed: 2.1.5]
└── lark [required: >=1,<2, installed: 1.1.9]

I am willing to contribute to implementing this solution if requested.

@eslam69 eslam69 added the bug Something isn't working label May 8, 2024
@c4deszes c4deszes linked a pull request May 19, 2024 that will close this issue
11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant