Skip to content

Conversation

@kparzysz-quic
Copy link
Contributor

@kparzysz-quic kparzysz-quic commented Jul 21, 2022

  • SplitString now preserves escape sequences, but still observes quote characters.
  • Added function Interpret that transforms given string according to interpretation rules:
    • outermost quotes are removed (if present),
    • escape sequences inside quotes are preserved verbatim,
    • unquoted escape sequences produce the escaped character (the escape character (\) is removed.
  • Interpretation happens every time a value of any type is to be parsed from a string, e.g. Array will first be parsed as an array, then substrings of the input will be parsed as individual elements of that array. In this case, some parts of the initial input will be parsed (and interpreted) twice.
  • Implement corresponding stringification functionality.

This new scheme enabled encoding nested arrays of string with any degree of nesting. For example

"-field='\\'foo0\\',\\'bar0,bar1\\'','\\'zing0,zing1\\',\\'fred\\''"

would correspond to the target kind attribute

Array<Array<Array<String>>>("field"))

and have the value

{ { {foo0}, {bar0, bar1} }, { {zing0, zing1}, {fred} } }

@kparzysz-quic kparzysz-quic requested review from Lunderberg, Mousius and junrushao and removed request for Lunderberg and Mousius July 21, 2022 17:32
- SplitString now preserves escape sequences, but still observes
  quote characters.
- Added function Interpret that transforms given string according
  to interpretation rules:
  - outermost quotes are removed (if present),
  - escape sequences inside quotes are preserved verbatim,
  - unquoted escape sequences produce the escaped character (the
    escape character (\) is removed.
- Interpretation happens every time a value of any type is to be
  parsed from a string, e.g. Array<String> will first be parsed
  as an array, then substrings of the input will be parsed as
  individual elements of that array. In this case, some parts of
  the initial input will be parsed (and interpreted) twice.
- Implement corresponding stringification functionality.

This new scheme enabled encoding nested arrays of string with any
degree of nesting. For example
  "-field='\\'foo0\\',\\'bar0,bar1\\'','\\'zing0,zing1\\',\\'fred\\''"
would correspond to the target kind attribute
  Array<Array<Array<String>>>("field"))
and have the value
 { { {foo0}, {bar0, bar1} }, { {zing0, zing1}, {fred} } }
@kparzysz-quic kparzysz-quic requested a review from areusch July 25, 2022 15:33
Copy link
Contributor

@areusch areusch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

implementation looks fine--one question, do we want to enable all of these nested Array<Array<Array>> in target? it feels like we are reaching more for a structured thing.

@kparzysz-quic
Copy link
Contributor Author

Short answer: no.

This came up when I was working on adding llvm-options to llvm target. That is going to be Array<String>, but I wanted a robust way of embedding arbitrary strings as option values, so that we don't place any restrictions there. So I thought about how to encode string within a string, etc, especially in a context of an array of strings. This is the result.

@kparzysz-quic kparzysz-quic merged commit 7b6cb60 into apache:main Jul 27, 2022
@kparzysz-quic kparzysz-quic deleted the llvm-target-cmdline branch July 27, 2022 22:09
xinetzone pushed a commit to daobook/tvm that referenced this pull request Nov 25, 2022
- SplitString now preserves escape sequences, but still observes
  quote characters.
- Added function Interpret that transforms given string according
  to interpretation rules:
  - outermost quotes are removed (if present),
  - escape sequences inside quotes are preserved verbatim,
  - unquoted escape sequences produce the escaped character (the
    escape character (\) is removed.
- Interpretation happens every time a value of any type is to be
  parsed from a string, e.g. Array<String> will first be parsed
  as an array, then substrings of the input will be parsed as
  individual elements of that array. In this case, some parts of
  the initial input will be parsed (and interpreted) twice.
- Implement corresponding stringification functionality.

This new scheme enabled encoding nested arrays of string with any
degree of nesting. For example
  "-field='\\'foo0\\',\\'bar0,bar1\\'','\\'zing0,zing1\\',\\'fred\\''"
would correspond to the target kind attribute
  Array<Array<Array<String>>>("field"))
and have the value
 { { {foo0}, {bar0, bar1} }, { {zing0, zing1}, {fred} } }
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.

2 participants