Skip to content

Add a way to mark a field as raw text #3

Open

Description

@Trosper3

Problem

Once #2 makes SPADE skip whitespace around separators, some fields need their whitespace kept exactly. Edit Distance's strings and Lossless Data Compression's text are free text, where a space next to a comma can be real data.

Wanted

  • A way for the grammar to mark a field as raw text, so whitespace in it is kept exactly and its line breaks aren't treated as wraps.

Redux context

Activity

  1. Trosper3 commented on Oct 1, 2026

    @Trosper3
    ContributorAuthor

    Design: raw text in instances

    A proposal for this issue, for feedback before any code is written.

    Where this stands

    • The two free-text problems in Redux, Edit Distance and Lossless Data Compression, don't parse their instances through SPADE today. Redux reads them by hand and only trims the ends. So the new whitespace handling in feat(parser): read instance strings in one pass, with clear errors #16 doesn't affect them, and nothing in Redux needs this right now.
    • It becomes needed if those instances move onto SPADE, or if any value needs a comma, brace or parenthesis inside it, such as a city called Washington, D.C..

    Why a marker in the definition string doesn't work

    This issue originally proposed marking a field as raw text in the definition string. But the instance string is read before the definition string is applied (#17 works around this for multisets by keeping extra information). For raw text, the reader can't find where a value ends: in ("kitten, sat",sitting) it has no way to know that the first comma is part of the text.

    Proposal: quoted values

    A value in double quotes is read exactly as written:

    ("kitten, sat", "sitting")      a list of two values: kitten, sat   and   sitting
    {"New York", "Washington, D.C."}
    
    • Everything between the quotes is kept: commas, braces, parentheses, spaces, tabs and line breaks. None of the whitespace rules from Ignore whitespace that isn't part of a value #2 apply inside quotes.
    • \" is a quote and \\ is a backslash inside a quoted value.
    • The quotes aren't part of the value: "abc" and abc are the same value.
    • Values without quotes work exactly as today.
    • An unclosed quote is a SpadeParseException, e.g. expected " at position 14, found end of input.

    This is a small change to the reader (InstanceScanner) only. It needs no grammar change, and works the same whether or not a definition string is used.

    Compatibility

    " is an ordinary value character today, so a value that contains one would read differently. No Redux default instance or certificate example contains ".

    Open questions

    1. Is this needed now, or should it wait until Edit Distance or Lossless Data Compression move onto SPADE?
    2. Should ToString() add quotes back around values that need them, so the output can be read in again? (That belongs with (Low Priority) Write values back out in the same format #8.)
  2. added this to the 0.3.0 milestone on Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions