Пример #1
0
 private NamespaceNode(ExpressionNode nameExpression)
 {
     Namespace      = null;
     NameExpression = nameExpression;
     classes        = new List <ClassNode>();
     namespaces     = new List <NamespaceNode>();
 }
Пример #2
0
        public static NamespaceNode Parse(TokenString tStr, ref int index)
        {
            int startIndex = index;

            if (tStr[index].Type != TokenType.@namespace)
            {
                return(null);
            }

            index++;
            var nameExpression = Exp.Parse(tStr.GetRangeUntil(ref index, TokenType.cBraceOpen));

            if (nameExpression == null)
            {
                index = startIndex;
                return(null);
            }

            NamespaceNode node = new NamespaceNode(nameExpression);

            // Get internals
            var classesRange = tStr.GetRangeInBrackets(ref index);

            int cRangeIndex = 0;

            while (cRangeIndex < classesRange.Count)
            {
                Token currentToken = classesRange[cRangeIndex];

                if (currentToken.Type == TokenType.accessor || currentToken.Type == TokenType.@class)
                {
                    ClassNode classNode = ClassNode.Parse(classesRange, ref cRangeIndex);

                    if (classNode == null)
                    {
                        break;
                    }

                    node.AddClass(classNode);
                }
                else if (currentToken.Type == TokenType.@namespace)
                {
                    NamespaceNode namespaceNode = new NamespaceNode(Exp.Parse(tStr.GetRangeUntil(ref index, TokenType.cBraceOpen)));

                    if (namespaceNode == null)
                    {
                        break;
                    }

                    node.AddNamespace(namespaceNode);
                }
                else
                {
                    cRangeIndex++;
                }
            }

            index += cRangeIndex;
            return(node);
        }
Пример #3
0
        public static NamespaceNode CreateGlobalNamespaceNode(string assemblyName = "Assembly")
        {
            NamespaceNode node = new NamespaceNode(Exp.Parse(new TokenString(new Token()
            {
                Type = TokenType.identifier, Value = assemblyName
            })));

            return(node);
        }
Пример #4
0
 public void AddNamespace(NamespaceNode namespaceNode)
 {
     namespaceNode.Namespace = this;
     namespaces.Add(namespaceNode);
 }