예제 #1
0
        public static void BindingAction3Success()
        {
            var userState = new RumorParserState();

            userState.LinkAction("foobar",
                                 ValueType.Boolean,
                                 ValueType.Number,
                                 ValueType.String
                                 );

            var state = new ParserState(
                "foobar(true or false, 4 + 4, \"hello\")", 4, userState
                );

            var result = Compiler.BindingAction()(state);

            Assert.AreEqual(
                new BindingActionNode("foobar",
                                      new BooleanLiteral(true),
                                      new NumberLiteral(8),
                                      new StringLiteral("hello")
                                      ),
                result
                );
        }
예제 #2
0
        public static void BindingAction0Success()
        {
            var userState = new RumorParserState();

            userState.LinkAction("foobar");

            var state = new ParserState(
                "foobar()", 4, userState
                );

            var result = Compiler.BindingAction()(state);

            Assert.AreEqual(new BindingActionNode("foobar"), result);
        }
예제 #3
0
        public static void IdentifierLabelRepeatFailure()
        {
            var userState = new RumorParserState();

            userState.UsedIdentifiers.Add("foobar");

            var state = new ParserState("[foobar]", 4, userState);

            var exception = Assert.Throws <ReasonException>(() =>
                                                            Compiler.IdentifierLabel(state)
                                                            );

            Assert.AreEqual(
                "parse exception at index 0: the identifier \"foobar\" has " +
                "already been used!",
                exception.Message
                );
        }
예제 #4
0
        public static void BindingAction1Success()
        {
            var userState = new RumorParserState();

            userState.LinkAction("foobar",
                                 ValueType.Boolean
                                 );

            var state = new ParserState(
                "foobar(true or false)", 4, userState
                );

            var result = Compiler.BindingAction()(state);

            Assert.AreEqual(
                new BindingActionNode("foobar",
                                      new BooleanLiteral(true)
                                      ),
                result
                );
        }