Esempio n. 1
0
        /// <summary>
        /// Applies a transform to an AST, producing a new AST.
        /// </summary>
        /// <param name="transform">The transform to apply.</param>
        /// <param name="ast">The AST.</param>
        /// <returns>A new AST that results from the application of the transform.</returns>
        public static Ast Apply(this IAstTransform transform, Ast ast)
        {
            if (transform == null)
            {
                throw new ArgumentNullException(nameof(transform));
            }

            if (ast == null)
            {
                throw new ArgumentNullException(nameof(ast));
            }

            var transformer = transform.CreateTransformer();

            ast.Accept(transformer);
            return(transformer.NewAst);
        }