amazon-ion / ion-schema-rust

Rust implementation of Ion Schema
https://amazon-ion.github.io/ion-schema/sandbox
Apache License 2.0
13 stars 6 forks source link

adds a state machine implementation for `ordered_elements` constraint #149

Closed desaikd closed 1 year ago

desaikd commented 1 year ago

Issue #56:

Description of changes:

This PR works on adding an NFA state machine for validating ordered_elements constraint.

List of changes:


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

desaikd commented 1 year ago

As per an offline discussion, moving all the information to Transition instead of State resolves the weirdness around entry/exit condition checks on states instead having those checks to see if we can take a given transition or not.

List of change:

QQ: Should we still keep the Initial and Final state? or at least an initial state? (I have added a transition to itself for the initial state in order to start the validation process from initial state. Another option would be to perform an initial transition for state_id = 0 and visits = 0 explicitly).

QQ: Should we add a transition that skips optional states while building NFA? (If we have an initial state then we can remove the recursive calls for optional states to get all possible transitions. And simply add a transition that skips all optional states in the build process) - reference discussion https://github.com/amazon-ion/ion-schema-rust/pull/149#discussion_r1119360000