[SOLVED] Missing EOF at 'val'

Hi,
I can`t figure out why getting this error. This rule below appears to be simple but it is causing me some issues. Any ideas?

2019-03-11 23:10:31.360 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'home.rules' has errors, therefore ignoring it: [434,1]: missing EOF at 'val'
val maxHumidity = 67
val minHumidity = 58

rule "Turn ON Vent"
when
    Item Humidity_GF_Bath changed
then
    if (Humidity_GF_Bath.state as Number > maxHumidity && 
	    Humidity_GF_Bath.state != NULL &&
        Humidity_GF_Bath.state != UNDEF &&
        Humidity_GF_Bath.state > 0) {
    if (Fan_GF_Bath.state != ON) Fan_GF_Bath.sendCommand(ON)
    }
else 
    if (Humidity_GF_Bath.state as Number < minHumidity) {
        Fan_GF_Bath.sendCommand(OFF)
    }
end

Line 434 is obviously a long way down a larger file. What makes you think this part is the culprit?

Global definitions (val) are best placed ahead of any rules, though I don’t think that would provoke a parse error.

I moved both val`s to the start of the rule file and getting another error now.

2019-03-11 23:25:02.202 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'home.rules' has errors, therefore ignoring it: [447,55]: missing '>' at ')'

It`s complaining about the first line after else

  if (Humidity_GF_Bath.state as Number < minHumidity) {

I don’t know how the parser likes it, but maybe you missing braces after else? Like this I mean:

else {
    if (Humidity_GF_Bath.state as Number < minHumidity) {
        Fan_GF_Bath.sendCommand(OFF)
    }
}

I suspect it thinks the < is part of the as Number, like QuantityType<Number> style usage. Add brackets.

if ( (Humidity_GF_Bath.state as Number) < minHumidity) {

Thanks @rossko57 indeed your suggestion was correct, problem solved, solution marked.