1

it says not all code paths return a value

private string Fisrt(string nonTerminal)
    {
        for (int j = 0; j < 6; j++)
        {
            if (Tokens[j, 0] == nonTerminal)
            {
                if (char.IsLower((char)Tokens[j, 3][0]))
                    return (Tokens[j, 3]);
                else
                    Fisrt(Tokens[j, 3]);
            }
        }
    }
1
  • it's declared in the function, a string value is returned but else is not returning a string value. add a return statement to the else.. Commented Jun 26, 2010 at 16:19

3 Answers 3

1
private string Fisrt(string nonTerminal)
    {
        for (int j = 0; j < 6; j++)
        {
            if (Tokens[j, 0] == nonTerminal)
            {
                if (char.IsLower((char)Tokens[j, 3][0]))
                    return (Tokens[j, 3]);
                else
                    return Fisrt(Tokens[j, 3]);
                 /* ^ add a return here */
            }
        }

        return SOMETHING;
     /* ^ You also need to add some return value here */
    }

You also need to decide what string value (or null) to return in the event your for loop exits normally.

Sign up to request clarification or add additional context in comments.

1 Comment

What if Tokens[j,0]==nonTerminal is never true?
1

For example, what if none of the Tokens[j, 0], with j values 0 to 5, is nonTerminal?

Or, if Tokens[j, 3][0] is never lowercase?

Comments

1

You should return the recursive step

`return First(Tokens[j, 3])`

and handle the cases outside the outer for and if.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.