#pragma warning disable RCS1175 // Unused this parameter. public static void AddBoolLibrary(this DogeWorkspace workspace, DogeSymbolTable symbolTable) #pragma warning restore RCS1175 // Unused this parameter. { symbolTable.SetSymbol(Bool, new DogeSymbol( Bool, List(Name, Bool), DogeSymbolAttribute.Static, DogeSymbolType.Type, DogeAccessibilityModifier.Public, null, null)); var internalSymbolTable = symbolTable.GetOrAddSymbolTable(Bool, DogeSymbolTableType.Namespace); }
public static void AddStandardLibrary(this DogeWorkspace workspace, DogeSymbolTable symbolTable) { symbolTable.SetSymbol(Name, new DogeSymbol( Name, List(Name), DogeSymbolAttribute.None, DogeSymbolType.Namespace, DogeAccessibilityModifier.Public, null, null)); var internalSymbolTable = symbolTable.GetOrAddSymbolTable(Name, DogeSymbolTableType.Namespace); workspace.AddStringLibrary(internalSymbolTable); workspace.AddIntLibrary(internalSymbolTable); workspace.AddBoolLibrary(internalSymbolTable); workspace.AddConsoleLibrary(internalSymbolTable); }
private static void Compile(DogeFile file, bool verbose, string code, params string[] startup) { IEnumerable <DogeToken> tokens = Workspace.Tokenize(code).ToArray(); if (verbose) { Console.WriteLine($"{string.Join(",\n", tokens.Select(x => x.ToString()))}"); } DogeNamespaceDefinition @namespace = Workspace.Build(file, tokens); if (verbose) { Console.Write(@namespace.ToString()); } DogeSymbolTable symbolTable = Workspace.BuildSymbolTable(@namespace); if (verbose) { Console.Write(symbolTable); } Workspace.AddStandardLibrary(symbolTable); Workspace.ResolveSymbols(@namespace, symbolTable); if (verbose) { Console.Write(@namespace.ToString()); } DogeProject project = new DogeProject( @namespace, (DogeNamedMethodDefinition)symbolTable.ResolveSymbol( startup, s => s.SymbolType == DogeSymbolType.Method, _ => true) .Definition !); DogeInterpreter interpreter = new DogeInterpreter(project); interpreter.Run(); }
#pragma warning disable RCS1175 // Unused this parameter. public static void AddConsoleLibrary(this DogeWorkspace workspace, DogeSymbolTable symbolTable) #pragma warning restore RCS1175 // Unused this parameter. { symbolTable.SetSymbol(Console, new DogeSymbol( Console, List(Name, Console), DogeSymbolAttribute.Static, DogeSymbolType.Type, DogeAccessibilityModifier.Public, null, null)); var internalSymbolTable = symbolTable.GetOrAddSymbolTable(Console, DogeSymbolTableType.Type); internalSymbolTable.SetSymbol(ConsolePrint, new DogeSymbol( ConsolePrint, List(Name, Console, ConsolePrint), DogeSymbolAttribute.None, DogeSymbolType.Method, DogeAccessibilityModifier.Public, null, new DogeExternalCall(Parameters(("text", Name + "." + String)), new DogeExternalCall.CallInterpreter(locals => { System.Console.Write(locals["text"]); return(null); })))); internalSymbolTable.SetSymbol(ConsolePrintLine, new DogeSymbol( ConsolePrintLine, List(Name, Console, ConsolePrintLine), DogeSymbolAttribute.None, DogeSymbolType.Method, DogeAccessibilityModifier.Public, null, new DogeExternalCall(Parameters(("text", Name + "." + String)), new DogeExternalCall.CallInterpreter(locals => { System.Console.WriteLine(locals["text"]); return(null); })))); }