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

Fix problems identified in McStas example instrument tests #72

Merged
merged 7 commits into from
Sep 25, 2024
Merged

Conversation

g5t
Copy link
Collaborator

@g5t g5t commented Sep 25, 2024

Various fixes to WHEN, using more-correct C99 grammar, parsing of types for DECLARE blocks.

In order to insert DECLARE variables into the component-type parameters
struct, we need to be able to identify their type information.
These types _could_ be user-defined `typedef` aliases, provided in,
e.g., the SHARE section of the current or any-other component (probably
preceding only, but possibly trailing definitions, since SHARE goes
before all initialization).

Previously parsing for both variable declaration and typedefs was
performed in one pass, but this led to a confusing Listener class which
mistakenly identified typenames for `typedef` `struct`s incorrectly,
sometimes.
E.g.,

```
typdef struct the_struct_label {
    double a_double;
    int an_int;
} the_struct_alias;
```
would have been misidentified as the equivalent of
`typedef struct the_struct_label an_int;`

By splitting `typedef` and declaration parsing into two passes, there
are now two slightly-simpler Listener classes that handle the above case
plus all others implemented in a new test file.
This double-pass invariably means slower parsing, but this seems a
worthwhile trade-off at the moment.
@g5t g5t merged commit e4d99cd into main Sep 25, 2024
14 checks passed
@g5t g5t deleted the issue-68-cont branch September 25, 2024 15:08
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