Ejemplo n.º 1
0
        //<stmt-list>//
        public Node StmtList()
        {
            var stmtList = new StmtList();

            while (firstOfStatement.Contains(CurrentToken))
            {
                switch (CurrentToken)
                {
                case TokenCategory.IDENTIFIER:
                    stmtList.Add(stmtId());
                    break;

                case TokenCategory.IF:
                    stmtList.Add(If());
                    break;

                case TokenCategory.LOOP:
                    var LooperLupe = new Loop()
                    {
                        AnchorToken = Expect(TokenCategory.LOOP)
                    };
                    Expect(TokenCategory.CURLY_BRACKET_OPEN);
                    LooperLupe.Add(StmtList());
                    stmtList.Add(LooperLupe);
                    Expect(TokenCategory.CURLY_BRACKET_CLOSE);
                    break;

                case TokenCategory.BREAK:

                    stmtList.Add(new Break()
                    {
                        AnchorToken = Expect(TokenCategory.BREAK)
                    });

                    Expect(TokenCategory.SEMICOLON);
                    break;

                case TokenCategory.RETURN:
                    var myreturn = new Return()
                    {
                        AnchorToken = Expect(TokenCategory.RETURN)
                    };
                    myreturn.Add(Expression());
                    stmtList.Add(myreturn);
                    Expect(TokenCategory.SEMICOLON);
                    break;

                case TokenCategory.SEMICOLON:
                    Expect(TokenCategory.SEMICOLON);
                    break;

                default:
                    throw new SyntaxError(firstOfStatement,
                                          tokenStream.Current);
                }
            }
            return(stmtList);
        }
Ejemplo n.º 2
0
        public override void DoMouseDown(MouseButtonEventArgs bu)
        {
            Console.WriteLine("abc");
            if (Root.Hovered == Root)
            {
                if (bu.Button == MouseButton.Left)
                {
                    Dragging = true;
                    vec3 pos = new vec3();

                    if (CastCursor(ref pos))
                    {
                        LastCursor = pos;
                        currentLoop.Add(new vec2(pos).csgeom());
                    }
                }
            }
        }
        public Node StmtLoop()
        {
            var loop = new Loop()
            {
                AnchorToken = Expect(TokenCategory.LOOP)
            };

            Expect(TokenCategory.OPEN_BRACKET);
            loop.Add(StmtList());
            Expect(TokenCategory.CLOSE_BRACKET);
            return(loop);
        }
Ejemplo n.º 4
0
        public Node Loop()
        {
            var n1 = new Loop();

            Expect(TokenType.LOOP);
            Expect(TokenType.BLOCK_BEGIN);
            while (firstOfStatement.Contains(CurrentToken))
            {
                n1.Add(Statement());
            }
            Expect(TokenType.BLOCK_END);
            return(n1);
        }
Ejemplo n.º 5
0
        public Node Loop()
        {
            var node = new Loop()
            {
                AnchorToken = Expect(TokenCategory.LOOP)
            };

            Expect(TokenCategory.OPENEDCURLY);
            if (CurrentToken != TokenCategory.CLOSEDCURLY)
            {
                node.Add(StmtList());
            }
            Expect(TokenCategory.CLOSEDCURLY);
            return(node);
        }
Ejemplo n.º 6
0
        public Node Loop()
        {
            var result = new Loop()
            {
                AnchorToken = Expect(TokenCategory.LOOP)
            };

            while (firstOfStatement.Contains(CurrentToken))
            {
                result.Add(Statement());
            }
            Expect(TokenCategory.END);
            Expect(TokenCategory.SEMICOL);
            return(result);
        }
Ejemplo n.º 7
0
        public Node StatementLoop()
        {
            var n1 = new Loop()
            {
                AnchorToken = Expect(TokenCategory.LOOP)
            };

            Expect(TokenCategory.BRACE_OPEN);
            while (firstOfStatement.Contains(CurrentToken))
            {
                n1.Add(Statement());
            }
            Expect(TokenCategory.BRACE_CLOSE);
            return(n1);
        }
Ejemplo n.º 8
0
        public Node Loop()
        {
            var result = new Loop()
            {
                AnchorToken = Expect(TokenCategory.LOOP)
            };

            var statementList = new StatementList();

            if (firstOfStatement.Contains(CurrentToken))
            {
                while (firstOfStatement.Contains(CurrentToken))
                {
                    statementList.Add(Statement());
                }
            }
            result.Add(statementList);

            Expect(TokenCategory.END);
            Expect(TokenCategory.SEMICOLON);
            return(result);
        }
Ejemplo n.º 9
0
 //------------------------------------------------------------------
 public void AddInLoop(Action action)
 {
     Loop.Add(action);
 }
Ejemplo n.º 10
0
        public void RunTest()
        {
            Loop loo = new Loop(_mock, 0, 0);

            loo.Add(new Token(TokenType.Name, 0, 0, "bla"));
            loo.Add(new Token(TokenType.Name, 0, 0, "in"));
            loo.Add(new Token(TokenType.Name, 0, 0, "fuu"));
            loo.Add(new Token(TokenType.Control, 0, 0, ".."));
            loo.Add(new Token(TokenType.Number, 0, 0, "4"));
            loo.Add(new Token(TokenType.Control, 0, 0, "-"));
            loo.Add(new Token(TokenType.Number, 0, 0, "8"));
            loo.Add(new Token(TokenType.Name, 0, 0, "do"));
            loo.Add(new Token(TokenType.Name, 0, 0, "fuu"));
            loo.Add(new Token(TokenType.Control, 0, 0, ":="));
            loo.Add(new Token(TokenType.Name, 0, 0, "fuu"));
            loo.Add(new Token(TokenType.Control, 0, 0, "+"));
            loo.Add(new Token(TokenType.Name, 0, 0, "bla"));
            loo.Exit();
            loo.Add(new Token(TokenType.Name, 0, 0, "end"));
            loo.Add(new Token(TokenType.Name, 0, 0, "for"));
            loo.Exit();
            loo.Run();
            int v = ((MplInteger)_mock.Definitions["bla"].GetValue()).Val;

            Assert.AreEqual(-4, v);
            v = ((MplInteger)_mock.Definitions["fuu"].GetValue()).Val;
            Assert.AreEqual(-10, v);
        }