Пример #1
0
        public static ArraySyntax CreateArray(IEnumerable <SyntaxBase> items)
        {
            var children = new List <SyntaxBase>();

            children.Add(SyntaxHelpers.NewlineToken);

            foreach (var item in items)
            {
                children.Add(CreateArrayItem(item));
                children.Add(SyntaxHelpers.NewlineToken);
            }

            return(new ArraySyntax(
                       SyntaxHelpers.CreateToken(TokenType.LeftSquare, "["),
                       children,
                       SyntaxHelpers.CreateToken(TokenType.RightSquare, "]")));
        }
Пример #2
0
        public static ObjectSyntax CreateObject(IEnumerable <ObjectPropertySyntax> properties)
        {
            var children = new List <SyntaxBase>();

            children.Add(SyntaxHelpers.NewlineToken);

            foreach (var property in properties)
            {
                children.Add(property);
                children.Add(SyntaxHelpers.NewlineToken);
            }

            return(new ObjectSyntax(
                       SyntaxHelpers.CreateToken(TokenType.LeftBrace, "{"),
                       children,
                       SyntaxHelpers.CreateToken(TokenType.RightBrace, "}")));
        }