Add "!" syntatic form - a bit like the single quote, but !(a b c) d => !(a b c d). Useful for like !(let a 1) (+ a 3) or w/e. Break out some of the infinate nesting"

This commit is contained in:
2023-02-10 01:01:04 -05:00
parent 3b5cc2c506
commit ba67b8c67b
3 changed files with 18 additions and 6 deletions

View File

@@ -9,6 +9,9 @@ pub Term: Form = {
SYM => Form::Symbol(<>.to_owned()),
"(" <ListInside?> ")" => <>.unwrap_or(Form::Nil),
"'" <Term> => Form::Pair(Rc::new(Form::Symbol("quote".to_owned())), Rc::new(Form::Pair(Rc::new(<>), Rc::new(Form::Nil)))),
"!" <h: Term> <t: Term> => {
h.append(Rc::new(t)).unwrap()
},
};
ListInside: Form = {
<Term> => Form::Pair(Rc::new(<>), Rc::new(Form::Nil)),
@@ -20,6 +23,7 @@ match {
")",
".",
"'",
"!",
r"[0-9]+" => NUM,
r"[a-zA-Z+*/_=?%&|^-][\w+*/=_?%&|^-]*" => SYM,
r"(;[^\n]*\n)|\s+" => { }