From bfb85bf0cd7a75b910d7125c69d5e5eae2bd51c1 Mon Sep 17 00:00:00 2001 From: JSDurand Date: Fri, 4 Aug 2023 16:36:50 +0800 Subject: add a crate 'tokens' This crate is responsible for the users to conveniently define their own tokenizers. Right now the user has to tokenize the input string manually, which is not quite what is expected from a parser, from the view point of users. --- tokens/src/lib.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 tokens/src/lib.rs (limited to 'tokens/src') diff --git a/tokens/src/lib.rs b/tokens/src/lib.rs new file mode 100644 index 0000000..ba4f7ac --- /dev/null +++ b/tokens/src/lib.rs @@ -0,0 +1,20 @@ +//! This package defines the trait for tokenizers that are expected +//! from the parser. +//! +//! This is not the essential part of the package, and users might +//! want to tweak this part. + +pub fn add(left: usize, right: usize) -> usize { + left + right +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn it_works() { + let result = add(2, 2); + assert_eq!(result, 4); + } +} -- cgit v1.2.3-18-g5258