예제 #1
0
		internal ValueInitializer(string propertyName, QualifierList qualifiers, object initializer)
		{
			this.m_propertyName = propertyName;
			this.m_qualifiers = qualifiers;
			this.m_initializer = initializer;
			this.m_qualifiers.SetParent(this);
		}
예제 #2
0
		internal ClassDeclaration(DocumentRange location, ClassName className, AliasIdentifier alias, ClassName superclassName, QualifierList qualifiers, ClassFeatureList classFeatures) : base(location)
		{
			this.m_className = className;
			this.m_alias = alias;
			this.m_superclassName = superclassName;
			this.m_qualifiers = qualifiers;
			this.m_classFeatures = classFeatures;
			qualifiers.SetParent(this);
			classFeatures.SetParent(this);
		}
예제 #3
0
        private ClassFeatureList ParseClassFeatureList()
        {
            List <ClassFeature> classFeatures = new List <ClassFeature>();

            while (!this.TryConsume(TokenType.CloseBrace))
            {
                QualifierList qualifierList = this.ParseQualifierList();
                DocumentRange location      = this.m_queue.Peek().Location;
                DataType      arrayType     = this.ParseBuiltInTypeOrObjectReference();
                string        value         = this.GetIdentifier().Value;
                if (!this.TryConsume(TokenType.OpenParens))
                {
                    if (this.TryConsume(TokenType.OpenBracket))
                    {
                        if (this.PeekToken(TokenType.CloseBracket))
                        {
                            this.Consume(TokenType.CloseBracket);
                            int?nullable = null;
                            arrayType = new ArrayType(arrayType, nullable);
                        }
                        else
                        {
                            throw new NotSupportedException();
                        }
                    }
                    object obj = null;
                    if (!this.TryConsume(TokenType.Equals))
                    {
                        this.Consume(TokenType.Semicolon);
                        classFeatures.Add(new PropertyDeclaration(location, value, arrayType, obj, qualifierList));
                    }
                    else
                    {
                        throw new ParseFailureException(Resources.MofInitializerNotSupported, location);
                    }
                }
                else
                {
                    throw new NotSupportedException();
                }
            }
            return(new ClassFeatureList(classFeatures.ToArray()));
        }
예제 #4
0
        private ClassDeclaration ParseClass(QualifierList qualifiers)
        {
            DocumentRange   location        = this.Consume(KeywordType.CLASS).Location;
            ClassName       className       = this.ParseClassName();
            AliasIdentifier aliasIdentifier = null;

            if (!this.PeekKeyword(KeywordType.AS))
            {
                ClassName className1 = null;
                if (this.TryConsume(TokenType.Colon))
                {
                    className1 = this.ParseClassName();
                }
                this.Consume(TokenType.OpenBrace);
                ClassFeatureList classFeatureList = this.ParseClassFeatureList();
                this.Consume(TokenType.Semicolon);
                return(new ClassDeclaration(location, className, aliasIdentifier, className1, qualifiers, classFeatureList));
            }
            else
            {
                throw new NotSupportedException();
            }
        }
예제 #5
0
		internal ReferenceDeclaration(DocumentRange location, string name, ObjectReference reference, object defaultValue, QualifierList qualifiers) : base(location)
		{
			qualifiers.SetParent(this);
			this.m_qualifiers = qualifiers;
		}
예제 #6
0
        private MofSpecification ParseMofSpecification()
        {
            Token                token;
            DocumentRange        documentRange;
            List <MofProduction> mofProductions = new List <MofProduction>();

            if (this.m_queue.Count > 0)
            {
                if (this.m_queue.Dequeue().Type == TokenType.StartOfInput)
                {
                    QualifierList qualifierList = null;
                    while (true)
                    {
                        if (this.m_queue.Count <= 0)
                        {
                            documentRange = new DocumentRange();
                            throw new ParseFailureException("No EndOfInput token found at the end of the input", documentRange);
                        }
                        token = this.m_queue.Peek();
                        TokenType type = token.Type;
                        if (type == TokenType.EndOfInput)
                        {
                            if (qualifierList == null)
                            {
                                return(new MofSpecification(mofProductions.ToArray()));
                            }
                            else
                            {
                                throw new ParseFailureException("Found qualifiers that are not applied to any production.", token.Location);
                            }
                        }
                        else
                        {
                            if (type == TokenType.Identifier)
                            {
                                if (qualifierList == null)
                                {
                                    qualifierList = new QualifierList(new Qualifier[0]);
                                }
                                TokenIdentifier tokenIdentifier = (TokenIdentifier)token;
                                if (!tokenIdentifier.IsKeyword)
                                {
                                    throw new ParseFailureException(string.Format("Unexpected identifier: {0}", tokenIdentifier), tokenIdentifier.Location);
                                }
                                else
                                {
                                    TokenKeyword tokenKeyword = (TokenKeyword)token;
                                    KeywordType  keywordType  = tokenKeyword.KeywordType;
                                    if (keywordType == KeywordType.CLASS)
                                    {
                                        mofProductions.Add(this.ParseClass(qualifierList));
                                        qualifierList = null;
                                        continue;
                                    }
                                    else
                                    {
                                        if (keywordType != KeywordType.INSTANCE)
                                        {
                                        }
                                        throw new ParseFailureException(string.Format("Unexpected keyword: {0}", tokenKeyword), tokenKeyword.Location);
                                    }
                                }
                            }
                            else if (type == TokenType.Alias)
                            {
                                break;
                            }
                            else if (type == TokenType.Pragma)
                            {
                                if (qualifierList == null)
                                {
                                    mofProductions.Add(this.ParseCompilerDirective());
                                    continue;
                                }
                                else
                                {
                                    throw new ParseFailureException("Qualifiers are not legal on pragmas.", token.Location);
                                }
                            }
                            if (type != TokenType.OpenBracket)
                            {
                                break;
                            }
                            qualifierList = this.ParseQualifierList();
                        }
                    }
                    throw new ParseFailureException("Unexpected token", token.Location);
                }
                else
                {
                    DocumentCoordinate documentCoordinate  = new DocumentCoordinate();
                    DocumentCoordinate documentCoordinate1 = new DocumentCoordinate();
                    throw new ParseFailureException("Expected a StartOfInput token.", new DocumentRange(this.m_filePath, documentCoordinate, documentCoordinate1));
                }
            }
            documentRange = new DocumentRange();
            throw new ParseFailureException("No EndOfInput token found at the end of the input", documentRange);
        }