public void ShouldParseAssignment()
        {
            var tokenStream = new Token[]
            {
                new IdentifierToken(FilePosition.StartOfFile(), new Identifier("id")),
                new EqualsToken(FilePosition.StartOfFile()),
                new IntegerToken(FilePosition.StartOfFile(), 5),
                new SemicolonToken(FilePosition.StartOfFile()),
            };

            var assignment = UdmfParser.Assignment.ParseOrThrow(tokenStream);
        }
Esempio n. 2
0
        public void ShouldParseAssignment()
        {
            var tokenStream = new Token[]
            {
                new IdentifierToken(FilePosition.StartOfFile(), new Identifier("id")),
                new EqualsToken(FilePosition.StartOfFile()),
                new IntegerToken(FilePosition.StartOfFile(), 5),
                new SemicolonToken(FilePosition.StartOfFile()),
            };

            var results = UdmfParser.Parse(tokenStream).ToArray();

            Assert.That(results, Has.Length.EqualTo(1));
            Assert.That(results[0], Is.TypeOf <Assignment>());
        }
        public void ShouldParseBlock()
        {
            var tokenStream = new Token[]
            {
                new IdentifierToken(FilePosition.StartOfFile(), new Identifier("blockName")),
                new OpenBraceToken(FilePosition.StartOfFile()),
                new IdentifierToken(FilePosition.StartOfFile(), new Identifier("id")),
                new EqualsToken(FilePosition.StartOfFile()),
                new IntegerToken(FilePosition.StartOfFile(), 5),
                new SemicolonToken(FilePosition.StartOfFile()),
                new CloseBraceToken(FilePosition.StartOfFile()),
            };

            var block = UdmfParser.Block.ParseOrThrow(tokenStream);

            Assert.That(block.Fields, Has.Length.EqualTo(1));
        }
Esempio n. 4
0
        public void ShouldParseBlock()
        {
            var tokenStream = new Token[]
            {
                new IdentifierToken(FilePosition.StartOfFile(), new Identifier("blockName")),
                new OpenBraceToken(FilePosition.StartOfFile()),
                new IdentifierToken(FilePosition.StartOfFile(), new Identifier("id")),
                new EqualsToken(FilePosition.StartOfFile()),
                new IntegerToken(FilePosition.StartOfFile(), 5),
                new SemicolonToken(FilePosition.StartOfFile()),
                new CloseBraceToken(FilePosition.StartOfFile()),
            };

            var results = UdmfParser.Parse(tokenStream).ToArray();

            Assert.That(results, Has.Length.EqualTo(1));
            Assert.That(results[0], Is.TypeOf <Block>());
            Assert.That(((Block)results[0]).Fields, Has.Length.EqualTo(1));
        }