Expand description
A library for running Dyck algorithms over languages of generic
This module provides functionalities to create and manipulate languages based on user-defined tokens, allowing for the evaluation and transformation of sequences of tokens (words) according to the rules of Dyck languages.
§Usage
Add dyck to your Cargo.toml:
[dependencies]
dyck = "0.1"§Example: Creating a Dyck language and checking if a word is valid.
use dyck::{Language, Word};
// define pairs of tokens for the language
let pairs = vec![("(", ")"), ("[", "]"), ("{", "}")];
let language = Language::new_from_vec(&pairs).expect("Failed to create language");
// define a word to check
let word: Word<&str> = vec!["(", "[", "]", "(", ")", ")"];
// check if the word is a valid Dyck word
if language.is_valid(&word) {
println!("The word is a valid Dyck word.");
} else {
println!("The word is not a valid Dyck word.");
}See /examples in the repository root for more examples.
Structs§
- Language
- Stores the context to be used to run algorithms on potential dyck words.
Traits§
- Dyck
Token - A trait implementable by user-defined enums to gain compatiblity with all Dyck functions. This trait alias is available as a derive macro via the derive feature.
Type Aliases§
- Word
- A word is a sequence of tokens to be evaluated relative to a Dyck language. It is not necessarily a dyck word, just a dyck candidate.