Example #1
0
        public void TestTerminals()
        {
            AssertSuccess(LBrace.Parse("{"), '{', true);
            AssertSuccess(RBrace.Parse("}"), '}', true);
            AssertSuccess(LParen.Parse("("), '(', true);
            AssertSuccess(RParen.Parse(")"), ')', true);
            AssertSuccess(Comma.Parse(","), ',', true);
            AssertSuccess(UScore.Parse("_"), '_', true);
            AssertSuccess(DQuote.Parse("\""), '"', true);
            AssertSuccess(SQuote.Parse("'"), '\'', true);

            AssertSuccess(Str.Parse("\"abc\""), "abc", true);
            AssertSuccess(Chr.Parse("'a'"), "a", true);

            AssertSuccess(ExprParser.Int.Parse("234"), "234", true);
            AssertSuccess(Float.Parse("234.0"), "234.0", true);
            AssertSuccess(Float.Parse(".0"), ".0", true);
            AssertSuccess(Float.Parse("1e2"), "1e2", true);
            AssertSuccess(Float.Parse("1E2"), "1E2", true);
            AssertSuccess(Float.Parse("1E-2"), "1E-2", true);
            AssertSuccess(Float.Parse("1E+2"), "1E+2", true);
            AssertSuccess(Float.Parse("1.0E2"), "1.0E2", true);
            AssertSuccess(Float.Parse("1.0E-2"), "1.0E-2", true);
            AssertSuccess(Float.Parse("1.0E+2"), "1.0E+2", true);


            AssertSuccess(IdStart.Parse("_"), '_', true);
            AssertSuccess(IdStart.Parse("a"), 'a', true);
            AssertSuccess(IdRest.Parse("_"), '_', true);
            AssertSuccess(IdRest.Parse("1"), '1', true);
            AssertSuccess(IdRest.Parse("_"), '_', true);
            AssertSuccess(IdRest.Parse("a"), 'a', true);
            AssertSuccess(Id.Parse("_"), "_", true);
            AssertSuccess(Id.Parse("A"), "A", true);
            AssertSuccess(Id.Parse("z"), "z", true);
            AssertSuccess(Id.Parse("abc"), "abc", true);
            AssertSuccess(Id.Parse("_abc"), "_abc", true);
            AssertSuccess(Id.Parse("_1"), "_1", true);
            AssertSuccess(Id.Parse("_1_a_zZ"), "_1_a_zZ", true);
            AssertSuccess(Id.Parse("e"), "e", true);
            AssertSuccess(Id.Parse("el"), "el", true);
            AssertSuccess(Id.Parse("els"), "els", true);
            AssertSuccess(Id.Parse("else1"), "else1", true);
            AssertSuccess(Id.Parse("i"), "i", true);
            AssertSuccess(Id.Parse("if1"), "if1", true);
            AssertSuccess(Id.Parse("if_"), "if_", true);
            AssertSuccess(Id.Parse("t"), "t", true);
            AssertSuccess(Id.Parse("tr"), "tr", true);

            AssertSuccess(True.Parse("true"), "true", true);
            AssertSuccess(False.Parse("false"), "false", true);
            AssertSuccess(If.Parse("if"), "if", true);
            AssertSuccess(Else.Parse("else"), "else", true);
            AssertSuccess(Then.Parse("then"), "then", true);
            AssertSuccess(ExprParser.In.Parse("in"), "in", true);

            AssertSuccess(Bool.Parse("true"), "true", true);
            AssertSuccess(Bool.Parse("false"), "false", true);
            AssertSuccess(Bool.Parse("\"true\""), "true", true);
            AssertSuccess(Bool.Parse("\"false\""), "false", true);

            AssertSuccess(KeyWords.Parse("else"), "else", true);
            AssertSuccess(KeyWords.Parse("then"), "then", true);
            AssertSuccess(KeyWords.Parse("if"), "if", true);
            AssertSuccess(KeyWords.Parse("in "), "in", true);
        }