Exemple #1
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);
        }
Exemple #2
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);
        }