예제 #1
0
        private Declarations Parameters()
        {
            Declarations decs = new Declarations();

            while (currentToken.GetType() != Token.Type.RightParen)
            {
                Type     t = GetType();
                Variable v = new Variable(currentToken.GetValue());
                Match(Token.Type.Identifier);
                decs.Add(v.ToString(), new Declaration(v, t));
                if (currentToken.GetType() == Token.Type.Comma)
                {
                    Match(Token.Type.Comma);
                }
            }

            return(decs);
        }
예제 #2
0
        private void Declaration(Declarations ds, Functions functions)
        {
            Type Type = GetType();

            while (currentToken.GetType() != Token.Type.Eof)
            {
                Variable v = new Variable(currentToken.GetValue());
                Match(Token.Type.Identifier);
                if (currentToken.GetType() == Token.Type.LeftParen)
                {
                    Function(functions, Type, v);
                    if (IsType())
                    {
                        Type = GetType();
                    }
                    else
                    {
                        break;
                    }
                }
                else
                {
                    ds.Add(v.ToString(), new Declaration(v, Type));
                    if (currentToken.GetType() == Token.Type.Comma)
                    {
                        Match(Token.Type.Comma);
                    }
                    else if (currentToken.GetType() == Token.Type.Semicolon)
                    {
                        Match(Token.Type.Semicolon);
                        if (IsType())
                        {
                            Type = GetType();
                        }
                        else
                        {
                            break;
                        }
                    }
                }
            }
        }