Skip to content

Write component definitions that read back as written (#391) - #396

Merged
g5t merged 2 commits into
mainfrom
comp-to-string-roundtrip
Oct 18, 2026
Merged

g5t merged 2 commits into
mainfrom
comp-to-string-roundtrip

Conversation

@g5t

@g5t g5t commented Oct 18, 2026

Copy link
Copy Markdown
Collaborator

mccode-antlr extract reconstitutes components with Comp.to_string, which wrote text the parser rejected or read differently:

  • DEPENDENCY came straight after DEFINE COMPONENT, but the grammar wants it after the parameters and metadata, so any component with one failed to parse (22 of the McStas components).
  • NOACC was never written.
  • vector, double * and int * parameters lost their type and default, initializer lists their braces; an archaic symbol came back as a string with an unquoted default.
  • Every block, and every METADATA, gained a blank line each time it was written and read, in instruments and instances (EXTEND) too, since they share the text wrapper.

Every McStas and McXtrace component the reader accepts now reads back with the same parameters, metadata, flags and blocks, and writes identically a second time. Classic mcstas translates extracted bundles to the same C, apart from number formatting and a string default of 0 kept as NULL.

Fixes #391

g5t added 2 commits October 18, 2026 18:07
`mccode-antlr extract` reconstitutes components with Comp.to_string, which
wrote text the parser rejected or read differently:

- DEPENDENCY came straight after DEFINE COMPONENT, but the grammar wants it
  after the parameters and metadata, so any component with one failed to
  parse (22 of the McStas components).
- NOACC was never written.
- `vector`, `double *` and `int *` parameters lost their type and default,
  initializer lists their braces; an archaic `symbol` came back as a string
  with an unquoted default.
- Every block, and every METADATA, gained a blank line each time it was
  written and read, in instruments and instances (EXTEND) too, since they
  share the text wrapper.

Every McStas and McXtrace component the reader accepts now reads back with
the same parameters, metadata, flags and blocks, and writes identically a
second time. Classic mcstas translates extracted bundles to the same C,
apart from number formatting and a string default of 0 kept as NULL.
@g5t
g5t merged commit 7335f27 into main Oct 18, 2026
12 checks passed
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.

mccode-antlr extract reconstitues comp files incorrectly

1 participant