public static string ConvertStructureValueDeclarationAst(StructureValueDeclarationAst node, MofQuirks quirks = MofQuirks.None)
        {
            // value of GOLF_PhoneNumber as $JohnDoesPhoneNo
            // {
            //     AreaCode = { "9", "0", "7" };
            //     Number = { "7", "4", "7", "4", "8", "8", "4" };
            // };
            var source = new StringBuilder();

            // value of GOLF_PhoneNumber as $JohnDoesPhoneNo
            source.Append(node.Value.Extent.Text);
            source.Append(" ");
            source.Append(node.Of.Extent.Text);
            source.Append(" ");
            source.Append(node.TypeName.Name);
            if (node.Alias != null)
            {
                source.Append(" ");
                source.Append(node.As.Extent.Text);
                source.Append(" $");
                source.Append(node.Alias.Name);
            }
            source.AppendLine();
            // {
            //     AreaCode = { "9", "0", "7" };
            //     Number = { "7", "4", "7", "4", "8", "8", "4" };
            // }
            source.Append(AstMofGenerator.ConvertPropertyValueListAst(node.PropertyValues, quirks));
            // ;
            source.Append(node.StatementEnd.Extent.Text);
            return(source.ToString());
        }
 public static string ConvertComplexValueAst(ComplexValueAst node, MofQuirks quirks = MofQuirks.None, string indent = "")
 {
     if (node.IsAlias)
     {
         return($"${node.Alias.Name}");
     }
     else
     {
         var source = new StringBuilder();
         // value of GOLF_PhoneNumber
         source.Append(node.Value.Extent.Text);
         source.Append(" ");
         source.Append(node.Of.Extent.Text);
         source.Append(" ");
         source.Append(node.TypeName.Name);
         source.AppendLine();
         // {
         //     AreaCode = { "9", "0", "7" };
         //     Number = { "7", "4", "7", "4", "8", "8", "4" };
         // }
         source.Append(indent);
         source.Append(AstMofGenerator.ConvertPropertyValueListAst(node.PropertyValues, quirks, indent));
         return(source.ToString());
     }
 }
        public static string ConvertInstanceValueDeclarationAst(InstanceValueDeclarationAst node, MofQuirks quirks = MofQuirks.None, string indent = "")
        {
            // instance of myType as $Alias00000070
            // {
            //     Reference = TRUE;
            // };
            var source = new StringBuilder();

            // instance of myType as $Alias00000070
            source.Append(node.Instance.Extent.Text);
            source.Append(" ");
            source.Append(node.Of.Extent.Text);
            source.Append(" ");
            source.Append(node.TypeName.Name);
            if (node.Alias != null)
            {
                source.Append(" ");
                source.Append(node.As.Extent.Text);
                source.Append(" ");
                source.Append("$");
                source.Append(node.Alias.Name);
            }
            source.AppendLine();
            // {
            //     Reference = TRUE;
            // }
            source.Append(AstMofGenerator.ConvertPropertyValueListAst(node.PropertyValues, quirks, indent));
            // ;
            source.Append(node.StatementEnd.Extent.Text);
            return(source.ToString());
        }
        public static string ConvertToMof(AstNode node, MofQuirks quirks = MofQuirks.None)
        {
            if (node == null)
            {
                return(null);
            }
            switch (node)
            {
            case MofSpecificationAst ast:
                // 7.2 MOF specification
                return(AstMofGenerator.ConvertMofSpecificationAst(ast, quirks));

            case CompilerDirectiveAst ast:
                // 7.3 Compiler directives
                return(AstMofGenerator.ConvertCompilerDirectiveAst(ast, quirks));

            case QualifierTypeDeclarationAst ast:
                // 7.4 Qualifiers
                return(AstMofGenerator.ConvertQualifierTypeDeclarationAst(ast, quirks));

            case QualifierListAst ast:
                // 7.4.1 QualifierList
                return(AstMofGenerator.ConvertQualifierListAst(ast, quirks));

            case ClassDeclarationAst ast:
                // 7.5.2 Class declaration
                return(AstMofGenerator.ConvertClassDeclarationAst(ast, quirks));

            case PropertyDeclarationAst ast:
                // 7.5.5 Property declaration
                return(AstMofGenerator.ConvertPropertyDeclarationAst(ast, quirks));

            case MethodDeclarationAst ast:
                // 7.5.6 Method declaration
                return(AstMofGenerator.ConvertMethodDeclarationAst(ast, quirks));

            case ParameterDeclarationAst ast:
                // 7.5.7 Parameter declaration
                return(AstMofGenerator.ConvertParameterDeclarationAst(ast, quirks));

            case ComplexValueArrayAst ast:
                // 7.5.9 Complex type value
                return(AstMofGenerator.ConvertComplexValueArrayAst(ast, quirks));

            case ComplexValueAst ast:
                // 7.5.9 Complex type value
                return(AstMofGenerator.ConvertComplexValueAst(ast, quirks));

            case PropertyValueListAst ast:
                // 7.5.9 Complex type value
                return(AstMofGenerator.ConvertPropertyValueListAst(ast, quirks));

            case LiteralValueArrayAst ast:
                // 7.6.1 Primitive type value
                return(AstMofGenerator.ConvertLiteralValueArrayAst(ast, quirks));

            case IntegerValueAst ast:
                // 7.6.1.1 Integer value
                return(AstMofGenerator.ConvertIntegerValueAst(ast, quirks));

            case RealValueAst ast:
                // 7.6.1.2 Real value
                return(AstMofGenerator.ConvertRealValueAst(ast, quirks));

            case StringValueAst ast:
                // 7.6.1.3 String values
                return(AstMofGenerator.ConvertStringValueAst(ast, quirks));

            case BooleanValueAst ast:
                // 7.6.1.5 Boolean value
                return(AstMofGenerator.ConvertBooleanValueAst(ast, quirks));

            case NullValueAst ast:
                // 7.6.1.6 Null value
                return(AstMofGenerator.ConvertNullValueAst(ast, quirks));

            case InstanceValueDeclarationAst ast:
                // 7.6.2 Complex type value
                return(AstMofGenerator.ConvertInstanceValueDeclarationAst(ast, quirks));

            case StructureValueDeclarationAst ast:
                // 7.6.2 Complex type value
                return(AstMofGenerator.ConvertStructureValueDeclarationAst(ast, quirks));

            case EnumValueAst ast:
                // 7.6.3 Enum type value
                return(AstMofGenerator.ConvertEnumValueAst(ast, quirks));

            case EnumValueArrayAst ast:
                // 7.6.3 Enum type value
                return(AstMofGenerator.ConvertEnumValueArrayAst(ast, quirks));

            case EnumTypeValueAst ast:
                // 7.6.3 Enum type value
                return(AstMofGenerator.ConvertEnumTypeValueAst(ast, quirks));

            case PropertyValueAst ast:
                // 7.5.9 Complex type value
                return(AstMofGenerator.ConvertPropertyValueAst(ast, quirks));

            default:
                // unknown
                throw new InvalidOperationException(node.GetType().FullName);
            }
        }