public void Anonymous1() { string name = NativeSymbolBag.GenerateAnonymousName(); Assert.True(NativeSymbolBag.IsAnonymousName(name)); }
private Macro ProcessPoundDefineComplexMacro(PreprocessorLine line) { // It's a complex macro. Go ahead and get the line information List <Token> list = new List <Token>(line.TokenList); int i = 0; // Strip the newlines while (i < list.Count) { if (list[i].TokenType == TokenType.NewLine) { list.RemoveAt(i); } else { i += 1; } } i = 0; // Get the #define token Token defineToken = null; while (i < list.Count) { if (list[i].TokenType == TokenType.PoundDefine) { defineToken = list[i]; break; } i += 1; } // Get the name token Token nameToken = null; while (i < list.Count) { if (list[i].TokenType == TokenType.Word) { nameToken = list[i]; break; } i += 1; } if (defineToken == null || nameToken == null) { _errorProvider.AddWarning("Error processing line: {0}", line.ToString()); return(new Macro(NativeSymbolBag.GenerateAnonymousName(), string.Empty)); } // i now points to the name token. Remove the range of tokens up until this point. Now remove the // whitespace on either end of the list list.RemoveRange(0, i + 1); while (list.Count > 0 && (list[0].TokenType == TokenType.WhiteSpace || list[0].TokenType == TokenType.NewLine)) { list.RemoveAt(0); } while (list.Count > 0 && (list[list.Count - 1].TokenType == TokenType.WhiteSpace || list[list.Count - 1].TokenType == TokenType.NewLine)) { list.RemoveAt(list.Count - 1); } // Create a string for all of the tokens var b = new StringBuilder(); foreach (Token cur in list) { b.Append(cur.Value); } return(new Macro(nameToken.Value, b.ToString())); }