aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/syntax.rs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2025-07-19 15:24:30 +0900
committernsfisis <nsfisis@gmail.com>2025-07-19 15:41:49 +0900
commit145efc39d14c242266c574063ffcba329c62e8a3 (patch)
treea6f6e2c78b14ed97486041cd853d2140f1b659e2 /src/syntax.rs
parent6cbd16ed14ac36f8e117937fc2dc73a8a9ddb698 (diff)
downloadregulus-145efc39d14c242266c574063ffcba329c62e8a3.tar.gz
regulus-145efc39d14c242266c574063ffcba329c62e8a3.tar.zst
regulus-145efc39d14c242266c574063ffcba329c62e8a3.zip
implement parsing
Diffstat (limited to 'src/syntax.rs')
-rw-r--r--src/syntax.rs27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/syntax.rs b/src/syntax.rs
new file mode 100644
index 0000000..abf7309
--- /dev/null
+++ b/src/syntax.rs
@@ -0,0 +1,27 @@
+pub mod ast;
+pub mod parse;
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn parse_valid() {
+ assert!(parse::parse("").is_ok());
+ assert!(parse::parse("a").is_ok());
+ assert!(parse::parse("ab").is_ok());
+ assert!(parse::parse("abc").is_ok());
+ assert!(parse::parse("a|b").is_ok());
+ assert!(parse::parse("a|b*").is_ok());
+ assert!(parse::parse("(a|b)*").is_ok());
+ assert!(parse::parse("(((a|b)))*").is_ok());
+ assert!(parse::parse("a*b*").is_ok());
+ }
+
+ #[test]
+ fn parse_invalid() {
+ assert!(parse::parse("(").is_err());
+ assert!(parse::parse("()))").is_err());
+ assert!(parse::parse("(((())").is_err());
+ }
+}