Repository navigation
fix: parse single-quoted values as backward-compat containers (#5, partial) - #33
Merged
Merged
Conversation
The old Fortran/C reader treated ', " and {} as equivalent quote containers,
but the new implementation had dropped ' support. Real-world files using e.g.
`pbc='F F F'` therefore failed: the pure-Python backend raised, and the C
backend silently fell back to defaults (losing the value).
Add ' as a quote container equivalent to " in the grammar (ints/floats/bools,
no strings) — one source of truth, since python/extxyz/extxyz_kv_grammar.py is
a symlink to grammar/extxyz_kv_grammar.py and the C grammar is generated from
it. Both tree walkers dispatch on OLD_ONE_D_ARRAY + content type, so no parser
code change was needed.
`'1 2 3'` -> int array, `'3'` -> scalar 3, `pbc='F F F'` -> [F,F,F]; `'hello'`
stays a bare string (non-numeric). The string-only single-quote container
(writer-side disambiguation) remains deferred as the larger issue #5 design.
README spec updated; new tests cover both backends; ase-extxyz suite + leaks
clean.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The old Fortran/C extxyz reader treated
',"and{}as equivalent quote containers, but the new implementation dropped'support. Real-world files using e.g.pbc='F F F'(see issue #8's example) therefore failed:SyntaxErrorpbcwrongly became all-true)This restores
'as a quote container equivalent to"— ints/floats/bools, no strings:pbc='F F F'pbc = [F, F, F]k='1 2 3'[1, 2, 3]k='3'3k='hello''hello'(unchanged — not numeric)'and"now behave identically, on both backends.How
One-line grammar change in
grammar/extxyz_kv_grammar.py(adds a'…'Sequencetoold_one_d_array).python/extxyz/extxyz_kv_grammar.pyis a symlink to it and the C grammar is generated from it, so there's a single source of truth. Both tree walkers (parse_treeinextxyz.c, the pyleri visitor) dispatch onOLD_ONE_D_ARRAY+ content type rather than the quote character, so no parser code change was needed. README spec updated.Scope
This is the parser-only part of #5, per maintainer decision. The larger #5 proposal — a string-only single-quote container with writer-side disambiguation so strings that look like arrays round-trip — remains deferred (the thread never reached consensus: single-quote-as-string vs
{"…"}). This PR deliberately does not close #5.Verification
tests/test_single_quote.py— 10 cases, both backends.leaksclean on a single-quote file; C driver parsespbc/kcorrectly.🤖 Generated with Claude Code