public UniqueSymbolOrArities(int arity, TSymbol uniqueSymbol) { _uniqueSymbolOrArities = uniqueSymbol; _arityBitVectorOrUniqueArity = arity; //if there's no unique symbol, how can there be an arity? Debug.Assert((uniqueSymbol != null) || (arity == 0)); }
public TreeNode(TreeNode parent, TSymbol c) { this.Char = c; this.Parent = parent; this.results = new List <TSymbol[]>(); hash = new Dictionary <TSymbol, TreeNode>(); }
public TPlayer(string name, TSymbol symbol) { if (string.IsNullOrWhiteSpace(name)) throw new ArgumentException(nameof(name)); if (symbol == TSymbol.Empty) throw new ArgumentException(nameof(symbol)); Name = name; Symbol = symbol; }
public TreeNode(TreeNode parent, TSymbol c) { _char = c; _parent = parent; _results = new List <TSymbol[]>(); _resultsAr = new TSymbol[][] { }; _transitionsAr = new TreeNode[] { }; _transHash = new Hashtable(); }
public void SyntaxError(TextWriter output, IRecognizer recognizer, TSymbol offendingSymbol, int line, int charPositionInLine, string msg, RecognitionException e) { var source = offendingSymbol is IToken t? SourceRange.FromTokens(t, null) : new SourceRange(new SourceLocation(line, charPositionInLine), new SourceLocation(line, charPositionInLine)); mod.Diagnostics.AddError(msg, source); }
public void GetUniqueSymbolOrArities(out IArityEnumerable arities, out TSymbol uniqueSymbol) { if (this.HasUniqueSymbol) { arities = null; uniqueSymbol = (TSymbol)_uniqueSymbolOrArities; } else { arities = (_uniqueSymbolOrArities == null && _arityBitVectorOrUniqueArity == 0) ? null : (IArityEnumerable)this; uniqueSymbol = null; } }
public TreeNode GetTransition(TSymbol c) { TreeNode t; if (hash.TryGetValue(c, out t)) { return(t); } else { return(null); } }
internal static TSymbol FindSymbol(string name, TSymbol gSymbol) { TSymbol temp = gSymbol; while (temp != null) { if (temp.Name.ToLower() == name.ToLower()) { return(temp); } temp = temp.Next; } return(null); }
public void AddSymbol(TSymbol symbol, string multiName) { if (symbol != null && symbol == _uniqueSymbolOrMultiNames) { return; } if (this.HasUniqueSymbol) { // The symbol is no longer unique. So clear the // UniqueSymbol field and record the unique name // before adding the new name value. var(uniqueName, _) = (Tuple <string, TSymbol>)_uniqueSymbolOrMultiNames; Debug.Assert(_uniqueSymbolOrMultiNames is TSymbol); _uniqueSymbolOrMultiNames = new ConsList <string>(uniqueName, ConsList <string> .Empty); } AddMultiName(multiName); }
public void Bind <TSymbol, TCodeCommand>() where TSymbol : Symbol, new() where TCodeCommand : CodeCommand, new() { var symbol = new TSymbol(); if (symbol is IScope scope) { var openSymbol = scope.GetOpenSymbol(); symbolToCommand.Add(openSymbol.GetType(), () => new TCodeCommand()); symbols.Add(openSymbol); symbols.Add(scope.GetCloseSymbol()); } else { symbols.Add(symbol); symbolToCommand.Add(typeof(TSymbol), () => new TCodeCommand()); } }
public void AddSymbol(TSymbol symbol, int arity) { if (symbol != null && symbol == _uniqueSymbolOrArities) { Debug.Assert(arity == _arityBitVectorOrUniqueArity); return; } if (this.HasUniqueSymbol) { // The symbol is no longer unique. So clear the // UniqueSymbol field and record the unique arity // before adding the new arity value. Debug.Assert(_uniqueSymbolOrArities is TSymbol); _uniqueSymbolOrArities = null; int uniqueArity = _arityBitVectorOrUniqueArity; _arityBitVectorOrUniqueArity = 0; AddArity(uniqueArity); } AddArity(arity); }
public void Execute(GeneratorExecutionContext context) { //if (!Debugger.IsAttached) Debugger.Launch(); context.AddSource("g2", SourceText.From(AttrCode, new UTF8Encoding(false))); if (context.SyntaxReceiver is RegisterReceiver Receiver) { CSharpParseOptions Options = (context.Compilation as CSharpCompilation).SyntaxTrees[0].Options as CSharpParseOptions; var AttributeTree = CSharpSyntaxTree.ParseText(SourceText.From(AttrCode, new UTF8Encoding(false)), Options); var Compilation = context.Compilation.AddSyntaxTrees(AttributeTree); var Symbol = Compilation.GetTypeByMetadataName("CodeGed.AutoRegisterAttribute"); List <string> RegCalls = new List <string>(); foreach (var C in Receiver.Classes) { SemanticModel Model = Compilation.GetSemanticModel(C.SyntaxTree); if (Model.GetDeclaredSymbol(C) is ITypeSymbol TSymbol && TSymbol.GetAttributes() .Any(E => E.AttributeClass.Equals(Symbol, SymbolEqualityComparer.Default))) { var Name = C.GetFullDefined() + "." + C.Identifier.Text; RegCalls.Add($"Services.AddSingleton<{Name}>();"); } } var Full = $@" namespace CodeGed{{ using System; using Microsoft.Extensions.DependencyInjection; public static class AutoRegKits{{ public static void GeneratedRegister(this IServiceCollection Services){{ {string.Join(Environment.NewLine, RegCalls)} }} }} }} "; context.AddSource("g3", SourceText.From(Full, new UTF8Encoding(false))); } }
public UniqueSymbolOrMultiNames(TSymbol uniqueSymbol, string multiName) { _uniqueSymbolOrMultiNames = new Tuple <string, TSymbol>(multiName, uniqueSymbol); //if there's no unique symbol, how can there be a multi name? Debug.Assert((uniqueSymbol != null) || (multiName == null)); }
protected void OnSetSymbol(TSymbol symbol, int row, int column) { SetSymbol?.Invoke(symbol, row, column); }
public bool ContainsTransition(TSymbol c) { return(GetTransition(c) != null); }
public TreeNode GetTransition(TSymbol c) { return((TreeNode)_transHash[c]); }
public TConsolePlayer(string name, TSymbol symbol) : base(name, symbol) { }
public TComputerPlayer(TSymbol symbol) : this(Environment.MachineName, symbol) { }
protected TComputerPlayer(string name, TSymbol symbol) : base(name, symbol) { }
public void OnPlayerSetSymbol(TSymbol symbol, int row, int column) { _field[row, column] = symbol; }
public StateResult(int?state, TSymbol result) { State = state; Result = result; }
public void GetUniqueSymbolOrMultiNames(out IEnumerable <string> multiNames, out TSymbol uniqueSymbol) { if (this.HasUniqueSymbol) { multiNames = null; uniqueSymbol = (TSymbol)_uniqueSymbolOrMultiNames; } else { multiNames = (ConsList <string>)_uniqueSymbolOrMultiNames; uniqueSymbol = null; } }