Пример #1
0
        public static (List <ASTError>, ASTAlias) Parse(
            IParser parser,
            IEnumerable <ASTAnnotation> annotations,
            IEnumerable <ASTDirective> directives)
        {
            List <ASTError> errors = new List <ASTError>();
            ASTAlias        result = new ASTAlias
            {
                Annotations = annotations,
                Directives  = directives
            };

            if (parser.HasNext())
            {
                parser.Next();
            }
            var nameId = parser.Consume(TokenType.Identifier);

            result.Name = nameId.Value;
            parser.Consume(TokenType.Equal);
            result.Type         = ASTTypeDefinition.Parse(parser).ToList();
            result.Restrictions = ASTRestriction.CreateRestrictions(parser, TokenType.KW_Alias).ToList();
            parser.TryConsume(TokenType.EndStatement);
            parser.Consume(TokenType.ContextEnded);

            return(errors, result);
        }
Пример #2
0
 public ASTAlias(IParser parser)
 {
     if (parser.HasNext()) parser.Next();
     var nameId = parser.Consume(TokenType.Identifier);
     this.Name = nameId.Value;
     parser.Consume(TokenType.Equal);
     this.Type = ASTTypeDefinition.ParseType(parser).ToList();
     this.Restrictions = ASTRestriction.CreateRestrictions(parser).ToList();
     parser.TryConsume(TokenType.EndStatement);
     parser.Consume(TokenType.ContextEnded);
 }
Пример #3
0
        public ASTTypeField(IParser parser)
        {
            this.Restrictions = new List <ASTRestriction>();
            this.Annotations  = ASTAnnotation.Parse(parser).ToList();
            this.Name         = parser.Consume(TokenType.Identifier).Value;
            Token Separator = parser.Consume(TokenType.Separator);

            this.Type         = ASTTypeDefinition.ParseType(parser).ToList();
            this.Restrictions = ASTRestriction.CreateRestrictions(parser).ToList();
            parser.Consume(TokenType.EndStatement);
        }
Пример #4
0
        public static ASTTypeField Parse(IParser parser)
        {
            var result = new ASTTypeField();

            result.Restrictions = new List <ASTRestriction>();
            result.Annotations  = ASTAnnotation.Parse(parser).ToList();
            result.Name         = parser.Consume(TokenType.Identifier).Value;
            Token Separator = parser.Consume(TokenType.Separator);

            result.Type         = ASTTypeDefinition.ParseType(parser).ToList();
            result.Restrictions = ASTRestriction.CreateRestrictions(parser, TokenType.KW_Type).ToList();
            parser.Consume(TokenType.EndStatement);
            return(result);
        }
Пример #5
0
        public ASTChoice(IParser parser)
        {
            if (parser.HasNext())
            {
                parser.Next();
            }
            var nameId = parser.Consume(TokenType.Identifier);

            this.Name = nameId.Value;
            parser.Consume(TokenType.Equal);
            this.Type    = ASTTypeDefinition.ParseType(parser).ToList();
            this.Options = ASTOption.Parse(parser).ToList();
            parser.TryConsume(TokenType.EndStatement);
            parser.Consume(TokenType.ContextEnded);
        }
Пример #6
0
        public static (List <ASTError>, ASTChoice) Parse(IParser parser)
        {
            if (parser.HasNext())
            {
                parser.Next();
            }

            var result = new ASTChoice();

            var nameId = parser.Consume(TokenType.Identifier);

            result.Name = nameId.Value;
            parser.Consume(TokenType.Equal);
            result.Type    = ASTTypeDefinition.Parse(parser).ToList();
            result.Options = ASTOption.Parse(parser).ToList();
            parser.TryConsume(TokenType.EndStatement);
            parser.Consume(TokenType.ContextEnded);
            return(new List <ASTError>(), result);
        }
Пример #7
0
        public static ASTFlowParameter Parse(IParser parser)
        {
            var identifiers = ASTTypeDefinition.Parse(parser).ToList();

            return(new ASTFlowParameter("", identifiers));
        }