private CustomDefinition GetDefinition(DefSpecifierNode defSpecifier) { for (NameSpaceDefinition nameSpace = Parser.RootNameSpace; defSpecifier.NextSpecifier != null; defSpecifier = defSpecifier.NextSpecifier) { if (nameSpace.IsContainCustomDefinition(defSpecifier.Content) && nameSpace.IsContainNameSpace(defSpecifier.Content)) { if (defSpecifier.NextSpecifier == null) { return(nameSpace.GetClassDefinition(defSpecifier.Content)); } } if (nameSpace.IsContainCustomDefinition(defSpecifier.Content)) { return(nameSpace.GetClassDefinition(defSpecifier.Content)); } if (nameSpace.IsContainNameSpace(defSpecifier.Content)) { nameSpace = nameSpace.GetNameSpaceDefinition(defSpecifier.Content); } } return(null); //TODO:报错 最后一个不是类型 }
private void AnalyzeUsing(UsingNode usingNode) { for (NameSpaceDefinition nameSpace = Parser.RootNameSpace; usingNode.NextUsing != null; usingNode = usingNode.NextUsing) { if (!nameSpace.IsContainNameSpace(usingNode.Name)) { return; //TODO:报错 未找到命名空间名 } usingNode.NameSpace = nameSpace.GetNameSpaceDefinition(usingNode.Name); } }
private void Init(string outputName) { RootNameSpace = new NameSpaceDefinition(outputName); _endNameSpace = new NameSpaceDefinition(outputName); FilesReferences = new List <UsingNode> [Lexer.FileCount]; FilesAliases = new Dictionary <string, DefSpecifierNode> [Lexer.FileCount]; FilesDefinitions = new List <CustomDefinition> [Lexer.FileCount]; for (int i = 0; i < Lexer.FileCount; i++) { FilesReferences[i] = new List <UsingNode>(); FilesAliases[i] = new Dictionary <string, DefSpecifierNode>(); FilesDefinitions[i] = new List <CustomDefinition>(); } }
private void ParseNameSpace() { _lexer.Match(TokenType.Identifer); //TODO:使用Match函数报错 if (!RootNameSpace.IsContainNameSpace(_lexer.NextTokenContent)) { RootNameSpace.AddAfter(_lexer.NextTokenContent); } NameSpaceDefinition last = RootNameSpace.GetNameSpaceDefinition(_lexer.NextTokenContent); _lexer.Next(); while (_lexer.Match(".")) { _lexer.MatchNext(TokenType.Identifer); //TODO:使用Match函数报错 last.AddAfter(_lexer.NextTokenContent); last = last.GetNameSpaceDefinition(_lexer.NextTokenContent); _lexer.Next(); } _endNameSpace = last; _lexer.MatchNow(";"); //TODO:使用Match函数报错 }