public void SemanticError21()
        {
            GlobalSymbolList globals = new GlobalSymbolList();
            globals.Add("a", IrisType.Integer.MakeArrayType());

            string input = @"a := 1";
            TestHelpers.TestStatementParserWithError(input, globals, @"(1, 6) Cannot assign to 'a' (type mismatch error).");
        }
        public void SemanticError31()
        {
            GlobalSymbolList globals = new GlobalSymbolList();
            globals.Add("a", IrisType.Integer);

            string input = @"a(false)";
            TestHelpers.TestStatementParserWithError(input, globals, @"(1, 2) Symbol 'a' is not a procedure or function.");
        }
        public void SemanticError38()
        {
            GlobalSymbolList globals = new GlobalSymbolList();
            globals.Add("a", Procedure.Create(new Variable[0]));
            globals.Add("b", IrisType.Integer);

            string input = @"b := a";
            TestHelpers.TestStatementParserWithError(input, globals, @"(1, 3) Cannot use procedure in assignment statement.");
        }
        public void SemanticError37()
        {
            GlobalSymbolList globals = new GlobalSymbolList();
            globals.Add("a", Procedure.Create(new Variable[0]));
            globals.Add("b", IrisType.Integer);

            string input = @"a := b";
            TestHelpers.TestStatementParserWithError(input, globals, @"(1, 3) Cannot assign to result of function or procedure call.");
        }
        public void SemanticError34()
        {
            GlobalSymbolList globals = new GlobalSymbolList();
            globals.Add("a", IrisType.Integer);
            globals.Add("b", IrisType.Integer);

            string input = @"for a := 0 to 'test' do b := 1";
            TestHelpers.TestStatementParserWithError(input, globals, @"(1, 15) Expecting integer expression.");
        }
        public void SyntaxError10()
        {
            GlobalSymbolList globals = new GlobalSymbolList();

            globals.Add("a", IrisType.Integer.MakeArrayType());

            string input = @"a[0];";

            TestHelpers.TestStatementParserWithError(input, globals, @"(1, 5) Expecting ':='.");
        }
        public void SyntaxError08()
        {
            GlobalSymbolList globals = new GlobalSymbolList();

            globals.Add("a", IrisType.Integer);

            string input = @"else a := 1";

            TestHelpers.TestStatementParserWithError(input, globals, @"(1, 6) Cannot start statement with 'else' or unexpected ';' after if statement.");
        }
        public void SyntaxError24()
        {
            GlobalSymbolList globals = new GlobalSymbolList();

            globals.Add("a", IrisType.Integer);

            string input = @"for 'test' := 0 to 'test' do a := 1";

            TestHelpers.TestStatementParserWithError(input, globals, @"(1, 5) Expecting integer identifier.");
        }
        public void SyntaxError09()
        {
            string input = @"if true then begin ;";

            TestHelpers.TestStatementParserWithError(input, @"(1, 21) Unexpected end of file looking for 'end'.");
        }
        public void SyntaxError07()
        {
            string input = @"if (true then begin end;";

            TestHelpers.TestStatementParserWithError(input, @"(1, 10) Expecting ')'.");
        }
        public void SyntaxError06()
        {
            string input = @"if true do begin end;";

            TestHelpers.TestStatementParserWithError(input, @"(1, 9) Expecting 'then'.");
        }
        public void SyntaxError05()
        {
            string input = @"while true begin end;";

            TestHelpers.TestStatementParserWithError(input, @"(1, 12) Expecting 'do'.");
        }
        public void SyntaxError02()
        {
            string input = @"if";

            TestHelpers.TestStatementParserWithError(input, @"(1, 3) Expecting expression.");
        }
        public void SyntaxError01()
        {
            string input = @"";

            TestHelpers.TestStatementParserWithError(input, @"(1, 1) Expecting statement.");
        }
示例#15
0
        public void SemanticError16()
        {
            string input = @"if 'test' do begin end;";

            TestHelpers.TestStatementParserWithError(input, @"(1, 4) Expecting boolean expression.");
        }
示例#16
0
        public void SemanticError20()
        {
            string input = @"a := 1";

            TestHelpers.TestStatementParserWithError(input, @"(1, 3) Symbol 'a' is undefined.");
        }
        public void SyntaxError03()
        {
            string input = @"if true then";

            TestHelpers.TestStatementParserWithError(input, @"(1, 13) Expecting statement.");
        }