Skip to content
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

Adds step_in and step_out to the text reader #332

Merged
merged 6 commits into from
Oct 13, 2021
Merged

Conversation

zslayton
Copy link
Contributor

This depends on the changes in PR #331. When 331 is merged, this PR will be rebased against it.

Changes:

  • Creates a new type, ParentContainer, to represent levels of
    depth in the data.
  • Adds step_in, step_out, and field_name methods that can
    be used to traverse text Ion data of any shape.
  • Adds logic to skip over the rest of a container as needed when
    next and step_out are called.

A future PR will modify the reader so it implements the Cursor trait (i.e. system reader). This means that next() will no longer return an AnnotatedTextValue (which will be a private type); it will instead return an IonType indicating what was found in the stream. Users can then call functions like read_i64 to get at the values themselves.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

* Removes non-value variants from the `TextStreamItem` enum,
  including `ListEnd`, `SExpressionEnd`, `StructEnd`, `Comment`,
  and `EndOfStream`.
* Adds container item parsing rules that return a `None` if an
  end-of-container delimiter is found instead of a value.
* Adds methods to the reader for parsing container values. These
  methods will eventually be private helper methods called by
  `next()`. For the moment, users must call them manually.
* Makes the `parse_test_ok` and `parse_test_err` unit test helper
  methods generic, allowing them to be used in more places.

Fixes #328.
* Now that `TextStreamItem` only represents Ion values (and not
  comments, container ends, or EOF), it has been renamed to
  `TextValue`.
* The pervasive tuple type `(Vec<OwnedSymbolToken>, TextStreamItem)`
  has been replaced by an `AnnotatedTextValue` struct that combines
  a `TextValue` with an `Vec<OwnedSymbolToken>`. It also provides
  helper methods for construction and conversions.
* Several parser names have been simplified by removing `recognize_`
  and `parse_` as prefixes. This is part of the work needed to
  address #327.
* Replaced `stream item` in variable/method names with `value`.

Fixes #330.
* Creates a new type, `ParentContainer`, to represent levels of
  depth in the data.
* Adds `step_in`, `step_out`, and `field_name` methods that can
  be used to traverse text Ion data of any shape.
* Adds logic to skip over the rest of a container as needed when
  `next` and `step_out` are called.
Base automatically changed from text-value to main October 13, 2021 21:25
Copy link
Contributor

@desaikd desaikd left a comment

Choose a reason for hiding this comment

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

We can add comments for methods in ParentContainer and a valid test case in the unit tests. Otherwise looks good!

@zslayton
Copy link
Contributor Author

We can add comments for methods in ParentContainer and a valid test case in the unit tests.

Will do!

@zslayton zslayton merged commit 6bc8069 into main Oct 13, 2021
@zslayton zslayton deleted the step-in-step-out branch October 13, 2021 21:47
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