-
Notifications
You must be signed in to change notification settings - Fork 0
020 subject serialization #31
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
Merged
Merged
Changes from 6 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
8bef44d
020-subject-serialization: specified and planned
akollegger 9e091f0
feat: implement round-trip serialization - US1
akollegger 063de41
feat: implement anonymous subject ID generation - US2
akollegger be516c2
feat: verify identity preservation - US3
akollegger dcc18e4
docs: finalize subject serialization feature
akollegger 2f81416
020-subject-serialization: Completed robust identity handling and rou…
akollegger 10da0bd
Initial plan
Copilot 720afbb
Update specs/020-subject-serialization/contracts/api.md
akollegger 5317b03
docs: update identity format to #<N> to match implementation
Copilot 9a77666
Merge pull request #32 from gram-data/copilot/sub-pr-31
akollegger File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -53,8 +53,8 @@ import Data.Char (isAlpha, isAlphaNum) | |||||||||||||||
|
|
||||||||||||||||
| -- | Escape special characters in strings for gram notation. | ||||||||||||||||
| -- | ||||||||||||||||
| -- Escapes quotes and backslashes in string values to ensure proper | ||||||||||||||||
| -- serialization in gram notation. | ||||||||||||||||
| -- Escapes quotes, backslashes, and control characters in string values | ||||||||||||||||
| -- to ensure proper serialization in gram notation. | ||||||||||||||||
| -- | ||||||||||||||||
| -- === Examples | ||||||||||||||||
| -- | ||||||||||||||||
|
|
@@ -63,11 +63,17 @@ import Data.Char (isAlpha, isAlphaNum) | |||||||||||||||
| -- | ||||||||||||||||
| -- >>> escapeString "He said \"Hello\"" | ||||||||||||||||
| -- "He said \\\"Hello\\\"" | ||||||||||||||||
| -- | ||||||||||||||||
| -- >>> escapeString "Line 1\nLine 2" | ||||||||||||||||
| -- "Line 1\\nLine 2" | ||||||||||||||||
| escapeString :: String -> String | ||||||||||||||||
| escapeString = concatMap escapeChar | ||||||||||||||||
| where | ||||||||||||||||
| escapeChar '"' = "\\\"" | ||||||||||||||||
| escapeChar '\\' = "\\\\" | ||||||||||||||||
| escapeChar '\n' = "\\n" | ||||||||||||||||
| escapeChar '\r' = "\\r" | ||||||||||||||||
| escapeChar '\t' = "\\t" | ||||||||||||||||
| escapeChar c = [c] | ||||||||||||||||
|
|
||||||||||||||||
| -- | Format a Symbol for gram notation. | ||||||||||||||||
|
|
@@ -177,7 +183,7 @@ serializeLabels lbls | |||||||||||||||
| | Set.null lbls = "" | ||||||||||||||||
| | otherwise = ":" ++ intercalate ":" (Set.toList lbls) | ||||||||||||||||
|
|
||||||||||||||||
| -- | Serialize a Subject to gram notation (legacy function, kept for compatibility). | ||||||||||||||||
| -- | Serialize a Subject to gram notation (legacy function, kept for compatibility). | ||||||||||||||||
| -- Note: This always uses node syntax. Use toGram for proper syntax selection. | ||||||||||||||||
| serializeSubject :: Subject -> String | ||||||||||||||||
| serializeSubject (Subject ident lbls props) = | ||||||||||||||||
|
|
@@ -186,6 +192,14 @@ serializeSubject (Subject ident lbls props) = | |||||||||||||||
| serializeLabels lbls ++ | ||||||||||||||||
| serializePropertyRecord props | ||||||||||||||||
|
|
||||||||||||||||
| -- | Serialize pattern elements for implicit root (no brackets/pipe). | ||||||||||||||||
| -- Used when serializing the top-level Gram container. | ||||||||||||||||
| -- NOTE: This function is now inlined into toGram to handle properties. | ||||||||||||||||
| -- Keeping signature for potential reuse or removing if unused. | ||||||||||||||||
| -- serializeImplicitElements :: [Pattern Subject] -> String | ||||||||||||||||
| -- serializeImplicitElements elems = | ||||||||||||||||
| -- intercalate "\n" (map toGram elems) | ||||||||||||||||
|
|
||||||||||||||||
|
Comment on lines
+195
to
+202
|
||||||||||||||||
| -- | Serialize pattern elements for implicit root (no brackets/pipe). | |
| -- Used when serializing the top-level Gram container. | |
| -- NOTE: This function is now inlined into toGram to handle properties. | |
| -- Keeping signature for potential reuse or removing if unused. | |
| -- serializeImplicitElements :: [Pattern Subject] -> String | |
| -- serializeImplicitElements elems = | |
| -- intercalate "\n" (map toGram elems) |
akollegger marked this conversation as resolved.
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.