summaryrefslogtreecommitdiffstats
path: root/crates/rebel-lang/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/rebel-lang/src/lib.rs')
-rw-r--r--crates/rebel-lang/src/lib.rs36
1 files changed, 36 insertions, 0 deletions
diff --git a/crates/rebel-lang/src/lib.rs b/crates/rebel-lang/src/lib.rs
new file mode 100644
index 0000000..001bb79
--- /dev/null
+++ b/crates/rebel-lang/src/lib.rs
@@ -0,0 +1,36 @@
+use std::fmt::Display;
+
+pub mod func;
+pub mod scope;
+pub mod typing;
+pub mod value;
+
+#[derive(Debug)]
+pub struct Error(pub &'static str, pub &'static str);
+
+impl Error {
+ pub fn lookup(text: &'static str) -> Self {
+ Self("Lookup", text)
+ }
+
+ pub fn typ(text: &'static str) -> Self {
+ Self("Type", text)
+ }
+
+ pub fn eval(text: &'static str) -> Self {
+ Self("Eval", text)
+ }
+
+ pub fn bug(text: &'static str) -> Self {
+ Self("BUG", text)
+ }
+}
+
+impl Display for Error {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ let Error(cat, text) = self;
+ write!(f, "{cat} error: {text}")
+ }
+}
+
+pub type Result<T> = std::result::Result<T, Error>;