private static object MakeQuoteConstant(object expr, Sympl symplRuntime) { if (expr is SymplListExpr) { SymplListExpr listexpr = (SymplListExpr)expr; int len = listexpr.Elements.Length; var exprs = new object[len]; for (int i = 0; i < len; i++) { exprs[i] = MakeQuoteConstant(listexpr.Elements[i], symplRuntime); } return(Cons._List(exprs)); } else if (expr is IdOrKeywordToken) { return(symplRuntime.MakeSymbol(((IdOrKeywordToken)expr).Name)); } else if (expr is LiteralToken) { return(((LiteralToken)expr).Value); } else { throw new InvalidOperationException( "Internal: quoted list has -- " + expr.ToString()); } }
static void Main(string[] args) { string dllPath = typeof(object).Assembly.Location; Assembly asm = Assembly.LoadFile(dllPath); string filename = @"..\..\Src\Languages\sympl\examples\test.sympl"; var s = new Sympl(new Assembly[] { asm }); var feo = s.ExecuteFile(filename); Console.WriteLine("ExecuteExpr ... "); s.ExecuteExpr("(print 5)", feo); if (args.Length > 0 && args[0] == "norepl") return; string input = null; string exprstr = ""; Console.WriteLine(); Console.WriteLine(); Console.WriteLine(); Console.WriteLine("Enter expressions. Enter blank line to abort input."); Console.WriteLine("Enter 'exit (the symbol) to exit."); Console.WriteLine(); string prompt = ">>> "; while (true) { Console.Write(prompt); input = Console.ReadLine(); if (input == "") { exprstr = ""; prompt = ">>> "; continue; } else { exprstr = exprstr + " " + input; } // See if we have complete input. try { var ast = new Parser().ParseExpr(new StringReader(exprstr)); } catch (Exception) { prompt = "... "; continue; } // We do, so execute. try { object res = s.ExecuteExpr(exprstr, feo); exprstr = ""; prompt = ">>> "; if (res == s.MakeSymbol("exit")) return; Console.WriteLine(res); } catch (Exception e) { exprstr = ""; prompt = ">>> "; Console.Write("ERROR: "); Console.WriteLine(e); } } }
public AnalysisScope(AnalysisScope parent, string name, Sympl runtime, ParameterExpression runtimeParam, ParameterExpression moduleParam) { _parent = parent; _name = name; _runtime = runtime; _runtimeParam = runtimeParam; _moduleParam = moduleParam; _names = new Dictionary <string, ParameterExpression>(); _isLambda = false; }
public AnalysisScope(AnalysisScope parent, string name, Sympl runtime, ParameterExpression runtimeParam, ParameterExpression moduleParam) { _parent = parent; _name = name; _runtime = runtime; _runtimeParam = runtimeParam; _moduleParam = moduleParam; _names = new Dictionary<string, ParameterExpression>(); _isLambda = false; }
static void Main(string[] args) { string dllPath = typeof(object).Assembly.Location; Assembly asm = Assembly.LoadFile(dllPath); string filename = @"..\..\Src\Languages\sympl\examples\test.sympl"; var s = new Sympl(new Assembly[] { asm }); var feo = s.ExecuteFile(filename); Console.WriteLine("ExecuteExpr ... "); s.ExecuteExpr("(print 5)", feo); if (args.Length > 0 && args[0] == "norepl") { return; } string input = null; string exprstr = ""; Console.WriteLine(); Console.WriteLine(); Console.WriteLine(); Console.WriteLine("Enter expressions. Enter blank line to abort input."); Console.WriteLine("Enter 'exit (the symbol) to exit."); Console.WriteLine(); string prompt = ">>> "; while (true) { Console.Write(prompt); input = Console.ReadLine(); if (input == "") { exprstr = ""; prompt = ">>> "; continue; } else { exprstr = exprstr + " " + input; } // See if we have complete input. try { var ast = new Parser().ParseExpr(new StringReader(exprstr)); } catch (Exception) { prompt = "... "; continue; } // We do, so execute. try { object res = s.ExecuteExpr(exprstr, feo); exprstr = ""; prompt = ">>> "; if (res == s.MakeSymbol("exit")) { return; } Console.WriteLine(res); } catch (Exception e) { exprstr = ""; prompt = ">>> "; Console.Write("ERROR: "); Console.WriteLine(e); } } }
private static object MakeQuoteConstant(object expr, Sympl symplRuntime) { if (expr is SymplListExpr) { SymplListExpr listexpr = (SymplListExpr)expr; int len = listexpr.Elements.Length; var exprs = new object[len]; for (int i = 0; i < len; i++) { exprs[i] = MakeQuoteConstant(listexpr.Elements[i], symplRuntime); } return Cons._List(exprs); } else if (expr is IdOrKeywordToken) { return symplRuntime.MakeSymbol(((IdOrKeywordToken)expr).Name); } else if (expr is LiteralToken) { return ((LiteralToken)expr).Value; } else { throw new InvalidOperationException( "Internal: quoted list has -- " + expr.ToString()); } }