Пример #1
0
        public Node AssignmentStatement(Token anchorToken)
        {
            var result = new AssignmentStatement();

            if (CurrentToken == TokenCategory.LEFT_SQR_BRACK)
            {
                var listIndexExpression = new ListIndexExpression();
                listIndexExpression.Add(new Identifier()
                {
                    AnchorToken = anchorToken
                });
                Expect(TokenCategory.LEFT_SQR_BRACK);
                listIndexExpression.Add(Expression());
                Expect(TokenCategory.RIGHT_SQR_BRACK);
                result.Add(listIndexExpression);
            }
            else
            {
                result.Add(new Identifier()
                {
                    AnchorToken = anchorToken
                });
            }

            result.AnchorToken = Expect(TokenCategory.ASSIGN_CONST);
            result.Add(Expression());
            Expect(TokenCategory.SEMICOLON);

            return(result);
        }
Пример #2
0
        public Node AssignmentCallStatement()
        {
            var identif    = Expect(TokenCategory.IDENTIFIER);
            var assignment = new AssignmentStatement();
            var call       = new CallStatement();

            Console.WriteLine("IDENTIFFFF" + identif);
            Console.WriteLine("CT: " + CurrentToken);
            //var alter = new Expression();

            //call-statement
            if (CurrentToken == TokenCategory.INITPARENTHESIS)
            {
                Expect(TokenCategory.INITPARENTHESIS);
                if (firstOfSimpleExpression.Contains(CurrentToken))
                {
                    call.Add(Expression());
                    while (CurrentToken == TokenCategory.COMMA)
                    {
                        Expect(TokenCategory.COMMA);
                        call.Add(Expression());
                    }
                }
                //call.Add(
                Expect(TokenCategory.CLOSINGPARENTHESIS);
                Expect(TokenCategory.ENDLINE);

                var result = new List()
                {
                    call
                };
                call.AnchorToken = identif;
                return(call);
                //call.AnchorToken = identif;
                //return call;
            }
            else if (CurrentToken == TokenCategory.INITBRACKET || CurrentToken == TokenCategory.CONSTANTDECLARATION)
            {
                if (CurrentToken == TokenCategory.INITBRACKET)
                {
                    Expect(TokenCategory.INITBRACKET);
                    var expression = Expression();
                    Expect(TokenCategory.CLOSINGBRACKET);
                    assignment.Add(expression);
                }
                Expect(TokenCategory.CONSTANTDECLARATION);
                var expression2 = Expression();
                Expect(TokenCategory.ENDLINE);
                assignment.Add(expression2);
                assignment.AnchorToken = identif;
                return(assignment);
            }
            /************** ATENCION ************/
            /************** ATENCION ************/
            /************** ATENCION ************/

            else
            {
                throw new SyntaxError(firstOfStatement,
                                      tokenStream.Current);
            }

            return(call);
        }