aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/syntax.rs
diff options
context:
space:
mode:
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());
+ }
+}