Beispiel #1
0
        internal new static QualifierDeclarationAst Parse(ParserStream stream)
        {
            var ast = new QualifierDeclarationAst();

            ast.Name = stream.Read <IdentifierToken>();

            if (stream.Peek <ParenthesesOpenToken>() != null)
            {
                stream.Read <ParenthesesOpenToken>();
                ast.Initializer = LiteralValueAst.Parse(stream);
                stream.Read <ParenthesesCloseToken>();
            }
            else if (stream.Peek <BlockOpenToken>() != null)
            {
                ast.Initializer = LiteralValueArrayAst.Parse(stream);
            }

            if (stream.Peek <ColonToken>() != null)
            {
                stream.Read <ColonToken>();
                while (stream.Peek <IdentifierToken>() != null)
                {
                    ast.Flavors.Add(stream.Read <IdentifierToken>().Name);
                }
            }

            return(ast);
        }
        /// <summary>
        /// </summary>
        /// <returns></returns>
        /// <remarks>
        ///
        /// See http://www.dmtf.org/sites/default/files/standards/documents/DSP0221_3.0.0a.pdf
        /// A.1 Value definitions
        ///
        ///     literalValueArray  = "{" [ literalValue *( "," literalValue ) ] "}"
        ///
        /// </remarks>
        internal new static LiteralValueArrayAst Parse(ParserStream stream)
        {
            var node = new LiteralValueArrayAst();

            // "{"
            stream.Read <BlockOpenToken>();
            // [ literalValue *( "," literalValue) ]
            if (stream.Peek <BlockCloseToken>() == null)
            {
                while (!stream.Eof)
                {
                    if (node.Values.Count > 0)
                    {
                        stream.Read <CommaToken>();
                    }
                    node.Values.Add(LiteralValueAst.Parse(stream));
                    if (stream.Peek <BlockCloseToken>() != null)
                    {
                        break;
                    }
                }
            }
            // "}"
            stream.Read <BlockCloseToken>();
            // return the result
            return(node);
        }
Beispiel #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="stream"></param>
        /// <returns></returns>
        /// <remarks>
        ///
        /// See http://www.dmtf.org/sites/default/files/standards/documents/DSP0221_3.0.0a.pdf
        /// A.17 Primitive type values
        ///
        ///     primitiveTypeValue = literalValue / literalValueArray
        ///
        /// </remarks>
        internal static PrimitiveTypeValueAst Parse(ParserStream stream)
        {
            var peek = stream.Peek();

            if (LiteralValueAst.IsLiteralValueToken(peek))
            {
                // literalValue
                return(LiteralValueAst.Parse(stream));
            }
            else if (peek is BlockOpenToken)
            {
                // literalValueArray
                return(LiteralValueArrayAst.Parse(stream));
            }
            else
            {
                throw new UnexpectedTokenException(peek);
            }
        }
 /// <summary>
 /// </summary>
 /// <returns></returns>
 /// <remarks>
 /// 
 ///     primitiveTypeValue = literalValue / literalValueArray
 ///
 ///     literalValueArray  = "{" [ literalValue *( "," literalValue ) ] "}"
 ///
 ///     literalValue       = integerValue / realValue /
 ///		                     stringValue / octetStringValue
 ///                          booleanValue /
 ///                          nullValue /
 ///		                     dateTimeValue
 ///
 /// </remarks>
 internal static new LiteralValueArrayAst Parse(ParserStream stream)
 {
     // complexValueArray =
     var node = new LiteralValueArrayAst();
     // "{"
     stream.Read<BlockOpenToken>();
     // [ literalValue
     node.Values.Add(LiteralValueAst.Parse(stream));
     // *( "," literalValue) ]
     while (stream.Peek<CommaToken>() != null)
     {
         stream.Read<CommaToken>();
         node.Values.Add(LiteralValueAst.Parse(stream));
     }
     // "}"
     stream.Read<BlockCloseToken>();
     // return the result
     return node;
 }
Beispiel #5
0
        /// <summary>
        /// </summary>
        /// <returns></returns>
        /// <remarks>
        ///
        /// See http://www.dmtf.org/sites/default/files/standards/documents/DSP0221_3.0.0a.pdf
        /// A.14 Complex type value
        ///
        ///     propertyValue = primitiveTypeValue / complexTypeValue / referenceTypeValue / enumTypeValue
        ///
        /// 7.3.5
        ///
        ///     primitiveTypeValue = literalValue / literalValueArray
        ///     primitiveType = DT_Integer / DT_Real / DT_STRING / DT_DATETIME / DT_BOOLEAN / DT_OCTETSTRING
        ///
        /// A.1
        ///
        ///     complexTypeValue = complexValue / complexValueArray
        ///
        /// A.19
        ///
        ///     referenceTypeValue  = referenceValue / referenceValueArray
        ///     referenceValueArray = "{" [ objectPathValue *( "," objectPathValue ) ] 1163 "}"
        ///
        /// A.7
        ///
        ///     enumTypeValue = enumValue / enumValueArray
        ///     enumDeclaration = enumTypeHeader enumName ":" enumTypeDeclaration ";"
        ///
        /// </remarks>
        internal static PropertyValueAst Parse(ParserStream stream)
        {
            var node = new PropertyValueAst();
            var peek = stream.Peek();

            // propertyValue = primitiveTypeValue / complexTypeValue / referenceTypeValue / enumTypeValue
            if (LiteralValueAst.IsLiteralValueToken(peek))
            {
                // primitiveTypeValue -> literalValue
                node.Value = PrimitiveTypeValueAst.Parse(stream);
            }
            else if (peek is BlockOpenToken)
            {
                // we need to read the subsequent token to work out whether
                // this is a complexValueArray, literalValueArray, referenceValueArray or enumValueArray
                stream.Read();
                peek = stream.Peek();
                if (LiteralValueAst.IsLiteralValueToken(peek))
                {
                    // literalValueArray
                    stream.Backtrack();
                    node.Value = LiteralValueArrayAst.Parse(stream);
                }
                else
                {
                    // complexValueType
                    stream.Backtrack();
                    node.Value = ComplexValueArrayAst.Parse(stream);
                }
            }
            else if (peek is AliasIdentifierToken)
            {
                // referenceTypeValue
                node.Value = ReferenceTypeValueAst.Parse(stream);
            }
            else
            {
                throw new UnexpectedTokenException(peek);
            }
            // return the result
            return(node);
        }