示例#1
0
        public void ShouldParseIntTupleList()
        {
            var tokenStream = new Token[]
            {
                new IdentifierToken(FilePosition.StartOfFile, new Identifier("planemap")),
                new OpenBraceToken(FilePosition.StartOfFile),

                new OpenBraceToken(FilePosition.StartOfFile),
                new IntegerToken(FilePosition.StartOfFile, 1),
                new CommaToken(FilePosition.StartOfFile),
                new IntegerToken(FilePosition.StartOfFile, 2),
                new CloseBraceToken(FilePosition.StartOfFile),

                new CommaToken(FilePosition.StartOfFile),

                new OpenBraceToken(FilePosition.StartOfFile),
                new IntegerToken(FilePosition.StartOfFile, 1),
                new CommaToken(FilePosition.StartOfFile),
                new IntegerToken(FilePosition.StartOfFile, 2),
                new CommaToken(FilePosition.StartOfFile),
                new IntegerToken(FilePosition.StartOfFile, 3),
                new CloseBraceToken(FilePosition.StartOfFile),

                new CloseBraceToken(FilePosition.StartOfFile),
            };

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

            results.Should().HaveCount(1);
            results[0].Should().BeOfType <IntTupleBlock>().Which.Tuples.Should().HaveCount(2);
        }
示例#2
0
        public void ShouldHandleParsingTestFile()
        {
            using var stream = TestFile.Uwmf.TEXTMAP;

            using var textReader = new StreamReader(stream, Encoding.ASCII);
            var lexer  = new UnifiedLexer(textReader);
            var result = UwmfParser.Parse(lexer.Scan()).ToArray();
        }
示例#3
0
        public void ShouldHandleParsingDemoMap()
        {
            var map = ThingDemoMap.Create();

            using var stream = new MemoryStream();
            map.WriteTo(stream);

            stream.Position = 0;

            using var textReader = new StreamReader(stream, Encoding.ASCII);
            var lexer  = new UnifiedLexer(textReader);
            var result = UwmfParser.Parse(lexer.Scan()).ToArray();
        }
示例#4
0
        public void ShouldParseEmptyBlock()
        {
            var tokenStream = new Token[]
            {
                new IdentifierToken(FilePosition.StartOfFile, new Identifier("blockName")),
                new OpenBraceToken(FilePosition.StartOfFile),
                new CloseBraceToken(FilePosition.StartOfFile),
            };

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

            results.Should().HaveCount(1);
            results[0].Should().BeOfType <Block>().Which.Fields.Should().BeEmpty();
        }
示例#5
0
        public void ShouldRoundTripDemoMap()
        {
            var map = ThingDemoMap.Create();

            using var stream = new MemoryStream();
            map.WriteTo(stream);

            stream.Position = 0;

            using var textReader = new StreamReader(stream, Encoding.ASCII);
            var roundTripped = UwmfSemanticAnalyzer.ReadMapData(UwmfParser.Parse(new UnifiedLexer(textReader).Scan()));

            UwmfComparison.AssertEqual(roundTripped, map);
        }
示例#6
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 = UwmfParser.Parse(tokenStream).ToArray();

            results.Should().HaveCount(1);
            results[0].Should().BeOfType <Assignment>();
        }
示例#7
0
 public void ShouldParseOldDemoMap()
 {
     using var stream     = TestFile.Uwmf.TEXTMAP;
     using var textReader = new StreamReader(stream, Encoding.ASCII);
     UwmfSemanticAnalyzer.ReadMapData(UwmfParser.Parse(new UnifiedLexer(textReader).Scan()));
 }