public BoundFunctionLiteral(FunctionLiteral prototype, Scope scopeAtPrototype) { this.prototype = prototype; this.scopeAtPrototype = scopeAtPrototype; }
public IStatement Bind(ref Scope scope) { // This thing would be full declared scope = new Scope(scope, this); return this; }
public IExpression Bind(Scope scope) { return new IntegerRange(min, max); }
static void Main(string[] args) { string file = @"D:\VS\Programs\InabaScript\InabaScript\basicExpressions.is"; string[] lines = File.ReadAllLines(file); Parser p = new Parser(new Scanner(file)); try { p.Parse(); } catch (Exception e) { for (int i = Math.Max(0, p.la.line - 3); i < Math.Min(p.scanner.lines.Count, p.la.line + 2); i++) { WriteColoredLine(lines, p, i); if (i == p.la.line - 1) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(Enumerable.Range(1, p.la.col - 1).Aggregate("", (x, y) => x + " ") + "^"); } } Console.ForegroundColor = ConsoleColor.White; Console.WriteLine(e.Message); } //for (int i = 0; i < lines.Length; i++) //{ // WriteColoredLine(lines, p, i); //} List<IStatement> boundStatements = new List<IStatement>(); Scope s = new Scope(); foreach (var statement in p.statements) { if (statement is MultiVariableDeclaration) { } } Console.ReadKey(); }
public static void Scopify(ref Scope scope, List<VariableDeclaration> declarations) { foreach (var decl in declarations) { scope = new Scope(scope, decl); } }
public IExpression Bind(Scope scope) { return (IExpression)scope.GetDeclarationFor(Name); }
public static VariableDeclaration Find(ref Scope scope, VariableDeclaration vardecl, string name, bool isDeclaration) { if (vardecl != null) { return vardecl; } IDeclaration decl = scope.GetDeclarationForOrNull(name); if (decl == null && isDeclaration) { var vd = new VariableDeclaration(name, new UnknownType()); scope = new Scope(scope, vd); return vd; } if (decl is VariableDeclaration) { return (VariableDeclaration)decl; } throw new Exception(name + " not a variable"); }
public Scope(Scope parent, IDeclaration decl) { this.name = decl.Name; this.parent = parent; this.scopeTable = parent.scopeTable; this.funcTypeToLiterals = parent.funcTypeToLiterals; if (scopeTable.ContainsKey(decl.Name)) { throw new Exception("already has " + decl); } this.typeTable = parent.typeTable; scopeTable.Add(decl.Name, decl); if (decl is IType) { this.typeTable.Add(decl.Name, (IType)decl); } }
public Scope(Scope parent) { this.scopeTable = new Dictionary<string, IDeclaration>(parent.scopeTable); this.typeTable = new Dictionary<string, IType>(parent.typeTable); this.funcTypeToLiterals = new Dictionary<string, List<BoundFunctionLiteral>>(parent.funcTypeToLiterals); }
public IExpression Bind(Scope scope) { BoundFunctionLiteral bfl = new BoundFunctionLiteral(this, scope); scope.RegisterFuncLiteral(bfl); return bfl; }
public IExpression Bind(Scope scope) { return this; }