Hi all,
I'm getting this error for the below program, can anyone figure where is the issue?
error CS0161: 'AbstractSyntax.Parser.type()': not all code paths return a value
in my parser.cs:
private Type type() <-- error { Type t = null; switch (current_token.getType()) { case Token.TokenType.Int: case Token.TokenType.Char: case Token.TokenType.Float: case Token.TokenType.Bool: t = new Type(current_token.toString()); current_token = mylexer.next(); return t; default: Console.WriteLine("Syntax error: line " + mylexer.getCurrentLine() + " expecting: int, char, bool, or float" + "; saw: " + current_token.getType() + "value is " + current_token.toString()); current_token = mylexer.next(); error_flag = true; break; } }
You can return it from within the switch statement if you wished.
Currently it either returns from within the switch exlpicitly (line 12: return t;) or it exits the switch (default) because there is no explicit return statement