MCSN-project2014 / APproject

Project for the MCSN Advanced Programming Module A.Y. 2014/2015
http://mcsn-project2014.github.io/APproject/
MIT License
4 stars 0 forks source link

Fibonacci Testing #32

Closed teto1992 closed 9 years ago

teto1992 commented 9 years ago

I wrote the funW@P code for the Fibonacci sequence as:

fun fib(n int) int{ var retVal int = -1; if n == 0 { retVal = 0; } if n == 1 { retVal = 1; } else { retVal = (fib(n-1) + fib(n-2)); } return retVal; }

fun main(){ return fib(5); }

Unfortunately the parsing doesn't produce any result and throws an Exception which is not handled. Any idea? Is my syntax OK?

Mene90 commented 9 years ago

the problem is the 'return' inside a main function. Because, from the point of view of semantic rules, this kind of statement is not implemented for main function.

Mene90 commented 9 years ago

Anyway now the parser manages this kind of problems