public static object DefineSymbolMacro(Symbol sym, SymbolMacro value, string doc) { EraseVariable(sym); sym.SymbolMacroValue = value; sym.CompilerDocumentation = doc; return(sym); }
public static Expression CompileDefineSymbolMacro(Cons form, AnalysisScope scope) { // define-compiler name form CheckLength(form, 3); var sym = CheckSymbol(Second(form)); if (sym.IsDynamic) { throw new LispException("Invalid symbol-macro name: {0}", sym); } WarnWhenShadowing(sym); string doc = ""; var macro = new SymbolMacro(Third(form)); return Expression.Call(DefineSymbolMacroMethod, Expression.Constant(sym), Expression.Constant(macro), Expression.Constant(doc, typeof(string))); }
public static object DefineSymbolMacro(Symbol sym, SymbolMacro value, string doc) { EraseVariable(sym); sym.SymbolMacroValue = value; sym.CompilerDocumentation = doc; return sym; }
public static Expression CompileLetSymbolMacro(Cons form, AnalysisScope scope) { // let-symbol-macro name form CheckLength(form, 3); CheckMinLength(form, 3); var sym = CheckSymbol(Second(form)); if (sym.IsDynamic) { throw new LispException("Invalid symbol-macro name: {0}", sym); } if (!scope.IsBlockScope) { throw new LispException("Statement requires block or file scope: {0}", form); } if (sym == Symbols.Tilde) { throw new LispException("\"~\" is a reserved symbol name"); } if (scope.FindDuplicate(sym)) { throw new LispException("Duplicate declaration of variable: {0}", sym); } var macro = new SymbolMacro(Third(form)); scope.DefineMacro(sym, macro, ScopeFlags.SymbolMacro | ScopeFlags.All); return Expression.Constant(null); }