Allow backslashes in quoted strings (Windows paths); v0.3.6 - #6
Merged
Conversation
The HIT lexer excluded backslash from single- and double-quoted string
content (the `\\` in the IN_ARRAY / IN_DARRAY character classes), so a
value like 'C:\Users\me\model' failed to parse ("unexpected character
'\'"). That makes Windows paths unrepresentable in a HIT file -- the root
cause behind neml2's Windows workarounds (issue #414), which had to
forward-slash every path written into a stub .i.
Drop backslash from those two character classes so it is a literal inside
quoted strings (no escaping semantics; a single-quoted value is raw). Only
the lexer's DFA tables change; regenerated generated/Lexer.cpp with the same
flex 2.6.4 + flags the build uses (Parser untouched). Triple-quoted strings
already accepted backslashes; unquoted values are unchanged (quote paths).
Adds a C++ and a Python test for a backslash path in both quote styles.
…latforms Reflect the lexer change (array/quoted-string elements may now contain backslashes, so Windows paths are representable) and state that nmhit builds and is tested on Linux, macOS, and Windows (GCC/Clang/MSVC).
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.
Problem
The HIT lexer excluded backslash from single- and double-quoted string content (the
\\in theIN_ARRAY/IN_DARRAYcharacter classes), so a value like'C:\Users\me\model'failed withunexpected character '\'. That makes Windows paths unrepresentable in a HIT file — the root cause behind neml2's Windows workarounds (applied-material-modeling/neml2#414), which currently forward-slash every path written into a compiled stub.i.Fix
Drop backslash from those two character classes so it's a literal inside quoted strings. A single-quoted value is raw (no escaping semantics), so
'C:\Users\me\model'now tokenises as the literal string. Backward-compatible — it only accepts more input.generated/Lexer.cppregenerated with the same flex 2.6.4 + flags the build uses (--noline),#linestripped. Parser untouched.test_hit.cpp) and a Python (test_nmhit.py) test for a backslash path in both quote styles.Verified locally on Linux (C++ ctest + 28 Python tests). Windows CI covers it too.
After merge
Tag v0.3.6 to publish the wheels, then neml2 can bump its
nmhitpin and revert its interim forward-slash workarounds (theINTERIM (nmhit-backslash)markers).🤖 Generated with Claude Code