Exemplo n.º 1
0
        public void Sequence3TokenReportsCorrectErrorPosition()
        {
            var p = Parse.Sequence(Token.EqualTo('1'), Token.EqualTo('w'), Token.EqualTo('U'))
                    .Select(t => new [] { t.Item1, t.Item2, t.Item3 });

            AssertParser.FailsAt(p, "1w1g", 2);
        }
Exemplo n.º 2
0
        public void TokenChainFailWithMultiTokenOperator()
        {
            // Addition is represented with operator '++'
            // If we only have one '+', ensure we get error
            var nPlusPlusN = Parse.Chain(
                Token.EqualTo('+').IgnoreThen(Token.EqualTo('+')),
                Token.EqualTo('1').Value(1),
                (opr, val1, val2) => val1 + val2);

            AssertParser.FailsAt(nPlusPlusN, "1+1", 2);
        }
Exemplo n.º 3
0
        public void ChainFailWithMultiTokenOperator()
        {
            // Addition is represented with operator '++'
            // If we only have one '+', ensure we get error
            var nPlusPlusN = Parse.Chain(
                Character.EqualTo('+').IgnoreThen(Character.EqualTo('+')),
                Numerics.IntegerInt32,
                (opr, val1, val2) => val1 + val2);

            AssertParser.FailsAt(nPlusPlusN, "1+1", 2);
        }
Exemplo n.º 4
0
        public void Sequence3ReportsCorrectErrorPosition()
        {
            var p = Parse.Sequence(Character.Digit, Character.AnyChar, Character.Upper);

            AssertParser.FailsAt(Span.MatchedBy(p), "1w1g", 2);
        }